-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/dev/itsmeow/whisperwoods/entity/EntityAnimalWithTypesAndSizeContainable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package dev.itsmeow.whisperwoods.entity; | ||
|
||
import dev.itsmeow.imdlib.entity.util.IContainable; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.CompoundNBT; | ||
import net.minecraft.util.ActionResultType; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.world.World; | ||
|
||
public abstract class EntityAnimalWithTypesAndSizeContainable extends EntityAnimalWithTypesAndSize implements IContainable { | ||
|
||
public EntityAnimalWithTypesAndSizeContainable(EntityType<? extends EntityAnimalWithTypesAndSizeContainable> entityType, World worldIn) { | ||
super(entityType, worldIn); | ||
} | ||
|
||
@Override | ||
protected void registerData() { | ||
super.registerData(); | ||
this.registerFromContainerKey(); | ||
} | ||
|
||
@Override | ||
public void writeAdditional(CompoundNBT compound) { | ||
super.writeAdditional(compound); | ||
this.writeFromContainerToEntity(compound); | ||
} | ||
|
||
@Override | ||
public void readAdditional(CompoundNBT compound) { | ||
super.readAdditional(compound); | ||
this.readFromContainerToEntity(compound); | ||
} | ||
|
||
@Override | ||
public boolean canDespawn(double distanceToClosestPlayer) { | ||
return !this.isFromContainer() && despawn(distanceToClosestPlayer); | ||
} | ||
|
||
@Override | ||
public boolean preventDespawn() { | ||
return this.isFromContainer(); | ||
} | ||
|
||
@Override | ||
public void setContainerData(ItemStack bucket) { | ||
IContainable.super.setContainerData(bucket); | ||
CompoundNBT tag = bucket.getTag(); | ||
if(bucket.getTag() == null) { | ||
tag = new CompoundNBT(); | ||
} | ||
tag.putString("BucketVariantTag", this.getVariantNameOrEmpty()); | ||
tag.putFloat("SizeTag", this.dataManager.get(SIZE)); | ||
bucket.setTag(tag); | ||
} | ||
|
||
@Override | ||
public ActionResultType func_230254_b_(PlayerEntity player, Hand hand) { | ||
if(this.processContainerInteract(player, hand)) { | ||
return ActionResultType.SUCCESS; | ||
} | ||
return super.func_230254_b_(player, hand); | ||
} | ||
|
||
@Override | ||
public void readFromContainerTag(CompoundNBT tag) { | ||
if(tag.contains("BucketVariantTag")) { | ||
this.setType(tag.getString("BucketVariantTag")); | ||
} | ||
if(tag.contains("SizeTag")) { | ||
this.setSize(tag.getFloat("SizeTag")); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/whisperwoods/models/item/bottled_moth.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "whisperwoods:items/bottled_moth" | ||
} | ||
} |
Binary file added
BIN
+285 Bytes
src/main/resources/assets/whisperwoods/textures/items/bottled_moth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.