Pedestals and rituals state saving

This commit is contained in:
Aleksey 2020-11-10 13:51:25 +03:00
parent c7d8365765
commit 28427f54a3
3 changed files with 21 additions and 10 deletions

View file

@ -238,7 +238,6 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
@Override
public void tick() {
boolean initialBurning = this.isBurning();
boolean smelting = false;
if (initialBurning) {
this.burnTime--;
}
@ -261,7 +260,6 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
this.fuelTime = this.burnTime;
burning = this.isBurning();
if (burning) {
smelting = true;
if (!fuel.isEmpty()) {
Item item = fuel.getItem();
fuel.decrement(1);
@ -270,6 +268,7 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
this.inventory.set(2, remainFuel == null ? ItemStack.EMPTY : new ItemStack(remainFuel));
}
}
this.markDirty();
}
}
@ -279,7 +278,7 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
this.smeltTime = 0;
this.smeltTimeTotal = this.getSmeltTime();
this.craftRecipe(recipe);
smelting = true;
this.markDirty();
}
} else {
this.smeltTime = 0;
@ -287,14 +286,10 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
}
if (initialBurning != burning) {
smelting = true;
this.world.setBlockState(pos, world.getBlockState(pos).with(EndStoneSmelter.LIT, burning), 3);
this.markDirty();
}
}
if (smelting) {
this.markDirty();
}
}
protected boolean canAcceptRecipeOutput(Recipe<?> recipe) {

View file

@ -38,6 +38,7 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
@Override
public void clear() {
this.activeItem = ItemStack.EMPTY;
this.markDirty();
}
@Override
@ -62,7 +63,10 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
@Override
public ItemStack removeStack(int slot) {
return this.activeItem = ItemStack.EMPTY;
ItemStack stored = this.activeItem;
this.activeItem = ItemStack.EMPTY;
this.markDirty();
return stored;
}
public void removeStack(World world, BlockState state) {
@ -73,6 +77,7 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
@Override
public void setStack(int slot, ItemStack stack) {
this.activeItem = stack;
this.markDirty();
}
public void setStack(World world, BlockState state, ItemStack stack) {

View file

@ -66,11 +66,13 @@ public class InfusionRitual implements Inventory {
this.activeRecipe = null;
this.progress = 0;
this.time = 0;
this.markDirty();
return false;
} else if (recipe != activeRecipe) {
this.activeRecipe = recipe;
this.time = this.activeRecipe.getInfusionTime();
this.progress = 0;
this.markDirty();
}
return true;
}
@ -78,6 +80,7 @@ public class InfusionRitual implements Inventory {
if (activeRecipe != null) {
this.time = this.activeRecipe.getInfusionTime();
this.progress = 0;
this.markDirty();
return true;
}
return false;
@ -97,6 +100,7 @@ public class InfusionRitual implements Inventory {
this.activeRecipe = null;
this.progress = 0;
this.time = 0;
this.markDirty();
} else {
ServerWorld world = (ServerWorld) this.world;
BlockPos target = this.worldPos.up();
@ -193,7 +197,14 @@ public class InfusionRitual implements Inventory {
}
@Override
public void markDirty() {}
public void markDirty() {
if (isValid()) {
this.input.markDirty();
for (PedestalBlockEntity catalyst : catalysts) {
catalyst.markDirty();
}
}
}
@Override
public boolean canPlayerUse(PlayerEntity player) {