Add cubozoa bucket and make fish buckets retain variant

This change adds a cubozoa bucket that functions like the other types of
fish buckets. In addition to that, this commit also saves the size and
variant of end fish and cubozoa in the item tag when they are scooped up
in a bucket, so that they retain their size/variant when they are placed
again. Here is the issue from the Forge port that made me away of the
issue: https://github.com/Beethoven92/BetterEndForge/issues/93
This commit is contained in:
vemerion 2021-04-18 09:11:33 +02:00
parent d0f5f664c6
commit b49bd6ef91
6 changed files with 34 additions and 3 deletions

View file

@ -22,7 +22,6 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.passive.SchoolingFishEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
@ -53,6 +52,14 @@ public class CubozoaEntity extends SchoolingFishEntity {
if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) {
this.dataTracker.set(VARIANT, (byte) 1);
}
if (entityTag != null) {
if (entityTag.contains("variant"))
this.dataTracker.set(VARIANT, entityTag.getByte("variant"));
if (entityTag.contains("scale"))
this.dataTracker.set(SCALE, entityTag.getByte("scale"));
}
this.calculateDimensions();
return data;
}
@ -120,7 +127,11 @@ public class CubozoaEntity extends SchoolingFishEntity {
@Override
protected ItemStack getFishBucketItem() {
return new ItemStack(Items.WATER_BUCKET);
ItemStack bucket = EndItems.BUCKET_CUBOZOA.getDefaultStack();
CompoundTag tag = bucket.getOrCreateTag();
tag.putByte("variant", dataTracker.get(VARIANT));
tag.putByte("scale", dataTracker.get(SCALE));
return bucket;
}
@Override

View file

@ -46,6 +46,14 @@ public class EndFishEntity extends SchoolingFishEntity {
if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) {
this.dataTracker.set(VARIANT, (byte) (random.nextInt(VARIANTS_SULPHUR) + VARIANTS_NORMAL));
}
if (entityTag != null) {
if (entityTag.contains("variant"))
this.dataTracker.set(VARIANT, entityTag.getByte("variant"));
if (entityTag.contains("scale"))
this.dataTracker.set(SCALE, entityTag.getByte("scale"));
}
this.calculateDimensions();
return data;
}
@ -77,7 +85,11 @@ public class EndFishEntity extends SchoolingFishEntity {
@Override
protected ItemStack getFishBucketItem() {
return new ItemStack(EndItems.BUCKET_END_FISH);
ItemStack bucket = EndItems.BUCKET_END_FISH.getDefaultStack();
CompoundTag tag = bucket.getOrCreateTag();
tag.putByte("variant", dataTracker.get(VARIANT));
tag.putByte("scale", dataTracker.get(SCALE));
return bucket;
}
@Override

View file

@ -120,6 +120,7 @@ public class EndItems {
public final static Item END_FISH_RAW = registerFood("end_fish_raw", FoodComponents.SALMON);
public final static Item END_FISH_COOKED = registerFood("end_fish_cooked", FoodComponents.COOKED_SALMON);
public final static Item BUCKET_END_FISH = registerItem("bucket_end_fish", new FishBucketItem(EndEntities.END_FISH, Fluids.WATER, makeItemSettings().maxCount(1)));
public final static Item BUCKET_CUBOZOA = registerItem("bucket_cubozoa", new FishBucketItem(EndEntities.CUBOZOA, Fluids.WATER, makeItemSettings().maxCount(1)));
public final static Item SWEET_BERRY_JELLY = registerFood("sweet_berry_jelly", 6, 0.75F);
public final static Item SHADOW_BERRY_JELLY = registerFood("shadow_berry_jelly", 7, 0.75F, new StatusEffectInstance(StatusEffects.NIGHT_VISION, 400));
public final static Item BLOSSOM_BERRY = registerFood("blossom_berry", FoodComponents.APPLE);

View file

@ -316,6 +316,7 @@
"block.betterend.quartz_lantern": "Quartz Lantern",
"item.betterend.bucket_end_fish": "Bucket of End Fish",
"item.betterend.bucket_cubozoa": "Bucket of Cubozoa",
"item.betterend.end_fish_cooked": "Cooked End Fish",
"item.betterend.end_fish_raw": "End Fish",

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:item/bucket_cubozoa"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB