Removed color provider
This commit is contained in:
parent
2c8862a37b
commit
4040597a6d
475 changed files with 5411 additions and 7521 deletions
|
@ -3,7 +3,6 @@ package ru.betterend.blocks.entities;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ElytraItem;
|
||||
|
@ -24,11 +23,11 @@ import java.util.List;
|
|||
public class BlockEntityHydrothermalVent extends BlockEntity {
|
||||
private final static Vec3 POSITIVE_Y = new Vec3(0.0f, 1.0f, 0.0f);
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
|
||||
|
||||
public BlockEntityHydrothermalVent(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.HYDROTHERMAL_VENT, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
public static <T extends BlockEntity> void tick(Level level, BlockPos worldPosition, BlockState state, T uncastedEntity) {
|
||||
if (level != null && uncastedEntity instanceof BlockEntityHydrothermalVent && state.is(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
BlockEntityHydrothermalVent blockEntity = (BlockEntityHydrothermalVent) uncastedEntity;
|
||||
|
@ -36,11 +35,11 @@ public class BlockEntityHydrothermalVent extends BlockEntity {
|
|||
clientTick(level, worldPosition, state, blockEntity);
|
||||
}
|
||||
//else {
|
||||
serverTick(level, worldPosition, state, blockEntity);
|
||||
serverTick(level, worldPosition, state, blockEntity);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void clientTick(Level level, BlockPos worldPosition, BlockState state, BlockEntityHydrothermalVent blockEntity) {
|
||||
boolean active = state.getValue(HydrothermalVentBlock.ACTIVATED);
|
||||
if (active && level.random.nextInt(20) == 0 && state.getValue(HydrothermalVentBlock.WATERLOGGED)) {
|
||||
|
@ -50,7 +49,7 @@ public class BlockEntityHydrothermalVent extends BlockEntity {
|
|||
level.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void serverTick(Level level, BlockPos worldPosition, BlockState state, BlockEntityHydrothermalVent blockEntity) {
|
||||
boolean active = state.getValue(HydrothermalVentBlock.ACTIVATED);
|
||||
POS.set(worldPosition).move(Direction.UP);
|
||||
|
@ -70,7 +69,7 @@ public class BlockEntityHydrothermalVent extends BlockEntity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean hasElytra(LivingEntity entity) {
|
||||
Item item = entity.getItemBySlot(EquipmentSlot.CHEST).getItem();
|
||||
return item instanceof ElytraItem || item instanceof FallFlyingItem;
|
||||
|
|
|
@ -46,12 +46,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeHolder, StackedContentsCompatible {
|
||||
|
||||
|
||||
private static final int[] TOP_SLOTS = new int[]{0, 1};
|
||||
private static final int[] BOTTOM_SLOTS = new int[]{2, 3};
|
||||
private static final int[] SIDE_SLOTS = new int[]{1, 2};
|
||||
private static final Map<Item, Integer> AVAILABLE_FUELS = Maps.newHashMap();
|
||||
|
||||
|
||||
private final Object2IntOpenHashMap<ResourceLocation> recipesUsed;
|
||||
protected NonNullList<ItemStack> inventory;
|
||||
protected final ContainerData propertyDelegate;
|
||||
|
@ -60,7 +60,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
private int smeltTime;
|
||||
private int burnTime;
|
||||
private int fuelTime;
|
||||
|
||||
|
||||
public EndStoneSmelterBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.END_STONE_SMELTER, blockPos, blockState);
|
||||
this.inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
@ -80,7 +80,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set(int index, int value) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
@ -96,22 +96,22 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
EndStoneSmelterBlockEntity.this.smeltTimeTotal = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getCount() {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private boolean isBurning() {
|
||||
return burnTime > 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
return inventory.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
Iterator<ItemStack> iterator = inventory.iterator();
|
||||
|
@ -121,27 +121,26 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
return true;
|
||||
}
|
||||
itemStack = iterator.next();
|
||||
}
|
||||
while (itemStack.isEmpty());
|
||||
|
||||
} while (itemStack.isEmpty());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int slot) {
|
||||
return inventory.get(slot);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack removeItem(int slot, int amount) {
|
||||
return ContainerHelper.removeItem(inventory, slot, amount);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack removeItemNoUpdate(int slot) {
|
||||
return ContainerHelper.takeItem(inventory, slot);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setItem(int slot, ItemStack stack) {
|
||||
ItemStack itemStack = inventory.get(slot);
|
||||
|
@ -156,19 +155,17 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected int getSmeltTime() {
|
||||
if (level == null) return 200;
|
||||
int smeltTime = level.getRecipeManager().getRecipeFor(AlloyingRecipe.TYPE, this, level)
|
||||
.map(AlloyingRecipe::getSmeltTime).orElse(0);
|
||||
int smeltTime = level.getRecipeManager().getRecipeFor(AlloyingRecipe.TYPE, this, level).map(AlloyingRecipe::getSmeltTime).orElse(0);
|
||||
if (smeltTime == 0) {
|
||||
smeltTime = level.getRecipeManager().getRecipeFor(RecipeType.BLASTING, this, level)
|
||||
.map(BlastingRecipe::getCookingTime).orElse(200);
|
||||
smeltTime = level.getRecipeManager().getRecipeFor(RecipeType.BLASTING, this, level).map(BlastingRecipe::getCookingTime).orElse(200);
|
||||
smeltTime /= 1.5;
|
||||
}
|
||||
return smeltTime;
|
||||
}
|
||||
|
||||
|
||||
public void dropExperience(Player player) {
|
||||
if (level == null) return;
|
||||
List<Recipe<?>> list = Lists.newArrayList();
|
||||
|
@ -188,21 +185,21 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
player.awardRecipes(list);
|
||||
recipesUsed.clear();
|
||||
}
|
||||
|
||||
|
||||
private void dropExperience(Level world, Vec3 vec3d, int count, float amount) {
|
||||
int expTotal = Mth.floor(count * amount);
|
||||
float g = Mth.frac(count * amount);
|
||||
if (g != 0.0F && Math.random() < g) {
|
||||
expTotal++;
|
||||
}
|
||||
|
||||
|
||||
while (expTotal > 0) {
|
||||
int expVal = ExperienceOrb.getExperienceValue(expTotal);
|
||||
expTotal -= expVal;
|
||||
world.addFreshEntity(new ExperienceOrb(world, vec3d.x, vec3d.y, vec3d.z, expVal));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
if (level != null && level.getBlockEntity(worldPosition) != this) {
|
||||
|
@ -210,30 +207,30 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
}
|
||||
return player.distanceToSqr(worldPosition.getX() + 0.5D, worldPosition.getY() + 0.5D, worldPosition.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearContent() {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Component getDefaultName() {
|
||||
return new TranslatableComponent(String.format("block.%s.%s", BetterEnd.MOD_ID, EndStoneSmelter.ID));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected AbstractContainerMenu createMenu(int syncId, Inventory playerInventory) {
|
||||
return new EndStoneSmelterScreenHandler(syncId, playerInventory, this, propertyDelegate);
|
||||
}
|
||||
|
||||
|
||||
public static void tick(Level tickLevel, BlockPos tickPos, BlockState tickState, EndStoneSmelterBlockEntity blockEntity) {
|
||||
if (tickLevel == null) return;
|
||||
|
||||
|
||||
boolean initialBurning = blockEntity.isBurning();
|
||||
if (initialBurning) {
|
||||
blockEntity.burnTime--;
|
||||
}
|
||||
|
||||
|
||||
boolean burning = initialBurning;
|
||||
if (!tickLevel.isClientSide) {
|
||||
ItemStack fuel = blockEntity.inventory.get(2);
|
||||
|
@ -264,7 +261,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
blockEntity.setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (burning && accepted) {
|
||||
blockEntity.smeltTime++;
|
||||
if (blockEntity.smeltTime == blockEntity.smeltTimeTotal) {
|
||||
|
@ -285,17 +282,15 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean canAcceptRecipeOutput(Recipe<?> recipe) {
|
||||
if (recipe == null) return false;
|
||||
boolean validInput;
|
||||
if (recipe instanceof AlloyingRecipe) {
|
||||
validInput = !inventory.get(0).isEmpty() &&
|
||||
!inventory.get(1).isEmpty();
|
||||
validInput = !inventory.get(0).isEmpty() && !inventory.get(1).isEmpty();
|
||||
}
|
||||
else {
|
||||
validInput = !inventory.get(0).isEmpty() ||
|
||||
!inventory.get(1).isEmpty();
|
||||
validInput = !inventory.get(0).isEmpty() || !inventory.get(1).isEmpty();
|
||||
}
|
||||
if (validInput) {
|
||||
ItemStack result = recipe.getResultItem();
|
||||
|
@ -318,10 +313,10 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void craftRecipe(Recipe<?> recipe) {
|
||||
if (recipe == null || !canAcceptRecipeOutput(recipe)) return;
|
||||
|
||||
|
||||
ItemStack result = recipe.getResultItem();
|
||||
ItemStack output = inventory.get(3);
|
||||
if (output.isEmpty()) {
|
||||
|
@ -330,12 +325,12 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
else if (output.getItem() == result.getItem()) {
|
||||
output.grow(result.getCount());
|
||||
}
|
||||
|
||||
|
||||
assert this.level != null;
|
||||
if (!this.level.isClientSide) {
|
||||
setRecipeUsed(recipe);
|
||||
}
|
||||
|
||||
|
||||
if (recipe instanceof AlloyingRecipe) {
|
||||
inventory.get(0).shrink(1);
|
||||
inventory.get(1).shrink(1);
|
||||
|
@ -349,14 +344,14 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fillStackedContents(StackedContents finder) {
|
||||
for (ItemStack itemStack : this.inventory) {
|
||||
finder.accountStack(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRecipeUsed(Recipe<?> recipe) {
|
||||
if (recipe != null) {
|
||||
|
@ -365,12 +360,12 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
lastRecipe = recipe;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Recipe<?> getRecipeUsed() {
|
||||
return this.lastRecipe;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(Direction side) {
|
||||
if (side == Direction.DOWN) {
|
||||
|
@ -378,12 +373,12 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
}
|
||||
return side == Direction.UP ? TOP_SLOTS : SIDE_SLOTS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canPlaceItemThroughFace(int slot, ItemStack stack, Direction dir) {
|
||||
return this.canPlaceItem(slot, stack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTakeItemThroughFace(int slot, ItemStack stack, Direction dir) {
|
||||
if (dir == Direction.DOWN && slot == 2) {
|
||||
|
@ -391,7 +386,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected int getFuelTime(ItemStack fuel) {
|
||||
if (fuel.isEmpty()) {
|
||||
return 0;
|
||||
|
@ -399,7 +394,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
Item item = fuel.getItem();
|
||||
return AVAILABLE_FUELS.getOrDefault(item, getFabricFuel(fuel));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag tag) {
|
||||
super.load(tag);
|
||||
|
@ -414,7 +409,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
recipesUsed.put(new ResourceLocation(id), compoundTag.getInt(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
super.save(tag);
|
||||
|
@ -426,10 +421,10 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
CompoundTag usedRecipes = new CompoundTag();
|
||||
recipesUsed.forEach((identifier, integer) -> usedRecipes.putInt(identifier.toString(), integer));
|
||||
tag.put("RecipesUsed", usedRecipes);
|
||||
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
public boolean canPlaceItem(int slot, ItemStack stack) {
|
||||
if (slot == 3) {
|
||||
return false;
|
||||
|
@ -440,24 +435,24 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
ItemStack itemStack = this.inventory.get(2);
|
||||
return canUseAsFuel(stack) || stack.getItem() == Items.BUCKET && itemStack.getItem() != Items.BUCKET;
|
||||
}
|
||||
|
||||
|
||||
public static boolean canUseAsFuel(ItemStack stack) {
|
||||
return AVAILABLE_FUELS.containsKey(stack.getItem()) || getFabricFuel(stack) > 2000;
|
||||
}
|
||||
|
||||
|
||||
public static void registerFuel(ItemLike fuel, int time) {
|
||||
AVAILABLE_FUELS.put(fuel.asItem(), time);
|
||||
}
|
||||
|
||||
|
||||
public static Map<Item, Integer> availableFuels() {
|
||||
return AVAILABLE_FUELS;
|
||||
}
|
||||
|
||||
|
||||
private static int getFabricFuel(ItemStack stack) {
|
||||
Integer ticks = FuelRegistry.INSTANCE.get(stack.getItem());
|
||||
return ticks == null ? 0 : ticks;
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
AbstractFurnaceBlockEntity.getFuel().forEach((item, time) -> {
|
||||
if (time >= 2000) {
|
||||
|
|
|
@ -9,23 +9,23 @@ import ru.betterend.rituals.EternalRitual;
|
|||
|
||||
public class EternalPedestalEntity extends PedestalBlockEntity {
|
||||
private EternalRitual linkedRitual;
|
||||
|
||||
|
||||
public EternalPedestalEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.ETERNAL_PEDESTAL, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRitual() {
|
||||
return linkedRitual != null;
|
||||
}
|
||||
|
||||
|
||||
public void linkRitual(EternalRitual ritual) {
|
||||
this.linkedRitual = ritual;
|
||||
}
|
||||
|
||||
|
||||
public EternalRitual getRitual() {
|
||||
return linkedRitual;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLevel(Level level) {
|
||||
super.setLevel(level);
|
||||
|
@ -33,7 +33,7 @@ public class EternalPedestalEntity extends PedestalBlockEntity {
|
|||
linkedRitual.setWorld(level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
if (hasRitual()) {
|
||||
|
@ -41,7 +41,7 @@ public class EternalPedestalEntity extends PedestalBlockEntity {
|
|||
}
|
||||
return super.save(tag);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void fromTag(CompoundTag tag) {
|
||||
super.fromTag(tag);
|
||||
|
|
|
@ -9,13 +9,13 @@ import ru.betterend.registry.EndBlockEntities;
|
|||
import ru.betterend.rituals.InfusionRitual;
|
||||
|
||||
public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||
|
||||
|
||||
private InfusionRitual linkedRitual;
|
||||
|
||||
|
||||
public InfusionPedestalEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.INFUSION_PEDESTAL, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLevel(Level world) {
|
||||
super.setLevel(world);
|
||||
|
@ -26,19 +26,19 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
|||
linkRitual(new InfusionRitual(this, world, this.getBlockPos()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void linkRitual(InfusionRitual ritual) {
|
||||
linkedRitual = ritual;
|
||||
}
|
||||
|
||||
|
||||
public InfusionRitual getRitual() {
|
||||
return linkedRitual;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRitual() {
|
||||
return linkedRitual != null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
if (hasRitual()) {
|
||||
|
@ -46,7 +46,7 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
|||
}
|
||||
return super.save(tag);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void fromTag(CompoundTag tag) {
|
||||
super.fromTag(tag);
|
||||
|
@ -55,7 +55,7 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
|||
linkedRitual.fromTag(tag.getCompound("ritual"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static <T extends BlockEntity> void tickEnity(Level level, BlockPos blockPos, BlockState blockState, T uncastedEntity) {
|
||||
if (uncastedEntity instanceof InfusionPedestalEntity) {
|
||||
InfusionPedestalEntity blockEntity = (InfusionPedestalEntity) uncastedEntity;
|
||||
|
|
|
@ -16,70 +16,70 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
public class PedestalBlockEntity extends BlockEntity implements Container, BlockEntityClientSerializable {
|
||||
private ItemStack activeItem = ItemStack.EMPTY;
|
||||
|
||||
|
||||
private final int maxAge = 314;
|
||||
private int age;
|
||||
|
||||
|
||||
public PedestalBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
this(EndBlockEntities.PEDESTAL, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
public PedestalBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxAge() {
|
||||
return maxAge;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return activeItem.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int slot) {
|
||||
return activeItem;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack removeItem(int slot, int amount) {
|
||||
return removeItemNoUpdate(slot);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canPlaceItem(int slot, ItemStack stack) {
|
||||
return isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearContent() {
|
||||
activeItem = ItemStack.EMPTY;
|
||||
setChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack removeItemNoUpdate(int slot) {
|
||||
ItemStack stored = activeItem;
|
||||
clearContent();
|
||||
return stored;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setItem(int slot, ItemStack stack) {
|
||||
activeItem = stack.split(1);
|
||||
setChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
if (level != null && !level.isClientSide) {
|
||||
|
@ -97,46 +97,46 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Block
|
|||
}
|
||||
super.setChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag tag) {
|
||||
super.load(tag);
|
||||
fromTag(tag);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
tag.put("active_item", activeItem.save(new CompoundTag()));
|
||||
return super.save(tag);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fromClientTag(CompoundTag tag) {
|
||||
fromTag(tag);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompoundTag toClientTag(CompoundTag tag) {
|
||||
return save(tag);
|
||||
}
|
||||
|
||||
|
||||
protected void fromTag(CompoundTag tag) {
|
||||
if (tag.contains("active_item")) {
|
||||
CompoundTag itemTag = tag.getCompound("active_item");
|
||||
activeItem = ItemStack.of(itemTag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static <T extends BlockEntity> void tick(Level level, BlockPos blockPos, BlockState blockState, T uncastedEntity) {
|
||||
clientTick(level, blockPos, blockState, (PedestalBlockEntity) uncastedEntity);
|
||||
}
|
||||
|
||||
|
||||
private static void clientTick(Level tickLevel, BlockPos tickPos, BlockState tickState, PedestalBlockEntity blockEntity) {
|
||||
if (!blockEntity.isEmpty()) {
|
||||
blockEntity.age++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue