-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make crabs and horseshoe crabs bucketable
- Loading branch information
Showing
14 changed files
with
130 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
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
71 changes: 71 additions & 0 deletions
71
...meow/betteranimalsplus/common/entity/util/abstracts/EntityAnimalWithTypesContainable.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,71 @@ | ||
package dev.itsmeow.betteranimalsplus.common.entity.util.abstracts; | ||
|
||
import dev.itsmeow.imdlib.entity.interfaces.IContainable; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
|
||
public abstract class EntityAnimalWithTypesContainable extends EntityAnimalWithTypes implements IContainable { | ||
|
||
public EntityAnimalWithTypesContainable(EntityType<? extends EntityAnimalWithTypesContainable> entityType, Level worldIn) { | ||
super(entityType, worldIn); | ||
} | ||
|
||
@Override | ||
protected void defineSynchedData() { | ||
super.defineSynchedData(); | ||
this.registerFromContainerKey(); | ||
} | ||
|
||
@Override | ||
public void addAdditionalSaveData(CompoundTag compound) { | ||
super.addAdditionalSaveData(compound); | ||
this.writeFromContainerToEntity(compound); | ||
} | ||
|
||
@Override | ||
public void readAdditionalSaveData(CompoundTag compound) { | ||
super.readAdditionalSaveData(compound); | ||
this.readFromContainerToEntity(compound); | ||
} | ||
|
||
@Override | ||
public boolean removeWhenFarAway(double distanceToClosestPlayer) { | ||
return !this.isFromContainer() && despawn(distanceToClosestPlayer); | ||
} | ||
|
||
@Override | ||
public boolean requiresCustomPersistence() { | ||
return this.isFromContainer(); | ||
} | ||
|
||
@Override | ||
public void setContainerData(ItemStack bucket) { | ||
IContainable.super.setContainerData(bucket); | ||
CompoundTag tag = bucket.getTag(); | ||
if(bucket.getTag() == null) { | ||
tag = new CompoundTag(); | ||
} | ||
tag.putString("BucketVariantTag", this.getVariantNameOrEmpty()); | ||
bucket.setTag(tag); | ||
} | ||
|
||
@Override | ||
public InteractionResult mobInteract(Player player, InteractionHand hand) { | ||
if(this.processContainerInteract(player, hand)) { | ||
return InteractionResult.SUCCESS; | ||
} | ||
return super.mobInteract(player, hand); | ||
} | ||
|
||
@Override | ||
public void readFromContainerTag(CompoundTag tag) { | ||
if(tag.contains("BucketVariantTag")) { | ||
this.setType(tag.getString("BucketVariantTag")); | ||
} | ||
} | ||
} |
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
common/src/main/resources/assets/betteranimalsplus/models/item/crab_bucket.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": "betteranimalsplus:items/crab_bucket" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
common/src/main/resources/assets/betteranimalsplus/models/item/horseshoecrab_bucket.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": "betteranimalsplus:items/horseshoecrab_bucket" | ||
} | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+330 Bytes
common/src/main/resources/assets/betteranimalsplus/textures/items/crab_bucket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+323 Bytes
...main/resources/assets/betteranimalsplus/textures/items/horseshoecrab_bucket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.