Chipping away, Part II

This commit is contained in:
simibubi 2021-11-02 16:25:48 +01:00
parent 0cb7a0260e
commit 00b6a32e77
270 changed files with 1697 additions and 1867 deletions

View file

@ -205,7 +205,6 @@ import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ConfiguredModel;
import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.common.ToolType;
public class AllBlocks { public class AllBlocks {
@ -1018,7 +1017,8 @@ public class AllBlocks {
.simpleItem() .simpleItem()
.register(); .register();
public static final BlockEntry<SailBlock> SAIL = REGISTRATE.block("white_sail", p -> SailBlock.withCanvas(p, DyeColor.WHITE)) public static final BlockEntry<SailBlock> SAIL =
REGISTRATE.block("white_sail", p -> SailBlock.withCanvas(p, DyeColor.WHITE))
.initialProperties(SharedProperties::wooden) .initialProperties(SharedProperties::wooden)
.properties(BlockBehaviour.Properties::noOcclusion) .properties(BlockBehaviour.Properties::noOcclusion)
.blockstate(BlockStateGen.directionalBlockProvider(false)) .blockstate(BlockStateGen.directionalBlockProvider(false))
@ -1401,8 +1401,7 @@ public class AllBlocks {
public static final BlockEntry<Block> ZINC_ORE = REGISTRATE.block("zinc_ore", Block::new) public static final BlockEntry<Block> ZINC_ORE = REGISTRATE.block("zinc_ore", Block::new)
.initialProperties(() -> Blocks.GOLD_BLOCK) .initialProperties(() -> Blocks.GOLD_BLOCK)
.properties(p -> p.harvestLevel(2) .properties(p -> p.requiresCorrectToolForDrops()
.harvestTool(ToolType.PICKAXE)
.sound(SoundType.STONE)) .sound(SoundType.STONE))
.tag(Tags.Blocks.ORES) .tag(Tags.Blocks.ORES)
.transform(tagBlockAndItem("ores/zinc")) .transform(tagBlockAndItem("ores/zinc"))

View file

@ -13,21 +13,23 @@ import net.minecraftforge.eventbus.api.GenericEvent;
/** /**
* Event that is fired just before a SmartTileEntity is being deserealized <br> * Event that is fired just before a SmartTileEntity is being deserealized <br>
* Also if a new one is placed<br> * Also if a new one is placed<br>
* Use it to attach a new {@link TileEntityBehaviour} or replace existing ones (with caution) <br> * Use it to attach a new {@link TileEntityBehaviour} or replace existing ones
* (with caution) <br>
* <br> * <br>
* Actual setup of the behaviours internal workings and data should be done in TileEntityBehaviour#read() and TileEntityBehaviour#initialize() respectively.<br> * Actual setup of the behaviours internal workings and data should be done in
* TileEntityBehaviour#read() and TileEntityBehaviour#initialize()
* respectively.<br>
* <br> * <br>
* Because of the earlyness of this event, the added behaviours will have access to the initial nbt read (unless the TE was placed, not loaded), thereby allowing tiles to store and retrieve data for injected behaviours * Because of the earlyness of this event, the added behaviours will have access
* to the initial nbt read (unless the TE was placed, not loaded), thereby
* allowing tiles to store and retrieve data for injected behaviours
*/ */
public class TileEntityBehaviourEvent<T extends SmartTileEntity> extends GenericEvent<T> { public class TileEntityBehaviourEvent<T extends SmartTileEntity> extends GenericEvent<T> {
private BlockState state;
private T smartTileEntity; private T smartTileEntity;
private Map<BehaviourType<?>, TileEntityBehaviour> behaviours; private Map<BehaviourType<?>, TileEntityBehaviour> behaviours;
public TileEntityBehaviourEvent(BlockState state, T tileEntity, public TileEntityBehaviourEvent(T tileEntity, Map<BehaviourType<?>, TileEntityBehaviour> behaviours) {
Map<BehaviourType<?>, TileEntityBehaviour> behaviours) {
this.state = state;
smartTileEntity = tileEntity; smartTileEntity = tileEntity;
this.behaviours = behaviours; this.behaviours = behaviours;
} }
@ -50,7 +52,7 @@ public class TileEntityBehaviourEvent<T extends SmartTileEntity> extends Generic
} }
public BlockState getBlockState() { public BlockState getBlockState() {
return state; return smartTileEntity.getBlockState();
} }
} }

View file

@ -4,27 +4,32 @@ import java.util.function.BiConsumer;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.ferreusveritas.dynamictrees.api.TreeHelper;
import com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock;
import com.ferreusveritas.dynamictrees.blocks.branches.TrunkShellBlock;
import com.ferreusveritas.dynamictrees.util.BranchDestructionData;
import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue; import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.Block;
// Commented until dynamic trees are updated
public class DynamicTree extends AbstractBlockBreakQueue { public class DynamicTree extends AbstractBlockBreakQueue {
private BlockPos startCutPos;
// private BlockPos startCutPos;
public DynamicTree(BlockPos startCutPos) { public DynamicTree(BlockPos startCutPos) {
this.startCutPos = startCutPos; // this.startCutPos = startCutPos;
} }
public static boolean isDynamicBranch(Block block) {
return false; // TreeHelper.isBranch(block) || block instanceof TrunkShellBlock;
}
@Override @Override
public void destroyBlocks(Level world, ItemStack toDamage, @Nullable Player playerEntity, BiConsumer<BlockPos, ItemStack> drop) { public void destroyBlocks(Level world, ItemStack toDamage, @Nullable Player playerEntity, BiConsumer<BlockPos, ItemStack> drop) {
/*
BranchBlock start = TreeHelper.getBranch(world.getBlockState(startCutPos)); BranchBlock start = TreeHelper.getBranch(world.getBlockState(startCutPos));
if (start == null) //if start is null, it was not a branch if (start == null) //if start is null, it was not a branch
start = setBranchToShellMuse(world, world.getBlockState(startCutPos)); //we check for a trunk shell instead start = setBranchToShellMuse(world, world.getBlockState(startCutPos)); //we check for a trunk shell instead
@ -41,9 +46,13 @@ public class DynamicTree extends AbstractBlockBreakQueue {
// Feed all the tree drops to drop bi-consumer // Feed all the tree drops to drop bi-consumer
data.leavesDrops.forEach(stackPos -> drop.accept(stackPos.pos.offset(startCutPos), stackPos.stack)); data.leavesDrops.forEach(stackPos -> drop.accept(stackPos.pos.offset(startCutPos), stackPos.stack));
start.getLogDrops(world, startCutPos, data.species, data.woodVolume).forEach(stack -> drop.accept(startCutPos, stack)); start.getLogDrops(world, startCutPos, data.species, data.woodVolume).forEach(stack -> drop.accept(startCutPos, stack));
*/
} }
private BranchBlock setBranchToShellMuse(World world, BlockState state){ /*
private BranchBlock setBranchToShellMuse(World world, BlockState state) {
Block block = state.getBlock(); Block block = state.getBlock();
if (block instanceof TrunkShellBlock){ if (block instanceof TrunkShellBlock){
TrunkShellBlock.ShellMuse muse = ((TrunkShellBlock)block).getMuse(world, startCutPos); TrunkShellBlock.ShellMuse muse = ((TrunkShellBlock)block).getMuse(world, startCutPos);
@ -52,10 +61,10 @@ public class DynamicTree extends AbstractBlockBreakQueue {
return TreeHelper.getBranch(muse.state); return TreeHelper.getBranch(muse.state);
} }
} }
return null; return null;
} }
*/
public static boolean isDynamicBranch(Block block) {
return TreeHelper.isBranch(block) || block instanceof TrunkShellBlock;
}
} }

View file

@ -12,6 +12,7 @@ import com.simibubi.create.foundation.gui.GhostItemSubmitPacket;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import mezz.jei.api.gui.handlers.IGhostIngredientHandler; import mezz.jei.api.gui.handlers.IGhostIngredientHandler;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.renderer.Rect2i; import net.minecraft.client.renderer.Rect2i;
import net.minecraft.world.inventory.Slot; import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;

View file

@ -13,13 +13,14 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
public abstract class GeneratingKineticTileEntity extends KineticTileEntity { public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
public boolean reActivateSource; public boolean reActivateSource;
public GeneratingKineticTileEntity(BlockEntityType<?> typeIn) { public GeneratingKineticTileEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn); super(typeIn, pos, state);
} }
protected void notifyStressCapacityChange(float capacity) { protected void notifyStressCapacityChange(float capacity) {

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
import static net.minecraft.util.text.TextFormatting.GOLD; import static net.minecraft.ChatFormatting.GOLD;
import static net.minecraft.ChatFormatting.GRAY;
import java.util.List; import java.util.List;
@ -41,7 +42,6 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.TickableBlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -49,7 +49,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
public abstract class KineticTileEntity extends SmartTileEntity public abstract class KineticTileEntity extends SmartTileEntity
implements TickableBlockEntity, IHaveGoggleInformation, IHaveHoveringInformation, IInstanceRendered { implements IHaveGoggleInformation, IHaveHoveringInformation, IInstanceRendered {
public @Nullable Long network; public @Nullable Long network;
public @Nullable BlockPos source; public @Nullable BlockPos source;
@ -70,8 +70,8 @@ public abstract class KineticTileEntity extends SmartTileEntity
protected float lastStressApplied; protected float lastStressApplied;
protected float lastCapacityProvided; protected float lastCapacityProvided;
public KineticTileEntity(BlockEntityType<?> typeIn) { public KineticTileEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn); super(typeIn, pos, state);
effects = new KineticEffectHandler(this); effects = new KineticEffectHandler(this);
updateSpeed = true; updateSpeed = true;
} }
@ -226,13 +226,13 @@ public abstract class KineticTileEntity extends SmartTileEntity
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
boolean overStressedBefore = overStressed; boolean overStressedBefore = overStressed;
clearKineticInformation(); clearKineticInformation();
// DO NOT READ kinetic information when placed after movement // DO NOT READ kinetic information when placed after movement
if (wasMoved) { if (wasMoved) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
return; return;
} }
@ -252,7 +252,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
overStressed = capacity < stress && StressImpact.isEnabled(); overStressed = capacity < stress && StressImpact.isEnabled();
} }
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (clientPacket && overStressedBefore != overStressed && speed != 0) if (clientPacket && overStressedBefore != overStressed && speed != 0)
effects.triggerOverStressedEffect(); effects.triggerOverStressedEffect();
@ -412,8 +412,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.speedRequirement") .append(Lang.translate("tooltip.speedRequirement")
.withStyle(GOLD))); .withStyle(GOLD)));
Component hint = Component hint = Lang.translate("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock()
Lang.translate("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock()
.getDescriptionId())); .getDescriptionId()));
List<Component> cutString = TooltipHelper.cutTextComponent(hint, GRAY, ChatFormatting.WHITE); List<Component> cutString = TooltipHelper.cutTextComponent(hint, GRAY, ChatFormatting.WHITE);
for (int i = 0; i < cutString.size(); i++) for (int i = 0; i < cutString.size(); i++)
@ -597,5 +596,4 @@ public abstract class KineticTileEntity extends SmartTileEntity
return true; return true;
} }
} }

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllShapes;
import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;

View file

@ -30,8 +30,8 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity {
protected int breakerId = -NEXT_BREAKER_ID.incrementAndGet(); protected int breakerId = -NEXT_BREAKER_ID.incrementAndGet();
protected BlockPos breakingPos; protected BlockPos breakingPos;
public BlockBreakingKineticTileEntity(BlockEntityType<?> typeIn) { public BlockBreakingKineticTileEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn); super(typeIn, pos, state);
} }
@Override @Override
@ -68,12 +68,12 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
destroyProgress = compound.getInt("Progress"); destroyProgress = compound.getInt("Progress");
ticksUntilNextProgress = compound.getInt("NextTick"); ticksUntilNextProgress = compound.getInt("NextTick");
if (compound.contains("Breaking")) if (compound.contains("Breaking"))
breakingPos = NbtUtils.readBlockPos(compound.getCompound("Breaking")); breakingPos = NbtUtils.readBlockPos(compound.getCompound("Breaking"));
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
@Override @Override
@ -140,7 +140,7 @@ public abstract class BlockBreakingKineticTileEntity extends KineticTileEntity {
public void onBlockBroken(BlockState stateToBreak) { public void onBlockBroken(BlockState stateToBreak) {
FluidState FluidState = level.getFluidState(breakingPos); FluidState FluidState = level.getFluidState(breakingPos);
level.levelEvent(2001, breakingPos, Block.getId(stateToBreak)); level.levelEvent(2001, breakingPos, Block.getId(stateToBreak));
BlockEntity tileentity = stateToBreak.hasTileEntity() ? level.getBlockEntity(breakingPos) : null; BlockEntity tileentity = stateToBreak.hasBlockEntity() ? level.getBlockEntity(breakingPos) : null;
Vec3 vec = VecHelper.offsetRandomly(VecHelper.getCenterOf(breakingPos), level.random, .125f); Vec3 vec = VecHelper.offsetRandomly(VecHelper.getCenterOf(breakingPos), level.random, .125f);
Block.getDrops(stateToBreak, (ServerLevel) level, breakingPos, tileentity).forEach((stack) -> { Block.getDrops(stateToBreak, (ServerLevel) level, breakingPos, tileentity).forEach((stack) -> {

View file

@ -7,6 +7,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;

View file

@ -1,23 +1,15 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.state.properties.BlockStateProperties.FACING; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.net.minimport com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
ecraft.world.level.block.state.properties.BlockStatePropertiesport com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.block.BlockState; import net.minecraft.core.Direction;
import net.minecraft.util.Direction; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
public class DrillInstance extends SingleRotatingInstance { public class DrillInstance extends SingleRotatingInstance {
@ -28,7 +20,7 @@ public class DrillInstance extends SingleRotatingInstance {
@Override @Override
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
BlockState referenceState = tile.getBlockState(); BlockState referenceState = tile.getBlockState();
Direction facing = referenceState.getValue(FACING); Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing); return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing);
} }
} }

View file

@ -2,11 +2,12 @@ package com.simibubi.create.content.contraptions.components.actors;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
public class DrillTileEntity extends BlockBreakingKineticTileEntity { public class DrillTileEntity extends BlockBreakingKineticTileEntity {
public DrillTileEntity(BlockEntityType<? extends DrillTileEntity> type) { public DrillTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
@Override @Override

View file

@ -1,13 +1,11 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import com.jozufozu.flywheel.backend.material.Material; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
@ -18,6 +16,7 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
public class HarvesterActorInstance extends ActorInstance { public class HarvesterActorInstance extends ActorInstance {
@ -42,7 +41,7 @@ public class HarvesterActorInstance extends ActorInstance {
BlockState state = context.state; BlockState state = context.state;
facing = state.getValue(HORIZONTAL_FACING); facing = state.getValue(BlockStateProperties.HORIZONTAL_FACING);
harvester = material.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance(); harvester = material.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance();
@ -75,7 +74,7 @@ public class HarvesterActorInstance extends ActorInstance {
@Override @Override
public void beginFrame() { public void beginFrame() {
MatrixStack ms = new MatrixStack(); PoseStack ms = new PoseStack();
MatrixTransformStack msr = MatrixTransformStack.of(ms); MatrixTransformStack msr = MatrixTransformStack.of(ms);
msr.translate(context.localPos) msr.translate(context.localPos)

View file

@ -1,8 +1,10 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.block.HorizontalBlock.FACING; import javax.annotation.Nullable;
import javanet.minecrafimport com.jozufozu.flywheel.backend.Backend; import org.apache.commons.lang3.mutable.MutableBoolean;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
@ -12,7 +14,7 @@ import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
@ -32,46 +34,12 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import org.apache.commons.lang3.mutable.MutableBoolean;
t.world.level.block.HorizontalDirectionalBlockg.apache.commons.lang3.mutable.MutableBoolean;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.block.AbstractPlantBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CocoaBlock;
import net.minecraft.block.CropsBlock;
import net.minecraft.block.SugarCaneBlock;
import net.minecraft.block.SweetBerryBushBlock;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.Property;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
public class HarvesterMovementBehaviour extends MovementBehaviour { public class HarvesterMovementBehaviour extends MovementBehaviour {
@Override @Override
public boolean isActive(MovementContext context) { public boolean isActive(MovementContext context) {
return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(FACING) return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(HarvesterBlock.FACING)
.getOpposite()); .getOpposite());
} }
@ -97,7 +65,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
@Override @Override
public Vec3 getActiveAreaOffset(MovementContext context) { public Vec3 getActiveAreaOffset(MovementContext context) {
return Vec3.atLowerCornerOf(context.state.getValue(FACING) return Vec3.atLowerCornerOf(context.state.getValue(HarvesterBlock.FACING)
.getNormal()) .getNormal())
.scale(.45); .scale(.45);
} }
@ -121,8 +89,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
ItemStack item = ItemStack.EMPTY; ItemStack item = ItemStack.EMPTY;
float effectChance = 1; float effectChance = 1;
if (stateVisited.getBlock() if (stateVisited.is(BlockTags.LEAVES)) {
.is(BlockTags.LEAVES)) {
item = new ItemStack(Items.SHEARS); item = new ItemStack(Items.SHEARS);
effectChance = .45f; effectChance = .45f;
} }
@ -180,8 +147,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
return false; return false;
if (state.getBlock() instanceof SugarCaneBlock) if (state.getBlock() instanceof SugarCaneBlock)
return true; return true;
if (state.getBlock() if (state.is(BlockTags.LEAVES))
.is(BlockTags.LEAVES))
return true; return true;
if (state.getCollisionShape(world, pos) if (state.getCollisionShape(world, pos)

View file

@ -1,9 +1,9 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.block.HorizontalBlock.FACING; import com.simibubi.create.content.contraptions.components.actors.PloughBlock.PloughFakePlayer;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.net.minecrafimport com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
@ -25,36 +25,11 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult.Type; import net.minecraft.world.phys.HitResult.Type;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
t.world.level.block.HorizontalDirectionalBlocks.components.actors.PloughBlock.PloughFakePlayer;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.BubbleColumnBlock;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.Items;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceContext.BlockMode;
import net.minecraft.util.math.RayTraceContext.FluidMode;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour { public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override @Override
public boolean isActive(MovementContext context) { public boolean isActive(MovementContext context) {
return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(FACING) return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.getValue(PloughBlock.FACING)
.getOpposite()); .getOpposite());
} }
@ -74,8 +49,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
if (player == null) if (player == null)
return; return;
BlockHitResult ray = world BlockHitResult ray = world.clip(new ClipContext(vec, vec.add(0, -1, 0), Block.OUTLINE, Fluid.NONE, player));
.clip(new ClipContext(vec, vec.add(0, -1, 0), Block.OUTLINE, Fluid.NONE, player));
if (ray.getType() != Type.BLOCK) if (ray.getType() != Type.BLOCK)
return; return;
@ -85,8 +59,9 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override @Override
public Vec3 getActiveAreaOffset(MovementContext context) { public Vec3 getActiveAreaOffset(MovementContext context) {
return Vec3.atLowerCornerOf(context.state.getValue(FACING) return Vec3.atLowerCornerOf(context.state.getValue(PloughBlock.FACING)
.getNormal()).scale(.45); .getNormal())
.scale(.45);
} }
@Override @Override
@ -113,7 +88,8 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
if (brokenState.getBlock() == Blocks.SNOW && context.world instanceof ServerLevel) { if (brokenState.getBlock() == Blocks.SNOW && context.world instanceof ServerLevel) {
ServerLevel world = (ServerLevel) context.world; ServerLevel world = (ServerLevel) context.world;
brokenState.getDrops(new LootContext.Builder(world).withParameter(LootContextParams.BLOCK_STATE, brokenState) brokenState
.getDrops(new LootContext.Builder(world).withParameter(LootContextParams.BLOCK_STATE, brokenState)
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos)) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
.withParameter(LootContextParams.THIS_ENTITY, getPlayer(context)) .withParameter(LootContextParams.THIS_ENTITY, getPlayer(context))
.withParameter(LootContextParams.TOOL, new ItemStack(Items.IRON_SHOVEL))) .withParameter(LootContextParams.TOOL, new ItemStack(Items.IRON_SHOVEL)))
@ -125,7 +101,7 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
public void stopMoving(MovementContext context) { public void stopMoving(MovementContext context) {
super.stopMoving(context); super.stopMoving(context);
if (context.temporaryData instanceof PloughFakePlayer) if (context.temporaryData instanceof PloughFakePlayer)
((PloughFakePlayer) context.temporaryData).remove(); ((PloughFakePlayer) context.temporaryData).discard();
} }
private PloughFakePlayer getPlayer(MovementContext context) { private PloughFakePlayer getPlayer(MovementContext context) {

View file

@ -2,8 +2,10 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -14,8 +16,8 @@ public class PortableFluidInterfaceTileEntity extends PortableStorageInterfaceTi
protected LazyOptional<IFluidHandler> capability; protected LazyOptional<IFluidHandler> capability;
public PortableFluidInterfaceTileEntity(BlockEntityType<?> tileEntityTypeIn) { public PortableFluidInterfaceTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(tileEntityTypeIn); super(type, pos, state);
capability = createEmptyHandler(); capability = createEmptyHandler();
} }

View file

@ -3,9 +3,11 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.item.ItemHandlerWrapper; import com.simibubi.create.foundation.item.ItemHandlerWrapper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
@ -15,8 +17,8 @@ public class PortableItemInterfaceTileEntity extends PortableStorageInterfaceTil
protected LazyOptional<IItemHandlerModifiable> capability; protected LazyOptional<IItemHandlerModifiable> capability;
public PortableItemInterfaceTileEntity(BlockEntityType<?> tileEntityTypeIn) { public PortableItemInterfaceTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(tileEntityTypeIn); super(type, pos, state);
capability = LazyOptional.empty(); capability = LazyOptional.empty();
} }

View file

@ -7,6 +7,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;

View file

@ -8,6 +8,7 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -25,8 +26,8 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity
protected boolean powered; protected boolean powered;
protected Entity connectedEntity; protected Entity connectedEntity;
public PortableStorageInterfaceTileEntity(BlockEntityType<?> tileEntityTypeIn) { public PortableStorageInterfaceTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(tileEntityTypeIn); super(type, pos, state);
transferTimer = 0; transferTimer = 0;
connectionAnimation = LerpedFloat.linear() connectionAnimation = LerpedFloat.linear()
.startWithValue(0); .startWithValue(0);
@ -85,8 +86,8 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
transferTimer = compound.getInt("Timer"); transferTimer = compound.getInt("Timer");
distance = compound.getFloat("Distance"); distance = compound.getFloat("Distance");
powered = compound.getBoolean("Powered"); powered = compound.getBoolean("Powered");

View file

@ -9,6 +9,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;

View file

@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllEntityTypes;
import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;

View file

@ -16,8 +16,8 @@
//import net.minecraft.item.ItemStack; //import net.minecraft.item.ItemStack;
//import net.minecraft.nbt.NBTUtil; //import net.minecraft.nbt.NBTUtil;
//import net.minecraft.tileentity.TileEntity; //import net.minecraft.tileentity.TileEntity;
//import net.minecraft.util.Direction; //import net.minecraft.core.Direction;
//import net.minecraft.util.Direction.Axis; //import net.minecraft.core.Direction.Axis;
//import net.minecraft.util.math.BlockPos; //import net.minecraft.util.math.BlockPos;
//import net.minecraft.util.math.vector.Vector3d; //import net.minecraft.util.math.vector.Vector3d;
//import net.minecraft.world.World; //import net.minecraft.world.World;

View file

@ -4,6 +4,7 @@ import javax.annotation.Nullable;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockSource; import net.minecraft.core.BlockSource;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;

View file

@ -6,6 +6,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior; import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;

View file

@ -12,6 +12,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
@ -37,14 +38,14 @@ public class CuckooClockTileEntity extends KineticTileEntity {
PIG, CREEPER, SURPRISE, NONE; PIG, CREEPER, SURPRISE, NONE;
} }
public CuckooClockTileEntity(BlockEntityType<? extends CuckooClockTileEntity> type) { public CuckooClockTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
animationType = Animation.NONE; animationType = Animation.NONE;
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (clientPacket && compound.contains("Animation")) { if (clientPacket && compound.contains("Animation")) {
animationType = NBTHelper.readEnum(compound, "Animation", Animation.class); animationType = NBTHelper.readEnum(compound, "Animation", Animation.class);
animationProgress.lastValue = 0; animationProgress.lastValue = 0;

View file

@ -214,7 +214,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
crafter.setChanged(); crafter.setChanged();
crafter.sendData(); crafter.sendData();
if (!player.isCreative()) if (!player.isCreative())
player.inventory.placeItemBackInInventory(worldIn, AllItems.CRAFTER_SLOT_COVER.asStack()); player.getInventory().placeItemBackInInventory(worldIn, AllItems.CRAFTER_SLOT_COVER.asStack());
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
return InteractionResult.PASS; return InteractionResult.PASS;
@ -223,7 +223,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
return InteractionResult.PASS; return InteractionResult.PASS;
if (worldIn.isClientSide) if (worldIn.isClientSide)
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
player.inventory.placeItemBackInInventory(worldIn, inSlot); player.getInventory().placeItemBackInInventory(worldIn, inSlot);
crafter.getInventory().setStackInSlot(0, ItemStack.EMPTY); crafter.getInventory().setStackInSlot(0, ItemStack.EMPTY);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }

View file

@ -6,7 +6,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.jozufozu.flywheel.util.transform.TransformStack; import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.RotatingData;
@ -27,9 +27,9 @@ public class MechanicalCrafterInstance extends SingleRotatingInstance {
return getRotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState, facing, rotateToFace(facing)); return getRotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState, facing, rotateToFace(facing));
} }
private Supplier<MatrixStack> rotateToFace(Direction facing) { private Supplier<PoseStack> rotateToFace(Direction facing) {
return () -> { return () -> {
MatrixStack stack = new MatrixStack(); PoseStack stack = new PoseStack();
TransformStack stacker = MatrixTransformStack.of(stack) TransformStack stacker = MatrixTransformStack.of(stack)
.centre(); .centre();

View file

@ -96,8 +96,8 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
private ItemStack scriptedResult = ItemStack.EMPTY; private ItemStack scriptedResult = ItemStack.EMPTY;
public MechanicalCrafterTileEntity(BlockEntityType<? extends MechanicalCrafterTileEntity> type) { public MechanicalCrafterTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
setLazyTickRate(20); setLazyTickRate(20);
phase = Phase.IDLE; phase = Phase.IDLE;
groupedItemsBeforeCraft = new GroupedItems(); groupedItemsBeforeCraft = new GroupedItems();
@ -157,7 +157,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
Phase phaseBefore = phase; Phase phaseBefore = phase;
GroupedItems before = this.groupedItems; GroupedItems before = this.groupedItems;
@ -172,7 +172,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
this.phase = phase; this.phase = phase;
countDown = compound.getInt("CountDown"); countDown = compound.getInt("CountDown");
covered = compound.getBoolean("Cover"); covered = compound.getBoolean("Cover");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (!clientPacket) if (!clientPacket)
return; return;
if (compound.contains("Redraw")) if (compound.contains("Redraw"))

View file

@ -6,7 +6,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -50,7 +50,7 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami
Direction.Axis axis = facing.getAxis(); Direction.Axis axis = facing.getAxis();
float angle = (tile.independentAngle + AnimationTickHolder.getPartialTicks() * tile.chasingVelocity) / 360; float angle = (tile.independentAngle + AnimationTickHolder.getPartialTicks() * tile.chasingVelocity) / 360;
MatrixStack ms = new MatrixStack(); PoseStack ms = new PoseStack();
MatrixTransformStack.of(ms) MatrixTransformStack.of(ms)
.translate(getInstancePosition()) .translate(getInstancePosition())
.centre() .centre()

View file

@ -5,6 +5,7 @@ import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -19,8 +20,8 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity {
public float independentAngle; public float independentAngle;
public float chasingVelocity; public float chasingVelocity;
public HandCrankTileEntity(BlockEntityType<? extends HandCrankTileEntity> type) { public HandCrankTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
public void turn(boolean back) { public void turn(boolean back) {
@ -52,9 +53,9 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
inUse = compound.getInt("InUse"); inUse = compound.getInt("InUse");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
@Override @Override

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.contraptions.components.crusher; package com.simibubi.create.content.contraptions.components.crusher;
import static com.simibubi.create.content.contraptions.components.crusher.CrushingWheelControllerBlock.VALID; import static com.simibubi.create.content.contraptions.components.crusher.CrushingWheelControllerBlock.VALID;
import static net.minecraft.block.DirectionalBlock.FACING;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
@ -47,8 +46,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
} }
@Override @Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
CollisionContext context) {
return AllShapes.CRUSHING_WHEEL_COLLISION_SHAPE; return AllShapes.CRUSHING_WHEEL_COLLISION_SHAPE;
} }
@ -62,7 +60,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
worldIn.setBlockAndUpdate(pos.relative(d), Blocks.AIR.defaultBlockState()); worldIn.setBlockAndUpdate(pos.relative(d), Blocks.AIR.defaultBlockState());
} }
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
worldIn.removeBlockEntity(pos); worldIn.removeBlockEntity(pos);
} }
} }
@ -79,10 +77,8 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
boolean controllerExists = AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(world.getBlockState(controllerPos)); boolean controllerExists = AllBlocks.CRUSHING_WHEEL_CONTROLLER.has(world.getBlockState(controllerPos));
boolean controllerIsValid = controllerExists && world.getBlockState(controllerPos) boolean controllerIsValid = controllerExists && world.getBlockState(controllerPos)
.getValue(VALID); .getValue(VALID);
Direction controllerOldDirection = controllerExists Direction controllerOldDirection = controllerExists ? world.getBlockState(controllerPos)
? world.getBlockState(controllerPos) .getValue(CrushingWheelControllerBlock.FACING) : null;
.getValue(FACING)
: null;
boolean controllerShouldExist = false; boolean controllerShouldExist = false;
boolean controllerShouldBeValid = false; boolean controllerShouldBeValid = false;
@ -99,17 +95,14 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
&& te.getSpeed() != 0) { && te.getSpeed() != 0) {
Axis wheelAxis = state.getValue(AXIS); Axis wheelAxis = state.getValue(AXIS);
Axis sideAxis = side.getAxis(); Axis sideAxis = side.getAxis();
int controllerADO = Math.round(Math.signum(te.getSpeed())) * side.getAxisDirection().getStep(); int controllerADO = Math.round(Math.signum(te.getSpeed())) * side.getAxisDirection()
Vec3 controllerDirVec = new Vec3(wheelAxis == Axis.X ? 1 : 0 .getStep();
, wheelAxis == Axis.Y ? 1 : 0 Vec3 controllerDirVec = new Vec3(wheelAxis == Axis.X ? 1 : 0, wheelAxis == Axis.Y ? 1 : 0,
, wheelAxis == Axis.Z ? 1 : 0) wheelAxis == Axis.Z ? 1 : 0).cross(
.cross(new Vec3(sideAxis == Axis.X ? 1 : 0 new Vec3(sideAxis == Axis.X ? 1 : 0, sideAxis == Axis.Y ? 1 : 0, sideAxis == Axis.Z ? 1 : 0));
, sideAxis == Axis.Y ? 1 : 0
, sideAxis == Axis.Z ? 1 : 0));
controllerNewDirection = Direction.getNearest(controllerDirVec.x * controllerADO controllerNewDirection = Direction.getNearest(controllerDirVec.x * controllerADO,
, controllerDirVec.y * controllerADO controllerDirVec.y * controllerADO, controllerDirVec.z * controllerADO);
, controllerDirVec.z * controllerADO);
controllerShouldBeValid = true; controllerShouldBeValid = true;
} }
@ -130,11 +123,11 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
return; return;
world.setBlockAndUpdate(controllerPos, AllBlocks.CRUSHING_WHEEL_CONTROLLER.getDefaultState() world.setBlockAndUpdate(controllerPos, AllBlocks.CRUSHING_WHEEL_CONTROLLER.getDefaultState()
.setValue(VALID, controllerShouldBeValid) .setValue(VALID, controllerShouldBeValid)
.setValue(FACING, controllerNewDirection)); .setValue(CrushingWheelControllerBlock.FACING, controllerNewDirection));
} else if (controllerIsValid != controllerShouldBeValid || controllerOldDirection != controllerNewDirection) { } else if (controllerIsValid != controllerShouldBeValid || controllerOldDirection != controllerNewDirection) {
world.setBlockAndUpdate(controllerPos, world.getBlockState(controllerPos) world.setBlockAndUpdate(controllerPos, world.getBlockState(controllerPos)
.setValue(VALID, controllerShouldBeValid) .setValue(VALID, controllerShouldBeValid)
.setValue(FACING, controllerNewDirection)); .setValue(CrushingWheelControllerBlock.FACING, controllerNewDirection));
} }
((CrushingWheelControllerBlock) AllBlocks.CRUSHING_WHEEL_CONTROLLER.get()) ((CrushingWheelControllerBlock) AllBlocks.CRUSHING_WHEEL_CONTROLLER.get())

View file

@ -1,8 +1,12 @@
package com.simibubi.create.content.contraptions.components.crusher; package com.simibubi.create.content.contraptions.components.crusher;
import static net.minecraft.block.DirectionalBlock.FACING; import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import javanimport com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.content.contraptions.processing.ProcessingInventory; import com.simibubi.create.content.contraptions.processing.ProcessingInventory;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
@ -14,11 +18,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -47,52 +47,6 @@ import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.RecipeWrapper; import net.minecraftforge.items.wrapper.RecipeWrapper;
et.minecraft.world.level.block.DirectionalBlockist;
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.content.contraptions.processing.ProcessingInventory;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.sound.SoundScapes;
import com.simibubi.create.foundation.sound.SoundScapes.AmbienceGroup;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.particles.BlockParticleData;
import net.minecraft.particles.IParticleData;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.RecipeWrapper;
public class CrushingWheelControllerTileEntity extends SmartTileEntity { public class CrushingWheelControllerTileEntity extends SmartTileEntity {
public Entity processingEntity; public Entity processingEntity;
@ -104,8 +58,8 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity {
private RecipeWrapper wrapper; private RecipeWrapper wrapper;
public float crushingspeed; public float crushingspeed;
public CrushingWheelControllerTileEntity(BlockEntityType<? extends CrushingWheelControllerTileEntity> type) { public CrushingWheelControllerTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
inventory = new ProcessingInventory(this::itemInserted) { inventory = new ProcessingInventory(this::itemInserted) {
@Override @Override
@ -154,7 +108,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity {
float speed = crushingspeed * 4; float speed = crushingspeed * 4;
Vec3 centerPos = VecHelper.getCenterOf(worldPosition); Vec3 centerPos = VecHelper.getCenterOf(worldPosition);
Direction facing = getBlockState().getValue(FACING); Direction facing = getBlockState().getValue(CrushingWheelControllerBlock.FACING);
int offset = facing.getAxisDirection() int offset = facing.getAxisDirection()
.getStep(); .getStep();
Vec3 outSpeed = new Vec3((facing.getAxis() == Axis.X ? 0.25D : 0.0D) * offset, Vec3 outSpeed = new Vec3((facing.getAxis() == Axis.X ? 0.25D : 0.0D) * offset,
@ -315,7 +269,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity {
inventory.setStackInSlot(0, itemEntity.getItem() inventory.setStackInSlot(0, itemEntity.getItem()
.copy()); .copy());
itemInserted(inventory.getStackInSlot(0)); itemInserted(inventory.getStackInSlot(0));
itemEntity.remove(); itemEntity.discard();
level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 2 | 16); level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 2 | 16);
} }
@ -377,8 +331,8 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (compound.contains("Entity") && !isOccupied()) { if (compound.contains("Entity") && !isOccupied()) {
entityUUID = NbtUtils.loadUUID(NBTHelper.getINBT(compound, "Entity")); entityUUID = NbtUtils.loadUUID(NBTHelper.getINBT(compound, "Entity"));
this.searchForEntity = true; this.searchForEntity = true;

View file

@ -3,10 +3,12 @@ package com.simibubi.create.content.contraptions.components.crusher;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent;
@ -20,8 +22,8 @@ public class CrushingWheelTileEntity extends KineticTileEntity {
public static DamageSource damageSource = new DamageSource("create.crush").bypassArmor() public static DamageSource damageSource = new DamageSource("create.crush").bypassArmor()
.setScalesWithDifficulty(); .setScalesWithDifficulty();
public CrushingWheelTileEntity(BlockEntityType<? extends CrushingWheelTileEntity> type) { public CrushingWheelTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
setLazyTickRate(20); setLazyTickRate(20);
} }

View file

@ -9,8 +9,7 @@ import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3d;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.KineticTileInstance;
@ -26,8 +25,9 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.Mth;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
public class DeployerActorInstance extends ActorInstance { public class DeployerActorInstance extends ActorInstance {
@ -83,18 +83,18 @@ public class DeployerActorInstance extends ActorInstance {
public void beginFrame() { public void beginFrame() {
double factor; double factor;
if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) { if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) {
factor = MathHelper.sin(AnimationTickHolder.getRenderTime() * .5f) * .25f + .25f; factor = Mth.sin(AnimationTickHolder.getRenderTime() * .5f) * .25f + .25f;
} else { } else {
Vector3d center = VecHelper.getCenterOf(new BlockPos(context.position)); Vec3 center = VecHelper.getCenterOf(new BlockPos(context.position));
double distance = context.position.distanceTo(center); double distance = context.position.distanceTo(center);
double nextDistance = context.position.add(context.motion) double nextDistance = context.position.add(context.motion)
.distanceTo(center); .distanceTo(center);
factor = .5f - MathHelper.clamp(MathHelper.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1); factor = .5f - Mth.clamp(Mth.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1);
} }
Vector3d offset = Vector3d.atLowerCornerOf(facing.getNormal()).scale(factor); Vec3 offset = Vec3.atLowerCornerOf(facing.getNormal()).scale(factor);
MatrixStack ms = new MatrixStack(); PoseStack ms = new PoseStack();
MatrixTransformStack msr = MatrixTransformStack.of(ms); MatrixTransformStack msr = MatrixTransformStack.of(ms);
msr.translate(context.localPos) msr.translate(context.localPos)

View file

@ -11,6 +11,7 @@ import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
@ -68,7 +69,7 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<De
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
withTileEntityDo(worldIn, pos, te -> { withTileEntityDo(worldIn, pos, te -> {
if (te.player != null && !isMoving) { if (te.player != null && !isMoving) {
te.player.inventory.dropAll(); te.player.getInventory().dropAll();
te.overflowItems.forEach(itemstack -> te.player.drop(itemstack, true, false)); te.overflowItems.forEach(itemstack -> te.player.drop(itemstack, true, false));
te.player.remove(); te.player.remove();
te.player = null; te.player = null;

View file

@ -108,7 +108,7 @@ public class DeployerFakePlayer extends FakePlayer {
if (trueSource != null && trueSource instanceof DeployerFakePlayer) { if (trueSource != null && trueSource instanceof DeployerFakePlayer) {
DeployerFakePlayer fakePlayer = (DeployerFakePlayer) trueSource; DeployerFakePlayer fakePlayer = (DeployerFakePlayer) trueSource;
event.getDrops() event.getDrops()
.forEach(stack -> fakePlayer.inventory.placeItemBackInInventory(trueSource.level, stack.getItem())); .forEach(stack -> fakeplayer.getInventory().placeItemBackInInventory(trueSource.level, stack.getItem()));
event.setCanceled(true); event.setCanceled(true);
} }
} }

View file

@ -123,8 +123,7 @@ public class DeployerHandler {
return true; return true;
} }
static void activate(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, Vec3 extensionVector, static void activate(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, Vec3 extensionVector, Mode mode) {
Mode mode) {
Multimap<Attribute, AttributeModifier> attributeModifiers = player.getMainHandItem() Multimap<Attribute, AttributeModifier> attributeModifiers = player.getMainHandItem()
.getAttributeModifiers(EquipmentSlot.MAINHAND); .getAttributeModifiers(EquipmentSlot.MAINHAND);
player.getAttributes() player.getAttributes()
@ -134,8 +133,8 @@ public class DeployerHandler {
.addTransientAttributeModifiers(attributeModifiers); .addTransientAttributeModifiers(attributeModifiers);
} }
private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos clickedPos, Vec3 extensionVector,
Vec3 extensionVector, Mode mode) { Mode mode) {
Vec3 rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f)); Vec3 rayOrigin = vec.add(extensionVector.scale(3 / 2f + 1 / 64f));
Vec3 rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f)); Vec3 rayTarget = vec.add(extensionVector.scale(5 / 2f - 1 / 64f));
@ -146,7 +145,8 @@ public class DeployerHandler {
// Check for entities // Check for entities
final ServerLevel world = player.getLevel(); final ServerLevel world = player.getLevel();
List<Entity> entities = world.getEntitiesOfClass(Entity.class, new AABB(clickedPos)).stream() List<Entity> entities = world.getEntitiesOfClass(Entity.class, new AABB(clickedPos))
.stream()
.filter(e -> !(e instanceof AbstractContraptionEntity)) .filter(e -> !(e instanceof AbstractContraptionEntity))
.collect(Collectors.toList()); .collect(Collectors.toList());
InteractionHand hand = InteractionHand.MAIN_HAND; InteractionHand hand = InteractionHand.MAIN_HAND;
@ -165,15 +165,15 @@ public class DeployerHandler {
} }
if (cancelResult == null) { if (cancelResult == null) {
if (entity.interact(player, hand) if (entity.interact(player, hand)
.consumesAction()){ .consumesAction()) {
if (entity instanceof AbstractVillager) { if (entity instanceof AbstractVillager) {
AbstractVillager villager = ((AbstractVillager) entity); AbstractVillager villager = ((AbstractVillager) entity);
if (villager.getTradingPlayer() instanceof DeployerFakePlayer) if (villager.getTradingPlayer() instanceof DeployerFakePlayer)
villager.setTradingPlayer(null); villager.setTradingPlayer(null);
} }
success = true; success = true;
} } else if (entity instanceof LivingEntity
else if (entity instanceof LivingEntity && stack.interactLivingEntity(player, (LivingEntity) entity, hand) && stack.interactLivingEntity(player, (LivingEntity) entity, hand)
.consumesAction()) .consumesAction())
success = true; success = true;
} }
@ -196,14 +196,15 @@ public class DeployerHandler {
} }
entity.captureDrops(null); entity.captureDrops(null);
capturedDrops.forEach(e -> player.inventory.placeItemBackInInventory(world, e.getItem())); capturedDrops.forEach(e -> player.getInventory()
.placeItemBackInInventory(e.getItem()));
if (success) if (success)
return; return;
} }
// Shoot ray // Shoot ray
ClipContext rayTraceContext = ClipContext rayTraceContext =
new ClipContext(rayOrigin, rayTarget, Block.OUTLINE, Fluid.NONE, player); new ClipContext(rayOrigin, rayTarget, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player);
BlockHitResult result = world.clip(rayTraceContext); BlockHitResult result = world.clip(rayTraceContext);
if (result.getBlockPos() != clickedPos) if (result.getBlockPos() != clickedPos)
result = new BlockHitResult(result.getLocation(), result.getDirection(), clickedPos, result.isInside()); result = new BlockHitResult(result.getLocation(), result.getDirection(), clickedPos, result.isInside());
@ -225,7 +226,8 @@ public class DeployerHandler {
LeftClickBlock event = ForgeHooks.onLeftClickBlock(player, clickedPos, face); LeftClickBlock event = ForgeHooks.onLeftClickBlock(player, clickedPos, face);
if (event.isCanceled()) if (event.isCanceled())
return; return;
if (BlockHelper.extinguishFire(world, player, clickedPos, face)) // FIXME: is there an equivalent in world, as there was in 1.15? if (BlockHelper.extinguishFire(world, player, clickedPos, face)) // FIXME: is there an equivalent in world,
// as there was in 1.15?
return; return;
if (event.getUseBlock() != DENY) if (event.getUseBlock() != DENY)
clickedState.attack(world, clickedPos, player); clickedState.attack(world, clickedPos, player);
@ -242,7 +244,7 @@ public class DeployerHandler {
.getHitSound(), SoundSource.NEUTRAL, .25f, 1); .getHitSound(), SoundSource.NEUTRAL, .25f, 1);
if (progress >= 1) { if (progress >= 1) {
tryHarvestBlock(player.gameMode, clickedPos); tryHarvestBlock(player, player.gameMode, clickedPos);
world.destroyBlockProgress(player.getId(), clickedPos, -1); world.destroyBlockProgress(player.getId(), clickedPos, -1);
player.blockBreakingProgress = null; player.blockBreakingProgress = null;
return; return;
@ -289,8 +291,7 @@ public class DeployerHandler {
return; return;
if (useItem == DENY) if (useItem == DENY)
return; return;
if (item instanceof BlockItem if (item instanceof BlockItem && !(item instanceof CartAssemblerBlockItem)
&& !(item instanceof CartAssemblerBlockItem)
&& !clickedState.canBeReplaced(new BlockPlaceContext(itemusecontext))) && !clickedState.canBeReplaced(new BlockPlaceContext(itemusecontext)))
return; return;
@ -338,11 +339,10 @@ public class DeployerHandler {
player.stopUsingItem(); player.stopUsingItem();
} }
public static boolean tryHarvestBlock(ServerPlayerGameMode interactionManager, BlockPos pos) { public static boolean tryHarvestBlock(ServerPlayer player, ServerPlayerGameMode interactionManager, BlockPos pos) {
// <> PlayerInteractionManager#tryHarvestBlock // <> PlayerInteractionManager#tryHarvestBlock
ServerLevel world = interactionManager.level; ServerLevel world = player.getLevel();
ServerPlayer player = interactionManager.player;
BlockState blockstate = world.getBlockState(pos); BlockState blockstate = world.getBlockState(pos);
GameType gameType = interactionManager.getGameModeForPlayer(); GameType gameType = interactionManager.getGameModeForPlayer();
@ -364,14 +364,12 @@ public class DeployerHandler {
if (prevHeldItem.isEmpty() && !heldItem.isEmpty()) if (prevHeldItem.isEmpty() && !heldItem.isEmpty())
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, heldItem, InteractionHand.MAIN_HAND); net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, heldItem, InteractionHand.MAIN_HAND);
BlockPos posUp = pos.above(); BlockPos posUp = pos.above();
BlockState stateUp = world.getBlockState(posUp); BlockState stateUp = world.getBlockState(posUp);
if (blockstate.getBlock() instanceof DoublePlantBlock if (blockstate.getBlock() instanceof DoublePlantBlock
&& blockstate.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.LOWER && blockstate.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.LOWER
&& stateUp.getBlock() == blockstate.getBlock() && stateUp.getBlock() == blockstate.getBlock()
&& stateUp.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.UPPER && stateUp.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.UPPER) {
) {
// hack to prevent DoublePlantBlock from dropping a duplicate item // hack to prevent DoublePlantBlock from dropping a duplicate item
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 35); world.setBlock(pos, Blocks.AIR.defaultBlockState(), 35);
world.setBlock(posUp, Blocks.AIR.defaultBlockState(), 35); world.setBlock(posUp, Blocks.AIR.defaultBlockState(), 35);
@ -386,7 +384,7 @@ public class DeployerHandler {
return true; return true;
Block.getDrops(blockstate, world, pos, tileentity, player, prevHeldItem) Block.getDrops(blockstate, world, pos, tileentity, player, prevHeldItem)
.forEach(item -> player.inventory.placeItemBackInInventory(world, item)); .forEach(item -> player.getInventory().placeItemBackInInventory(item));
blockstate.spawnAfterBreak(world, pos, prevHeldItem); blockstate.spawnAfterBreak(world, pos, prevHeldItem);
return true; return true;
} }
@ -413,7 +411,7 @@ public class DeployerHandler {
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR,
SoundSource.NEUTRAL, 1.0F, 1.0F); SoundSource.NEUTRAL, 1.0F, 1.0F);
// <> BeehiveBlock#dropHoneycomb // <> BeehiveBlock#dropHoneycomb
player.inventory.placeItemBackInInventory(world, new ItemStack(Items.HONEYCOMB, 3)); player.getInventory().placeItemBackInInventory(new ItemStack(Items.HONEYCOMB, 3));
prevHeldItem.hurtAndBreak(1, player, s -> s.broadcastBreakEvent(hand)); prevHeldItem.hurtAndBreak(1, player, s -> s.broadcastBreakEvent(hand));
success = true; success = true;
} }
@ -426,7 +424,7 @@ public class DeployerHandler {
if (prevHeldItem.isEmpty()) if (prevHeldItem.isEmpty())
player.setItemInHand(hand, honeyBottle); player.setItemInHand(hand, honeyBottle);
else else
player.inventory.placeItemBackInInventory(world, honeyBottle); player.getInventory().placeItemBackInInventory(honeyBottle);
success = true; success = true;
} }

View file

@ -17,8 +17,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.math.vector.Vector3i;
public class DeployerInstance extends ShaftInstance implements IDynamicInstance, ITickableInstance { public class DeployerInstance extends ShaftInstance implements IDynamicInstance, ITickableInstance {
@ -117,8 +117,8 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
private void updatePosition() { private void updatePosition() {
float handLength = currentHand == AllBlockPartials.DEPLOYER_HAND_POINTING ? 0 float handLength = currentHand == AllBlockPartials.DEPLOYER_HAND_POINTING ? 0
: currentHand == AllBlockPartials.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f; : currentHand == AllBlockPartials.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f;
float distance = Math.min(MathHelper.clamp(progress, 0, 1) * (tile.reach + handLength), 21 / 16f); float distance = Math.min(Mth.clamp(progress, 0, 1) * (tile.reach + handLength), 21 / 16f);
Vector3i facingVec = facing.getNormal(); Vec3i facingVec = facing.getNormal();
BlockPos blockPos = getInstancePosition(); BlockPos blockPos = getInstancePosition();
float x = blockPos.getX() + ((float) facingVec.getX()) * distance; float x = blockPos.getX() + ((float) facingVec.getX()) * distance;

View file

@ -83,8 +83,8 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
.getNormal()); .getNormal());
facingVec = context.rotation.apply(facingVec); facingVec = context.rotation.apply(facingVec);
Vec3 vec = context.position.subtract(facingVec.scale(2)); Vec3 vec = context.position.subtract(facingVec.scale(2));
player.yRot = AbstractContraptionEntity.yawFromVector(facingVec); player.setYRot(AbstractContraptionEntity.yawFromVector(facingVec));
player.xRot = AbstractContraptionEntity.pitchFromVector(facingVec) - 90; player.setXRot(AbstractContraptionEntity.pitchFromVector(facingVec) - 90);
DeployerHandler.activate(player, vec, pos, facingVec, mode); DeployerHandler.activate(player, vec, pos, facingVec, mode);
} }
@ -183,8 +183,8 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
if (player == null) if (player == null)
return; return;
context.tileData.put("Inventory", player.inventory.save(new ListTag())); context.tileData.put("Inventory", player.getInventory().save(new ListTag()));
player.remove(); player.discard();
} }
private void tryGrabbingItem(MovementContext context) { private void tryGrabbingItem(MovementContext context) {
@ -206,7 +206,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
DeployerFakePlayer player = getPlayer(context); DeployerFakePlayer player = getPlayer(context);
if (player == null) if (player == null)
return; return;
Inventory inv = player.inventory; Inventory inv = player.getInventory();
ItemStack filter = getFilter(context); ItemStack filter = getFilter(context);
for (List<ItemStack> list : Arrays.asList(inv.armor, inv.offhand, inv.items)) { for (List<ItemStack> list : Arrays.asList(inv.armor, inv.offhand, inv.items)) {
@ -237,7 +237,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
private DeployerFakePlayer getPlayer(MovementContext context) { private DeployerFakePlayer getPlayer(MovementContext context) {
if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerLevel) { if (!(context.temporaryData instanceof DeployerFakePlayer) && context.world instanceof ServerLevel) {
DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) context.world); DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) context.world);
deployerFakePlayer.inventory.load(context.tileData.getList("Inventory", NBT.TAG_COMPOUND)); deployerFakePlayer.getInventory().load(context.tileData.getList("Inventory", NBT.TAG_COMPOUND));
if (context.data.contains("HeldItem")) if (context.data.contains("HeldItem"))
deployerFakePlayer.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.of(context.data.getCompound("HeldItem"))); deployerFakePlayer.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.of(context.data.getCompound("HeldItem")));
context.tileData.remove("Inventory"); context.tileData.remove("Inventory");

View file

@ -55,7 +55,7 @@ public class DeployerMovingInteraction extends MovingInteractionBehaviour {
if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerLevel) { if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerLevel) {
DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) ctx.world); DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) ctx.world);
deployerFakePlayer.inventory.load(ctx.tileData.getList("Inventory", Constants.NBT.TAG_COMPOUND)); deployerFakeplayer.getInventory().load(ctx.tileData.getList("Inventory", Constants.NBT.TAG_COMPOUND));
ctx.temporaryData = fake = deployerFakePlayer; ctx.temporaryData = fake = deployerFakePlayer;
ctx.tileData.remove("Inventory"); ctx.tileData.remove("Inventory");
} else } else

View file

@ -35,6 +35,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.ClipContext;
@ -81,9 +82,9 @@ public class DeployerTileEntity extends KineticTileEntity {
PUNCH, USE PUNCH, USE
} }
public DeployerTileEntity(BlockEntityType<? extends DeployerTileEntity> type) { public DeployerTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
state = State.WAITING; this.state = State.WAITING;
mode = Mode.USE; mode = Mode.USE;
heldItem = ItemStack.EMPTY; heldItem = ItemStack.EMPTY;
redstoneLocked = false; redstoneLocked = false;
@ -108,7 +109,8 @@ public class DeployerTileEntity extends KineticTileEntity {
if (!level.isClientSide) { if (!level.isClientSide) {
player = new DeployerFakePlayer((ServerLevel) level); player = new DeployerFakePlayer((ServerLevel) level);
if (deferredInventoryList != null) { if (deferredInventoryList != null) {
player.inventory.load(deferredInventoryList); player.getInventory()
.load(deferredInventoryList);
deferredInventoryList = null; deferredInventoryList = null;
heldItem = player.getMainHandItem(); heldItem = player.getMainHandItem();
sendData(); sendData();
@ -156,15 +158,16 @@ public class DeployerTileEntity extends KineticTileEntity {
} }
boolean changed = false; boolean changed = false;
for (int i = 0; i < player.inventory.getContainerSize(); i++) { Inventory inventory = player.getInventory();
for (int i = 0; i < inventory.getContainerSize(); i++) {
if (overflowItems.size() > 10) if (overflowItems.size() > 10)
break; break;
ItemStack item = player.inventory.getItem(i); ItemStack item = inventory.getItem(i);
if (item.isEmpty()) if (item.isEmpty())
continue; continue;
if (item != stack || !filtering.test(item)) { if (item != stack || !filtering.test(item)) {
overflowItems.add(item); overflowItems.add(item);
player.inventory.setItem(i, ItemStack.EMPTY); inventory.setItem(i, ItemStack.EMPTY);
changed = true; changed = true;
} }
} }
@ -176,7 +179,8 @@ public class DeployerTileEntity extends KineticTileEntity {
} }
Direction facing = getBlockState().getValue(FACING); Direction facing = getBlockState().getValue(FACING);
if (mode == Mode.USE && !DeployerHandler.shouldActivate(stack, level, worldPosition.relative(facing, 2), facing)) { if (mode == Mode.USE
&& !DeployerHandler.shouldActivate(stack, level, worldPosition.relative(facing, 2), facing)) {
timer = getTimerSpeed() * 10; timer = getTimerSpeed() * 10;
return; return;
} }
@ -218,8 +222,7 @@ public class DeployerTileEntity extends KineticTileEntity {
.add(movementVector.scale(3 / 2f)); .add(movementVector.scale(3 / 2f));
Vec3 rayTarget = VecHelper.getCenterOf(worldPosition) Vec3 rayTarget = VecHelper.getCenterOf(worldPosition)
.add(movementVector.scale(5 / 2f)); .add(movementVector.scale(5 / 2f));
ClipContext rayTraceContext = ClipContext rayTraceContext = new ClipContext(rayOrigin, rayTarget, Block.OUTLINE, Fluid.NONE, player);
new ClipContext(rayOrigin, rayTarget, Block.OUTLINE, Fluid.NONE, player);
BlockHitResult result = level.clip(rayTraceContext); BlockHitResult result = level.clip(rayTraceContext);
reach = (float) (.5f + Math.min(result.getLocation() reach = (float) (.5f + Math.min(result.getLocation()
.subtract(rayOrigin) .subtract(rayOrigin)
@ -229,7 +232,8 @@ public class DeployerTileEntity extends KineticTileEntity {
} }
public boolean startBoop(Direction facing) { public boolean startBoop(Direction facing) {
if (!level.isEmptyBlock(worldPosition.relative(facing, 1)) || !level.isEmptyBlock(worldPosition.relative(facing, 2))) if (!level.isEmptyBlock(worldPosition.relative(facing, 1))
|| !level.isEmptyBlock(worldPosition.relative(facing, 2)))
return false; return false;
BlockPos otherDeployer = worldPosition.relative(facing, 4); BlockPos otherDeployer = worldPosition.relative(facing, 4);
if (!level.isLoaded(otherDeployer)) if (!level.isLoaded(otherDeployer))
@ -270,8 +274,7 @@ public class DeployerTileEntity extends KineticTileEntity {
deployerTile.sendData(); deployerTile.sendData();
// award nearby players // award nearby players
List<ServerPlayer> players = List<ServerPlayer> players = level.getEntitiesOfClass(ServerPlayer.class, new AABB(worldPosition).inflate(9));
level.getEntitiesOfClass(ServerPlayer.class, new AABB(worldPosition).inflate(9));
players.forEach(AllTriggers.DEPLOYER_BOOP::trigger); players.forEach(AllTriggers.DEPLOYER_BOOP::trigger);
} }
@ -280,8 +283,8 @@ public class DeployerTileEntity extends KineticTileEntity {
Direction direction = getBlockState().getValue(FACING); Direction direction = getBlockState().getValue(FACING);
Vec3 center = VecHelper.getCenterOf(worldPosition); Vec3 center = VecHelper.getCenterOf(worldPosition);
BlockPos clickedPos = worldPosition.relative(direction, 2); BlockPos clickedPos = worldPosition.relative(direction, 2);
player.yRot = direction.toYRot(); player.setXRot(direction == Direction.UP ? -90 : direction == Direction.DOWN ? 90 : 0);
player.xRot = direction == Direction.UP ? -90 : direction == Direction.DOWN ? 90 : 0; player.setYRot(direction.toYRot());
if (direction == Direction.DOWN if (direction == Direction.DOWN
&& TileEntityBehaviour.get(level, clickedPos, TransportedItemStackHandlerBehaviour.TYPE) != null) && TileEntityBehaviour.get(level, clickedPos, TransportedItemStackHandlerBehaviour.TYPE) != null)
@ -300,7 +303,7 @@ public class DeployerTileEntity extends KineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState blockState, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
state = NBTHelper.readEnum(compound, "State", State.class); state = NBTHelper.readEnum(compound, "State", State.class);
mode = NBTHelper.readEnum(compound, "Mode", Mode.class); mode = NBTHelper.readEnum(compound, "Mode", Mode.class);
timer = compound.getInt("Timer"); timer = compound.getInt("Timer");
@ -310,7 +313,7 @@ public class DeployerTileEntity extends KineticTileEntity {
overflowItems = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND)); overflowItems = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND));
if (compound.contains("HeldItem")) if (compound.contains("HeldItem"))
heldItem = ItemStack.of(compound.getCompound("HeldItem")); heldItem = ItemStack.of(compound.getCompound("HeldItem"));
super.fromTag(blockState, compound, clientPacket); super.fromTag(compound, clientPacket);
if (!clientPacket) if (!clientPacket)
return; return;
@ -331,9 +334,11 @@ public class DeployerTileEntity extends KineticTileEntity {
if (player != null) { if (player != null) {
ListTag invNBT = new ListTag(); ListTag invNBT = new ListTag();
player.inventory.save(invNBT); player.getInventory()
.save(invNBT);
compound.put("Inventory", invNBT); compound.put("Inventory", invNBT);
compound.put("HeldItem", player.getMainHandItem().serializeNBT()); compound.put("HeldItem", player.getMainHandItem()
.serializeNBT());
compound.put("Overflow", NBTHelper.writeItemList(overflowItems)); compound.put("Overflow", NBTHelper.writeItemList(overflowItems));
} else if (deferredInventoryList != null) { } else if (deferredInventoryList != null) {
compound.put("Inventory", deferredInventoryList); compound.put("Inventory", deferredInventoryList);

View file

@ -391,7 +391,7 @@ public class AirCurrent {
public static boolean isPlayerCreativeFlying(Entity entity) { public static boolean isPlayerCreativeFlying(Entity entity) {
if (entity instanceof Player) { if (entity instanceof Player) {
Player player = (Player) entity; Player player = (Player) entity;
return player.isCreative() && player.abilities.flying; return player.isCreative() && player.getAbilities().flying;
} }
return false; return false;
} }

View file

@ -9,6 +9,7 @@ import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlo
import com.simibubi.create.content.logistics.block.chute.ChuteTileEntity; import com.simibubi.create.content.logistics.block.chute.ChuteTileEntity;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -28,8 +29,8 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements
protected boolean updateAirFlow; protected boolean updateAirFlow;
protected boolean updateGenerator; protected boolean updateGenerator;
public EncasedFanTileEntity(BlockEntityType<? extends EncasedFanTileEntity> type) { public EncasedFanTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
isGenerator = false; isGenerator = false;
airCurrent = new AirCurrent(this); airCurrent = new AirCurrent(this);
updateAirFlow = true; updateAirFlow = true;
@ -37,8 +38,8 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (!wasMoved) if (!wasMoved)
isGenerator = compound.getBoolean("Generating"); isGenerator = compound.getBoolean("Generating");
if (clientPacket) if (clientPacket)
@ -81,7 +82,8 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements
shouldGenerate = false; shouldGenerate = false;
if (shouldGenerate) if (shouldGenerate)
shouldGenerate = level != null && level.hasNeighborSignal(worldPosition) && level.isLoaded(worldPosition.below()) && blockBelowIsHot(); shouldGenerate = level != null && level.hasNeighborSignal(worldPosition)
&& level.isLoaded(worldPosition.below()) && blockBelowIsHot();
if (shouldGenerate == isGenerator) if (shouldGenerate == isGenerator)
return; return;
@ -94,8 +96,7 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity implements
return false; return false;
BlockState checkState = level.getBlockState(worldPosition.below()); BlockState checkState = level.getBlockState(worldPosition.below());
if (!checkState.getBlock() if (!checkState.is(AllBlockTags.FAN_HEATERS.tag))
.is(AllBlockTags.FAN_HEATERS.tag))
return false; return false;
if (checkState.hasProperty(BlazeBurnerBlock.HEAT_LEVEL) && !checkState.getValue(BlazeBurnerBlock.HEAT_LEVEL) if (checkState.hasProperty(BlazeBurnerBlock.HEAT_LEVEL) && !checkState.getValue(BlazeBurnerBlock.HEAT_LEVEL)

View file

@ -5,6 +5,7 @@ import javax.annotation.Nullable;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.CKinetics; import com.simibubi.create.foundation.config.CKinetics;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;

View file

@ -33,8 +33,8 @@ public class NozzleTileEntity extends SmartTileEntity {
private boolean pushing; private boolean pushing;
private BlockPos fanPos; private BlockPos fanPos;
public NozzleTileEntity(BlockEntityType<? extends NozzleTileEntity> type) { public NozzleTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
setLazyTickRate(5); setLazyTickRate(5);
} }
@ -51,8 +51,8 @@ public class NozzleTileEntity extends SmartTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (!clientPacket) if (!clientPacket)
return; return;
range = compound.getFloat("Range"); range = compound.getFloat("Range");
@ -176,7 +176,7 @@ public class NozzleTileEntity extends SmartTileEntity {
level.explode(null, center.x, center.y, center.z, 2, BlockInteraction.NONE); level.explode(null, center.x, center.y, center.z, 2, BlockInteraction.NONE);
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) { for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
Entity entity = iterator.next(); Entity entity = iterator.next();
entity.remove(); entity.discard();
iterator.remove(); iterator.remove();
} }
} }

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.components.flywheel; package com.simibubi.create.content.contraptions.components.flywheel;
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -13,7 +13,7 @@ import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.RotatingData;
@ -21,7 +21,7 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.Mth;
import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -53,22 +53,29 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
shaft = setup(shaftModel().createInstance()); shaft = setup(shaftModel().createInstance());
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90); BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
wheel = getTransformMaterial().getModel(AllBlockPartials.FLYWHEEL, referenceState, referenceState.getValue(HORIZONTAL_FACING)).createInstance(); wheel = getTransformMaterial()
.getModel(AllBlockPartials.FLYWHEEL, referenceState, referenceState.getValue(HORIZONTAL_FACING))
.createInstance();
connection = FlywheelBlock.getConnection(blockState); connection = FlywheelBlock.getConnection(blockState);
if (connection != null) { if (connection != null) {
connectedLeft = blockState.getValue(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT; connectedLeft = blockState.getValue(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT;
boolean flipAngle = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE; boolean flipAngle = connection.getAxis() == Direction.Axis.X
^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE;
connectorAngleMult = flipAngle ? -1 : 1; connectorAngleMult = flipAngle ? -1 : 1;
Material<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance(); upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState)
lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance(); .createInstance();
upperSliding = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState).createInstance(); lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState)
lowerSliding = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState).createInstance(); .createInstance();
upperSliding = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState)
.createInstance();
lowerSliding = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState)
.createInstance();
connectors = Lists.newArrayList(upperRotating, lowerRotating, upperSliding, lowerSliding); connectors = Lists.newArrayList(upperRotating, lowerRotating, upperSliding, lowerSliding);
} else { } else {
@ -86,7 +93,8 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
float speed = tile.visualSpeed.get(partialTicks) * 3 / 10f; float speed = tile.visualSpeed.get(partialTicks) * 3 / 10f;
float angle = tile.angle + speed * partialTicks; float angle = tile.angle + speed * partialTicks;
if (Math.abs(angle - lastAngle) < 0.001) return; if (Math.abs(angle - lastAngle) < 0.001)
return;
animate(angle); animate(angle);
@ -94,7 +102,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
} }
private void animate(float angle) { private void animate(float angle) {
MatrixStack ms = new MatrixStack(); PoseStack ms = new PoseStack();
MatrixTransformStack msr = MatrixTransformStack.of(ms); MatrixTransformStack msr = MatrixTransformStack.of(ms);
msr.translate(getInstancePosition()); msr.translate(getInstancePosition());
@ -163,18 +171,19 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite); return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite);
} }
protected void transformConnector(MatrixTransformStack ms, boolean upper, boolean rotating, float angle, boolean flip) { protected void transformConnector(MatrixTransformStack ms, boolean upper, boolean rotating, float angle,
boolean flip) {
float shift = upper ? 1 / 4f : -1 / 8f; float shift = upper ? 1 / 4f : -1 / 8f;
float offset = upper ? 1 / 4f : 1 / 4f; float offset = upper ? 1 / 4f : 1 / 4f;
float radians = (float) (angle / 180 * Math.PI); float radians = (float) (angle / 180 * Math.PI);
float shifting = MathHelper.sin(radians) * shift + offset; float shifting = Mth.sin(radians) * shift + offset;
float maxAngle = upper ? -5 : -15; float maxAngle = upper ? -5 : -15;
float minAngle = upper ? -45 : 5; float minAngle = upper ? -45 : 5;
float barAngle = 0; float barAngle = 0;
if (rotating) if (rotating)
barAngle = MathHelper.lerp((MathHelper.sin((float) (radians + Math.PI / 2)) + 1) / 2, minAngle, maxAngle); barAngle = Mth.lerp((Mth.sin((float) (radians + Math.PI / 2)) + 1) / 2, minAngle, maxAngle);
float pivotX = (upper ? 8f : 3f) / 16; float pivotX = (upper ? 8f : 3f) / 16;
float pivotY = (upper ? 8f : 2f) / 16; float pivotY = (upper ? 8f : 2f) / 16;

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.flywheel;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -18,8 +19,8 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
InterpolatedChasingValue visualSpeed = new InterpolatedChasingValue(); InterpolatedChasingValue visualSpeed = new InterpolatedChasingValue();
float angle; float angle;
public FlywheelTileEntity(BlockEntityType<? extends FlywheelTileEntity> type) { public FlywheelTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
public void setRotation(float speed, float capacity) { public void setRotation(float speed, float capacity) {
@ -62,11 +63,11 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
generatedSpeed = compound.getFloat("GeneratedSpeed"); generatedSpeed = compound.getFloat("GeneratedSpeed");
generatedCapacity = compound.getFloat("GeneratedCapacity"); generatedCapacity = compound.getFloat("GeneratedCapacity");
stoppingCooldown = compound.getInt("Cooldown"); stoppingCooldown = compound.getInt("Cooldown");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (clientPacket) if (clientPacket)
visualSpeed.withSpeed(1 / 32f) visualSpeed.withSpeed(1 / 32f)
.target(getGeneratedSpeed()); .target(getGeneratedSpeed());

View file

@ -24,8 +24,8 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender
public float appliedSpeed; public float appliedSpeed;
protected FlywheelTileEntity poweredWheel; protected FlywheelTileEntity poweredWheel;
public EngineTileEntity(BlockEntityType<?> tileEntityTypeIn) { public EngineTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(tileEntityTypeIn); super(type, pos, state);
} }
@Override @Override

View file

@ -3,14 +3,15 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.BlockStressValues; import com.simibubi.create.foundation.block.BlockStressValues;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.AbstractFurnaceBlock; import net.minecraft.world.level.block.AbstractFurnaceBlock;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
public class FurnaceEngineTileEntity extends EngineTileEntity { public class FurnaceEngineTileEntity extends EngineTileEntity {
public FurnaceEngineTileEntity(BlockEntityType<? extends FurnaceEngineTileEntity> type) { public FurnaceEngineTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
@Override @Override

View file

@ -68,14 +68,14 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
ItemStack stackInSlot = inv.getStackInSlot(slot); ItemStack stackInSlot = inv.getStackInSlot(slot);
if (!stackInSlot.isEmpty()) if (!stackInSlot.isEmpty())
emptyOutput = false; emptyOutput = false;
player.inventory.placeItemBackInInventory(worldIn, stackInSlot); player.getInventory().placeItemBackInInventory(worldIn, stackInSlot);
inv.setStackInSlot(slot, ItemStack.EMPTY); inv.setStackInSlot(slot, ItemStack.EMPTY);
} }
if (emptyOutput) { if (emptyOutput) {
inv = millstone.inputInv; inv = millstone.inputInv;
for (int slot = 0; slot < inv.getSlots(); slot++) { for (int slot = 0; slot < inv.getSlots(); slot++) {
player.inventory.placeItemBackInInventory(worldIn, inv.getStackInSlot(slot)); player.getInventory().placeItemBackInInventory(worldIn, inv.getStackInSlot(slot));
inv.setStackInSlot(slot, ItemStack.EMPTY); inv.setStackInSlot(slot, ItemStack.EMPTY);
} }
} }
@ -113,7 +113,7 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
ItemStack remainder = capability.orElse(new ItemStackHandler()).insertItem(0, itemEntity.getItem(), false); ItemStack remainder = capability.orElse(new ItemStackHandler()).insertItem(0, itemEntity.getItem(), false);
if (remainder.isEmpty()) if (remainder.isEmpty())
itemEntity.remove(); itemEntity.discard();
if (remainder.getCount() < itemEntity.getItem().getCount()) if (remainder.getCount() < itemEntity.getItem().getCount())
itemEntity.setItem(remainder); itemEntity.setItem(remainder);
} }

View file

@ -11,6 +11,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.core.particles.ItemParticleOption; import net.minecraft.core.particles.ItemParticleOption;
@ -39,8 +40,8 @@ public class MillstoneTileEntity extends KineticTileEntity {
public int timer; public int timer;
private MillingRecipe lastRecipe; private MillingRecipe lastRecipe;
public MillstoneTileEntity(BlockEntityType<? extends MillstoneTileEntity> type) { public MillstoneTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
inputInv = new ItemStackHandler(1); inputInv = new ItemStackHandler(1);
outputInv = new ItemStackHandler(9); outputInv = new ItemStackHandler(9);
capability = LazyOptional.of(MillstoneInventoryHandler::new); capability = LazyOptional.of(MillstoneInventoryHandler::new);
@ -162,11 +163,11 @@ public class MillstoneTileEntity extends KineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
timer = compound.getInt("Timer"); timer = compound.getInt("Timer");
inputInv.deserializeNBT(compound.getCompound("InputInventory")); inputInv.deserializeNBT(compound.getCompound("InputInventory"));
outputInv.deserializeNBT(compound.getCompound("OutputInventory")); outputInv.deserializeNBT(compound.getCompound("OutputInventory"));
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
public int getProcessingSpeed() { public int getProcessingSpeed() {

View file

@ -20,6 +20,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.core.particles.ItemParticleOption; import net.minecraft.core.particles.ItemParticleOption;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
@ -49,8 +50,8 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
public int processingTicks; public int processingTicks;
public boolean running; public boolean running;
public MechanicalMixerTileEntity(BlockEntityType<? extends MechanicalMixerTileEntity> type) { public MechanicalMixerTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
public float getRenderedHeadOffset(float partialTicks) { public float getRenderedHeadOffset(float partialTicks) {
@ -94,10 +95,10 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
running = compound.getBoolean("Running"); running = compound.getBoolean("Running");
runningTicks = compound.getInt("Ticks"); runningTicks = compound.getInt("Ticks");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (clientPacket && hasLevel()) if (clientPacket && hasLevel())
getBasin().ifPresent(bte -> bte.setAreFluidsMoving(running && runningTicks <= 20)); getBasin().ifPresent(bte -> bte.setAreFluidsMoving(running && runningTicks <= 20));

View file

@ -8,6 +8,8 @@ import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance; import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.Direction;
public class MixerInstance extends ShaftlessCogInstance implements IDynamicInstance { public class MixerInstance extends ShaftlessCogInstance implements IDynamicInstance {
private final RotatingData mixerHead; private final RotatingData mixerHead;

View file

@ -11,15 +11,17 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
public class CreativeMotorTileEntity extends GeneratingKineticTileEntity { public class CreativeMotorTileEntity extends GeneratingKineticTileEntity {
public static final int DEFAULT_SPEED = 16; public static final int DEFAULT_SPEED = 16;
protected ScrollValueBehaviour generatedSpeed; protected ScrollValueBehaviour generatedSpeed;
public CreativeMotorTileEntity(BlockEntityType<? extends CreativeMotorTileEntity> type) { public CreativeMotorTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
@Override @Override

View file

@ -24,6 +24,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.core.particles.ItemParticleOption; import net.minecraft.core.particles.ItemParticleOption;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
@ -64,8 +65,8 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
public Mode mode; public Mode mode;
public boolean finished; public boolean finished;
public MechanicalPressTileEntity(BlockEntityType<? extends MechanicalPressTileEntity> type) { public MechanicalPressTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
mode = Mode.WORLD; mode = Mode.WORLD;
entityScanCooldown = ENTITY_SCAN; entityScanCooldown = ENTITY_SCAN;
} }
@ -80,12 +81,12 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
running = compound.getBoolean("Running"); running = compound.getBoolean("Running");
mode = Mode.values()[compound.getInt("Mode")]; mode = Mode.values()[compound.getInt("Mode")];
finished = compound.getBoolean("Finished"); finished = compound.getBoolean("Finished");
prevRunningTicks = runningTicks = compound.getInt("Ticks"); prevRunningTicks = runningTicks = compound.getInt("Ticks");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (clientPacket) { if (clientPacket) {
NBTHelper.iterateCompoundList(compound.getList("ParticleItems", NBT.TAG_COMPOUND), NBTHelper.iterateCompoundList(compound.getList("ParticleItems", NBT.TAG_COMPOUND),

View file

@ -11,6 +11,7 @@ import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;

View file

@ -1,25 +1,16 @@
package com.simibubi.create.content.contraptions.components.saw; package com.simibubi.create.content.contraptions.components.saw;
import static net.minecraft.state.properties.BlockStateProperties.FACING; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.net.minimport com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
ecraft.world.level.block.state.properties.BlockStatePropertiesport com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import net.minecraft.block.BlockState; import net.minecraft.core.Direction;
import net.minecraft.util.Direction; import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Rotation; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
public class SawInstance extends SingleRotatingInstance { public class SawInstance extends SingleRotatingInstance {
@ -29,9 +20,11 @@ public class SawInstance extends SingleRotatingInstance {
@Override @Override
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
if (blockState.getValue(FACING).getAxis().isHorizontal()) { if (blockState.getValue(BlockStateProperties.FACING)
.getAxis()
.isHorizontal()) {
BlockState referenceState = blockState.rotate(tile.getLevel(), tile.getBlockPos(), Rotation.CLOCKWISE_180); BlockState referenceState = blockState.rotate(tile.getLevel(), tile.getBlockPos(), Rotation.CLOCKWISE_180);
Direction facing = referenceState.getValue(FACING); Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, referenceState, facing); return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, referenceState, facing);
} else { } else {
return getRotatingMaterial().getModel(shaft()); return getRotatingMaterial().getModel(shaft());

View file

@ -28,6 +28,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.recipe.RecipeConditions; import com.simibubi.create.foundation.utility.recipe.RecipeConditions;
import com.simibubi.create.foundation.utility.recipe.RecipeFinder; import com.simibubi.create.foundation.utility.recipe.RecipeFinder;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
@ -84,8 +85,8 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
private ItemStack playEvent; private ItemStack playEvent;
public SawTileEntity(BlockEntityType<? extends SawTileEntity> type) { public SawTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
inventory = new ProcessingInventory(this::start).withSlotLimit(!AllConfigs.SERVER.recipes.bulkCutting.get()); inventory = new ProcessingInventory(this::start).withSlotLimit(!AllConfigs.SERVER.recipes.bulkCutting.get());
inventory.remainingTime = -1; inventory.remainingTime = -1;
recipeIndex = 0; recipeIndex = 0;
@ -114,8 +115,8 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
inventory.deserializeNBT(compound.getCompound("Inventory")); inventory.deserializeNBT(compound.getCompound("Inventory"));
recipeIndex = compound.getInt("RecipeIndex"); recipeIndex = compound.getInt("RecipeIndex");
if (compound.contains("PlayEvent")) if (compound.contains("PlayEvent"))
@ -383,7 +384,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
ItemStack remainder = inventory.insertItem(0, entity.getItem() ItemStack remainder = inventory.insertItem(0, entity.getItem()
.copy(), false); .copy(), false);
if (remainder.isEmpty()) if (remainder.isEmpty())
entity.remove(); entity.discard();
else else
entity.setItem(remainder); entity.setItem(remainder);
} }
@ -444,9 +445,11 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
@Override @Override
public void onBlockBroken(BlockState stateToBreak) { public void onBlockBroken(BlockState stateToBreak) {
Optional<AbstractBlockBreakQueue> dynamicTree = TreeCutter.findDynamicTree(stateToBreak.getBlock(), breakingPos); Optional<AbstractBlockBreakQueue> dynamicTree =
TreeCutter.findDynamicTree(stateToBreak.getBlock(), breakingPos);
if (dynamicTree.isPresent()) { if (dynamicTree.isPresent()) {
dynamicTree.get().destroyBlocks(level, null, this::dropItemFromCutTree); dynamicTree.get()
.destroyBlocks(level, null, this::dropItemFromCutTree);
return; return;
} }

View file

@ -51,6 +51,7 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fmllegacy.network.NetworkHooks; import net.minecraftforge.fmllegacy.network.NetworkHooks;
import net.minecraftforge.fmllegacy.network.PacketDistributor; import net.minecraftforge.fmllegacy.network.PacketDistributor;
@ -146,7 +147,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
if (seat == null) if (seat == null)
return null; return null;
Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat) Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat)
.add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks).add(VecHelper.getCenterOf(BlockPos.ZERO)) .add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks)
.add(VecHelper.getCenterOf(BlockPos.ZERO))
.subtract(0.5, ySize, 0.5); .subtract(0.5, ySize, 0.5);
return transformedVector; return transformedVector;
} }
@ -165,8 +167,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
int indexOfSeat = contraption.getSeats() int indexOfSeat = contraption.getSeats()
.indexOf(localPos); .indexOf(localPos);
if (indexOfSeat == -1) if (indexOfSeat == -1)
return contraption.interactors.containsKey(localPos) return contraption.interactors.containsKey(localPos) && contraption.interactors.get(localPos)
&& contraption.interactors.get(localPos).handlePlayerInteraction(player, interactionHand, localPos, this); .handlePlayerInteraction(player, interactionHand, localPos, this);
// Eject potential existing passenger // Eject potential existing passenger
Entity toDismount = null; Entity toDismount = null;
@ -218,7 +220,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
@Override @Override
public final void tick() { public final void tick() {
if (contraption == null) { if (contraption == null) {
remove(); discard();
return; return;
} }
@ -446,7 +448,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
if (contraption == null) if (contraption == null)
return; return;
remove(); discard();
StructureTransform transform = makeStructureTransform(); StructureTransform transform = makeStructureTransform();
AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this), AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> this),
@ -483,16 +485,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public void remove(boolean keepData) { public void remove(RemovalReason p_146834_) {
if (!level.isClientSide && !removed && contraption != null) { if (!level.isClientSide && !isRemoved() && contraption != null)
if (!ticking) if (!ticking)
contraption.stop(level); contraption.stop(level);
}
if (contraption != null) if (contraption != null)
contraption.onEntityRemoved(this); contraption.onEntityRemoved(this);
super.remove(keepData); super.remove(p_146834_);
} }
protected abstract StructureTransform makeStructureTransform(); protected abstract StructureTransform makeStructureTransform();
@ -514,7 +514,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
super.onRemovedFromWorld(); super.onRemovedFromWorld();
if (level != null && level.isClientSide) if (level != null && level.isClientSide)
return; return;
getPassengers().forEach(Entity::remove); getPassengers().forEach(Entity::discard);
} }
@Override @Override
@ -551,14 +551,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
protected abstract void handleStallInformation(float x, float y, float z, float angle); protected abstract void handleStallInformation(float x, float y, float z, float angle);
@Override @Override
@SuppressWarnings("deprecation")
public CompoundTag saveWithoutId(CompoundTag nbt) { public CompoundTag saveWithoutId(CompoundTag nbt) {
Vec3 vec = position(); Vec3 vec = position();
List<Entity> passengers = getPassengers(); List<Entity> passengers = getPassengers();
for (Entity entity : passengers) { for (Entity entity : passengers) {
// setPos has world accessing side-effects when removed == false // setPos has world accessing side-effects when removed == null
entity.removed = true; String srg = "f_146795_";
ObfuscationReflectionHelper.setPrivateValue(Entity.class, entity, RemovalReason.UNLOADED_TO_CHUNK, srg);
// Gather passengers into same chunk when saving // Gather passengers into same chunk when saving
Vec3 prevVec = entity.position(); Vec3 prevVec = entity.position();
@ -566,7 +566,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
// Super requires all passengers to not be removed in order to write them to the // Super requires all passengers to not be removed in order to write them to the
// tag // tag
entity.removed = false; ObfuscationReflectionHelper.setPrivateValue(Entity.class, entity, null, srg);
} }
CompoundTag tag = super.saveWithoutId(nbt); CompoundTag tag = super.saveWithoutId(nbt);
@ -639,7 +639,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
} }
@Override @Override
public boolean hasOnePlayerPassenger() { public boolean hasExactlyOnePlayerPassenger() {
return false; return false;
} }
@ -679,18 +679,17 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
} }
@Override @Override
protected boolean updateInWaterStateAndDoFluidPushing() { protected boolean updateInWaterStateAndDoFluidPushing() {
/* /*
* Override this with an empty method to reduce enormous calculation time when contraptions are in water * Override this with an empty method to reduce enormous calculation time when
* WARNING: THIS HAS A BUNCH OF SIDE EFFECTS! * contraptions are in water WARNING: THIS HAS A BUNCH OF SIDE EFFECTS! - Fluids
* - Fluids will not try to change contraption movement direction * will not try to change contraption movement direction - this.inWater and
* - this.inWater and this.isInWater() will return unreliable data * this.isInWater() will return unreliable data - entities riding a contraption
* - entities riding a contraption will not cause water splashes (seats are their own entity so this should be fine) * will not cause water splashes (seats are their own entity so this should be
* - fall distance is not reset when the contraption is in water * fine) - fall distance is not reset when the contraption is in water -
* - this.eyesInWater and this.canSwim() will always be false * this.eyesInWater and this.canSwim() will always be false - swimming state
* - swimming state will never be updated * will never be updated
*/ */
return false; return false;
} }

View file

@ -79,8 +79,6 @@ import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.protocol.game.DebugPackets; import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -105,10 +103,11 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.pipeline.BlockInfo;
import net.minecraftforge.common.util.Constants.BlockFlags; import net.minecraftforge.common.util.Constants.BlockFlags;
import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -625,9 +624,9 @@ public abstract class Contraption {
protected void addBlock(BlockPos pos, Pair<StructureBlockInfo, BlockEntity> pair) { protected void addBlock(BlockPos pos, Pair<StructureBlockInfo, BlockEntity> pair) {
StructureBlockInfo captured = pair.getKey(); StructureBlockInfo captured = pair.getKey();
BlockPos localPos = pos.subtract(anchor); BlockPos localPos = pos.subtract(anchor);
StructureBlockInfo blockInfo = new StructureBlockInfo(localPos, captured.state, captured.nbt); StructureBlockInfo StructureBlockInfo = new StructureBlockInfo(localPos, captured.state, captured.nbt);
if (blocks.put(localPos, blockInfo) != null) if (blocks.put(localPos, StructureBlockInfo) != null)
return; return;
bounds = bounds.minmax(new AABB(localPos)); bounds = bounds.minmax(new AABB(localPos));
@ -637,7 +636,7 @@ public abstract class Contraption {
if (te != null && MountedFluidStorage.canUseAsStorage(te)) if (te != null && MountedFluidStorage.canUseAsStorage(te))
fluidStorage.put(localPos, new MountedFluidStorage(te)); fluidStorage.put(localPos, new MountedFluidStorage(te));
if (AllMovementBehaviours.contains(captured.state.getBlock())) if (AllMovementBehaviours.contains(captured.state.getBlock()))
actors.add(MutablePair.of(blockInfo, null)); actors.add(MutablePair.of(StructureBlockInfo, null));
if (AllInteractionBehaviours.contains(captured.state.getBlock())) if (AllInteractionBehaviours.contains(captured.state.getBlock()))
interactors.put(localPos, AllInteractionBehaviours.of(captured.state.getBlock())); interactors.put(localPos, AllInteractionBehaviours.of(captured.state.getBlock()));
if (te instanceof CreativeCrateTileEntity if (te instanceof CreativeCrateTileEntity
@ -903,7 +902,8 @@ public abstract class Contraption {
blockList.forEach(e -> { blockList.forEach(e -> {
CompoundTag c = (CompoundTag) e; CompoundTag c = (CompoundTag) e;
StructureBlockInfo info = usePalettedDeserialization ? readBlockInfo(c, finalPalette) : legacyReadBlockInfo(c); StructureBlockInfo info =
usePalettedDeserialization ? readStructureBlockInfo(c, finalPalette) : legacyReadStructureBlockInfo(c);
this.blocks.put(info.pos, info); this.blocks.put(info.pos, info);
@ -918,10 +918,10 @@ public abstract class Contraption {
tag.putInt("y", info.pos.getY()); tag.putInt("y", info.pos.getY());
tag.putInt("z", info.pos.getZ()); tag.putInt("z", info.pos.getZ());
BlockEntity te = BlockEntity.loadStatic(info.state, tag); BlockEntity te = BlockEntity.loadStatic(info.pos, info.state, tag);
if (te == null) if (te == null)
return; return;
te.setLevelAndPosition(new ContraptionTileWorld(world, te, info), te.getBlockPos()); te.setLevel(world);
if (te instanceof KineticTileEntity) if (te instanceof KineticTileEntity)
((KineticTileEntity) te).setSpeed(0); ((KineticTileEntity) te).setSpeed(0);
te.getBlockState(); te.getBlockState();
@ -939,13 +939,14 @@ public abstract class Contraption {
}); });
} }
private static StructureBlockInfo readBlockInfo(CompoundTag blockListEntry, HashMapPalette<BlockState> palette) { private static StructureBlockInfo readStructureBlockInfo(CompoundTag blockListEntry,
HashMapPalette<BlockState> palette) {
return new StructureBlockInfo(BlockPos.of(blockListEntry.getLong("Pos")), return new StructureBlockInfo(BlockPos.of(blockListEntry.getLong("Pos")),
Objects.requireNonNull(palette.valueFor(blockListEntry.getInt("State"))), Objects.requireNonNull(palette.valueFor(blockListEntry.getInt("State"))),
blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null); blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null);
} }
private static StructureBlockInfo legacyReadBlockInfo(CompoundTag blockListEntry) { private static StructureBlockInfo legacyReadStructureBlockInfo(CompoundTag blockListEntry) {
return new StructureBlockInfo(NbtUtils.readBlockPos(blockListEntry.getCompound("Pos")), return new StructureBlockInfo(NbtUtils.readBlockPos(blockListEntry.getCompound("Pos")),
NbtUtils.readBlockState(blockListEntry.getCompound("Block")), NbtUtils.readBlockState(blockListEntry.getCompound("Block")),
blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null); blockListEntry.contains("Data") ? blockListEntry.getCompound("Data") : null);
@ -956,7 +957,7 @@ public abstract class Contraption {
.forEach(MountedStorage::removeStorageFromWorld); .forEach(MountedStorage::removeStorageFromWorld);
fluidStorage.values() fluidStorage.values()
.forEach(MountedFluidStorage::removeStorageFromWorld); .forEach(MountedFluidStorage::removeStorageFromWorld);
glueToRemove.forEach(SuperGlueEntity::remove); glueToRemove.forEach(SuperGlueEntity::discard);
for (boolean brittles : Iterate.trueAndFalse) { for (boolean brittles : Iterate.trueAndFalse) {
for (Iterator<StructureBlockInfo> iterator = blocks.values() for (Iterator<StructureBlockInfo> iterator = blocks.values()
@ -993,8 +994,10 @@ public abstract class Contraption {
int flags = BlockFlags.IS_MOVING | BlockFlags.DEFAULT; int flags = BlockFlags.IS_MOVING | BlockFlags.DEFAULT;
world.sendBlockUpdated(add, block.state, Blocks.AIR.defaultBlockState(), flags); world.sendBlockUpdated(add, block.state, Blocks.AIR.defaultBlockState(), flags);
// when the blockstate is set to air, the block's POI data is removed, but markAndNotifyBlock tries to // when the blockstate is set to air, the block's POI data is removed, but
// remove it again, so to prevent an error from being logged by double-removal we add the POI data back now // markAndNotifyBlock tries to
// remove it again, so to prevent an error from being logged by double-removal
// we add the POI data back now
// (code copied from ServerWorld.onBlockStateChange) // (code copied from ServerWorld.onBlockStateChange)
ServerLevel serverWorld = (ServerLevel) world; ServerLevel serverWorld = (ServerLevel) world;
PoiType.forState(block.state) PoiType.forState(block.state)
@ -1041,7 +1044,8 @@ public abstract class Contraption {
Block.dropResources(state, world, targetPos, null); Block.dropResources(state, world, targetPos, null);
continue; continue;
} }
if (state.getBlock() instanceof SimpleWaterloggedBlock && state.hasProperty(BlockStateProperties.WATERLOGGED)) { if (state.getBlock() instanceof SimpleWaterloggedBlock
&& state.hasProperty(BlockStateProperties.WATERLOGGED)) {
FluidState FluidState = world.getFluidState(targetPos); FluidState FluidState = world.getFluidState(targetPos);
state = state.setValue(BlockStateProperties.WATERLOGGED, FluidState.getType() == Fluids.WATER); state = state.setValue(BlockStateProperties.WATERLOGGED, FluidState.getType() == Fluids.WATER);
} }
@ -1073,7 +1077,7 @@ public abstract class Contraption {
if (tileEntity instanceof FluidTankTileEntity && tag.contains("LastKnownPos")) if (tileEntity instanceof FluidTankTileEntity && tag.contains("LastKnownPos"))
tag.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below())); tag.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below()));
tileEntity.load(block.state, tag); tileEntity.load(tag);
if (storage.containsKey(block.pos)) { if (storage.containsKey(block.pos)) {
MountedStorage mountedStorage = storage.get(block.pos); MountedStorage mountedStorage = storage.get(block.pos);
@ -1217,11 +1221,11 @@ public abstract class Contraption {
return seats; return seats;
} }
public Map<BlockPos, BlockInfo> getBlocks() { public Map<BlockPos, StructureBlockInfo> getBlocks() {
return blocks; return blocks;
} }
public List<MutablePair<BlockInfo, MovementContext>> getActors() { public List<MutablePair<StructureBlockInfo, MovementContext>> getActors() {
return actors; return actors;
} }
@ -1248,15 +1252,15 @@ public abstract class Contraption {
private void gatherBBsOffThread() { private void gatherBBsOffThread() {
getContraptionWorld(); getContraptionWorld();
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> { simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
VoxelShape combinedShape = VoxelShapes.empty(); VoxelShape combinedShape = Shapes.empty();
for (Entry<BlockPos, BlockInfo> entry : blocks.entrySet()) { for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
BlockInfo info = entry.getValue(); StructureBlockInfo info = entry.getValue();
BlockPos localPos = entry.getKey(); BlockPos localPos = entry.getKey();
VoxelShape collisionShape = info.state.getCollisionShape(world, localPos); VoxelShape collisionShape = info.state.getCollisionShape(world, localPos);
if (collisionShape.isEmpty()) if (collisionShape.isEmpty())
continue; continue;
combinedShape = VoxelShapes.joinUnoptimized(combinedShape, combinedShape = Shapes.joinUnoptimized(combinedShape,
collisionShape.move(localPos.getX(), localPos.getY(), localPos.getZ()), IBooleanFunction.OR); collisionShape.move(localPos.getX(), localPos.getY(), localPos.getZ()), BooleanOp.OR);
} }
return combinedShape.optimize() return combinedShape.optimize()
.toAabbs(); .toAabbs();
@ -1297,10 +1301,10 @@ public abstract class Contraption {
private static class ContraptionTileWorld extends WrappedWorld implements IFlywheelWorld { private static class ContraptionTileWorld extends WrappedWorld implements IFlywheelWorld {
private final TileEntity te; private final BlockEntity te;
private final BlockInfo info; private final StructureBlockInfo info;
public ContraptionTileWorld(World world, TileEntity te, BlockInfo info) { public ContraptionTileWorld(Level world, BlockEntity te, StructureBlockInfo info) {
super(world); super(world);
this.te = te; this.te = te;
this.info = info; this.info = info;

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import static net.minecraft.entity.Entity.collideBoundingBoxHeuristically; import static net.minecraft.world.entity.Entity.collideBoundingBoxHeuristically;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -35,6 +35,7 @@ import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RewindableStream; import net.minecraft.util.RewindableStream;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -240,7 +241,7 @@ public class ContraptionCollider {
BlockState blockState = contraption.getBlocks() BlockState blockState = contraption.getBlocks()
.get(pos).state; .get(pos).state;
bounce = BlockHelper.getBounceMultiplier(blockState.getBlock()); bounce = BlockHelper.getBounceMultiplier(blockState.getBlock());
slide = Math.max(0, blockState.getSlipperiness(contraption.world, pos, entity) - .6f); slide = Math.max(0, blockState.getFriction(contraption.world, pos, entity) - .6f);
} }
} }
@ -298,7 +299,7 @@ public class ContraptionCollider {
if (!hardCollision && surfaceCollision.isFalse()) if (!hardCollision && surfaceCollision.isFalse())
continue; continue;
Vec3 allowedMovement = getAllowedMovement(totalResponse, entity); Vec3 allowedMovement = collide(totalResponse, entity);
entity.setPos(entityPosition.x + allowedMovement.x, entityPosition.y + allowedMovement.y, entity.setPos(entityPosition.x + allowedMovement.x, entityPosition.y + allowedMovement.y,
entityPosition.z + allowedMovement.z); entityPosition.z + allowedMovement.z);
entityPosition = entity.position(); entityPosition = entity.position();
@ -317,7 +318,7 @@ public class ContraptionCollider {
entityMotion = entityMotion.multiply(.5f, 1, .5f); entityMotion = entityMotion.multiply(.5f, 1, .5f);
} }
contactPointMotion = contraptionEntity.getContactPointMotion(entityPosition); contactPointMotion = contraptionEntity.getContactPointMotion(entityPosition);
allowedMovement = getAllowedMovement(contactPointMotion, entity); allowedMovement = collide(contactPointMotion, entity);
entity.setPos(entityPosition.x + allowedMovement.x, entityPosition.y, entity.setPos(entityPosition.x + allowedMovement.x, entityPosition.y,
entityPosition.z + allowedMovement.z); entityPosition.z + allowedMovement.z);
} }
@ -329,7 +330,7 @@ public class ContraptionCollider {
double d0 = entity.getX() - entity.xo - contactPointMotion.x; double d0 = entity.getX() - entity.xo - contactPointMotion.x;
double d1 = entity.getZ() - entity.zo - contactPointMotion.z; double d1 = entity.getZ() - entity.zo - contactPointMotion.z;
float limbSwing = Mth.sqrt(d0 * d0 + d1 * d1) * 4.0F; float limbSwing = Mth.sqrt((float) (d0 * d0 + d1 * d1)) * 4.0F;
if (limbSwing > 1.0F) if (limbSwing > 1.0F)
limbSwing = 1.0F; limbSwing = 1.0F;
AllPackets.channel.sendToServer(new ClientMotionPacket(entityMotion, true, limbSwing)); AllPackets.channel.sendToServer(new ClientMotionPacket(entityMotion, true, limbSwing));
@ -394,45 +395,45 @@ public class ContraptionCollider {
return position; return position;
} }
/** From Entity#getAllowedMovement **/ /** From Entity#collide **/
static Vec3 getAllowedMovement(Vec3 movement, Entity e) { static Vec3 collide(Vec3 p_20273_, Entity e) {
AABB bb = e.getBoundingBox(); AABB aabb = e.getBoundingBox();
CollisionContext ctx = CollisionContext.of(e); CollisionContext collisioncontext = CollisionContext.of(e);
Level world = e.level; VoxelShape voxelshape = e.level.getWorldBorder()
VoxelShape voxelshape = world.getWorldBorder()
.getCollisionShape(); .getCollisionShape();
Stream<VoxelShape> stream = Stream<VoxelShape> stream =
Shapes.joinIsNotEmpty(voxelshape, Shapes.create(bb.deflate(1.0E-7D)), BooleanOp.AND) Shapes.joinIsNotEmpty(voxelshape, Shapes.create(aabb.deflate(1.0E-7D)), BooleanOp.AND) ? Stream.empty()
? Stream.empty()
: Stream.of(voxelshape); : Stream.of(voxelshape);
Stream<VoxelShape> stream1 = world.getEntityCollisions(e, bb.expandTowards(movement), entity -> false); // FIXME: 1.15 equivalent translated correctly? Stream<VoxelShape> stream1 = e.level.getEntityCollisions(e, aabb.expandTowards(p_20273_), (p_19949_) -> {
RewindableStream<VoxelShape> reuseablestream = new RewindableStream<>(Stream.concat(stream1, stream)); return true;
Vec3 allowedMovement = movement.lengthSqr() == 0.0D ? movement });
: collideBoundingBoxHeuristically(e, movement, bb, world, ctx, reuseablestream); RewindableStream<VoxelShape> rewindablestream = new RewindableStream<>(Stream.concat(stream1, stream));
boolean xDifferent = movement.x != allowedMovement.x; Vec3 vec3 = p_20273_.lengthSqr() == 0.0D ? p_20273_
boolean yDifferent = movement.y != allowedMovement.y; : collideBoundingBoxHeuristically(e, p_20273_, aabb, e.level, collisioncontext, rewindablestream);
boolean zDifferent = movement.z != allowedMovement.z; boolean flag = p_20273_.x != vec3.x;
boolean notMovingUp = e.isOnGround() || yDifferent && movement.y < 0.0D; boolean flag1 = p_20273_.y != vec3.y;
if (e.maxUpStep > 0.0F && notMovingUp && (xDifferent || zDifferent)) { boolean flag2 = p_20273_.z != vec3.z;
Vec3 allowedStep = collideBoundingBoxHeuristically(e, new Vec3(movement.x, (double) e.maxUpStep, movement.z), boolean flag3 = e.onGround || flag1 && p_20273_.y < 0.0D;
bb, world, ctx, reuseablestream); if (e.maxUpStep > 0.0F && flag3 && (flag || flag2)) {
Vec3 allowedStepGivenMovement = collideBoundingBoxHeuristically(e, new Vec3(0.0D, (double) e.maxUpStep, 0.0D), Vec3 vec31 = collideBoundingBoxHeuristically(e, new Vec3(p_20273_.x, e.maxUpStep, p_20273_.z), aabb,
bb.expandTowards(movement.x, 0.0D, movement.z), world, ctx, reuseablestream); e.level, collisioncontext, rewindablestream);
if (allowedStepGivenMovement.y < (double) e.maxUpStep) { Vec3 vec32 = collideBoundingBoxHeuristically(e, new Vec3(0.0D, e.maxUpStep, 0.0D),
Vec3 vec3 = collideBoundingBoxHeuristically(e, new Vec3(movement.x, 0.0D, movement.z), aabb.expandTowards(p_20273_.x, 0.0D, p_20273_.z), e.level, collisioncontext, rewindablestream);
bb.move(allowedStepGivenMovement), world, ctx, reuseablestream).add(allowedStepGivenMovement); if (vec32.y < e.maxUpStep) {
if (getHorizontalDistanceSqr(vec3) > getHorizontalDistanceSqr(allowedStep)) { Vec3 vec33 = collideBoundingBoxHeuristically(e, new Vec3(p_20273_.x, 0.0D, p_20273_.z),
allowedStep = vec3; aabb.move(vec32), e.level, collisioncontext, rewindablestream).add(vec32);
if (vec33.horizontalDistanceSqr() > vec31.horizontalDistanceSqr()) {
vec31 = vec33;
} }
} }
if (getHorizontalDistanceSqr(allowedStep) > getHorizontalDistanceSqr(allowedMovement)) { if (vec31.horizontalDistanceSqr() > vec3.horizontalDistanceSqr()) {
return allowedStep.add(collideBoundingBoxHeuristically(e, new Vec3(0.0D, -allowedStep.y + movement.y, 0.0D), return vec31.add(collideBoundingBoxHeuristically(e, new Vec3(0.0D, -vec31.y + p_20273_.y, 0.0D),
bb.move(allowedStep), world, ctx, reuseablestream)); aabb.move(vec31), e.level, collisioncontext, rewindablestream));
} }
} }
return allowedMovement; return vec3;
} }
private static PlayerType getPlayerType(Entity entity) { private static PlayerType getPlayerType(Entity entity) {

View file

@ -8,7 +8,7 @@ import com.jozufozu.flywheel.light.LightProvider;
import com.jozufozu.flywheel.light.LightUpdater; import com.jozufozu.flywheel.light.LightUpdater;
import com.jozufozu.flywheel.light.ListenerStatus; import com.jozufozu.flywheel.light.ListenerStatus;
import net.minecraft.world.LightType; import net.minecraft.world.level.LightLayer;
public abstract class ContraptionLighter<C extends Contraption> implements ILightUpdateListener { public abstract class ContraptionLighter<C extends Contraption> implements ILightUpdateListener {
protected final C contraption; protected final C contraption;
@ -42,7 +42,7 @@ public abstract class ContraptionLighter<C extends Contraption> implements ILigh
} }
@Override @Override
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed) { public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed) {
lightVolume.onLightUpdate(world, type, changed); lightVolume.onLightUpdate(world, type, changed);
} }

View file

@ -1,7 +1,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import static net.minecraft.util.text.TextFormatting.GRAY;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -23,12 +21,15 @@ public interface IDisplayAssemblyExceptions {
if (!tooltip.isEmpty()) if (!tooltip.isEmpty())
tooltip.add(TextComponent.EMPTY); tooltip.add(TextComponent.EMPTY);
tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy().append(Lang.translate("gui.assembly.exception").withStyle(ChatFormatting.GOLD))); tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
.append(Lang.translate("gui.assembly.exception")
.withStyle(ChatFormatting.GOLD)));
String text = e.component.getString(); String text = e.component.getString();
Arrays.stream(text.split("\n")) Arrays.stream(text.split("\n"))
.forEach(l -> TooltipHelper.cutStringTextComponent(l, GRAY, WHITE) .forEach(l -> TooltipHelper.cutStringTextComponent(l, ChatFormatting.GRAY, ChatFormatting.WHITE)
.forEach(c -> tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy().append(c)))); .forEach(c -> tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
.append(c))));
return true; return true;
} }

View file

@ -1,7 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import static net.minecraft.block.HorizontalFaceBlock.FACE; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.AXIS;
import static net.minecraft.state.properties.BlockStateProperties.FACING; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
@ -30,6 +31,8 @@ import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.level.block.state.properties.BellAttachType; import net.minecraft.world.level.block.state.properties.BellAttachType;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.Half; import net.minecraft.world.level.block.state.properties.Half;
import net.minecraft.world.level.block.state.properties.SlabType; import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@ -124,11 +127,10 @@ public class StructureTransform {
if (rotationAxis == Axis.Y) { if (rotationAxis == Axis.Y) {
if (block instanceof BellBlock) { if (block instanceof BellBlock) {
if (state.getValue(BlockStateProperties.BELL_ATTACHMENT) == BellAttachType.DOUBLE_WALL) { if (state.getValue(BlockStateProperties.BELL_ATTACHMENT) == BellAttachType.DOUBLE_WALL)
state = state.setValue(BlockStateProperties.BELL_ATTACHMENT, BellAttachType.SINGLE_WALL); state = state.setValue(BlockStateProperties.BELL_ATTACHMENT, BellAttachType.SINGLE_WALL);
} return state.setValue(BellBlock.FACING,
return state.setValue(FaceAttachedHorizontalDirectionalBlock.FACING, rotation.rotate(state.getValue(BellBlock.FACING)));
rotation.rotate(state.getValue(FaceAttachedHorizontalDirectionalBlock.FACING)));
} }
return state.rotate(rotation); return state.rotate(rotation);
} }
@ -137,30 +139,32 @@ public class StructureTransform {
return rotateChassis(state); return rotateChassis(state);
if (block instanceof FaceAttachedHorizontalDirectionalBlock) { if (block instanceof FaceAttachedHorizontalDirectionalBlock) {
Direction stateFacing = state.getValue(FaceAttachedHorizontalDirectionalBlock.FACING); DirectionProperty facingProperty = FaceAttachedHorizontalDirectionalBlock.FACING;
AttachFace stateFace = state.getValue(FACE); EnumProperty<AttachFace> faceProperty = FaceAttachedHorizontalDirectionalBlock.FACE;
Direction stateFacing = state.getValue(facingProperty);
AttachFace stateFace = state.getValue(faceProperty);
Direction forcedAxis = rotationAxis == Axis.Z ? Direction.EAST : Direction.SOUTH; Direction forcedAxis = rotationAxis == Axis.Z ? Direction.EAST : Direction.SOUTH;
if (stateFacing.getAxis() == rotationAxis && stateFace == AttachFace.WALL) if (stateFacing.getAxis() == rotationAxis && stateFace == AttachFace.WALL)
return state; return state;
for (int i = 0; i < rotation.ordinal(); i++) { for (int i = 0; i < rotation.ordinal(); i++) {
stateFace = state.getValue(FACE); stateFace = state.getValue(faceProperty);
stateFacing = state.getValue(FaceAttachedHorizontalDirectionalBlock.FACING); stateFacing = state.getValue(facingProperty);
boolean b = state.getValue(FACE) == AttachFace.CEILING; boolean b = state.getValue(faceProperty) == AttachFace.CEILING;
state = state.setValue(HORIZONTAL_FACING, b ? forcedAxis : forcedAxis.getOpposite()); state = state.setValue(facingProperty, b ? forcedAxis : forcedAxis.getOpposite());
if (stateFace != AttachFace.WALL) { if (stateFace != AttachFace.WALL) {
state = state.setValue(FACE, AttachFace.WALL); state = state.setValue(faceProperty, AttachFace.WALL);
continue; continue;
} }
if (stateFacing.getAxisDirection() == AxisDirection.POSITIVE) { if (stateFacing.getAxisDirection() == AxisDirection.POSITIVE) {
state = state.setValue(FACE, AttachFace.FLOOR); state = state.setValue(faceProperty, AttachFace.FLOOR);
continue; continue;
} }
state = state.setValue(FACE, AttachFace.CEILING); state = state.setValue(faceProperty, AttachFace.CEILING);
} }
return state; return state;

View file

@ -45,8 +45,8 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
private float prevForcedAngle; private float prevForcedAngle;
public ClockworkBearingTileEntity(BlockEntityType<? extends ClockworkBearingTileEntity> type) { public ClockworkBearingTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
setLazyTickRate(3); setLazyTickRate(3);
} }
@ -310,7 +310,7 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
float hourAngleBefore = hourAngle; float hourAngleBefore = hourAngle;
float minuteAngleBefore = minuteAngle; float minuteAngleBefore = minuteAngle;
@ -318,7 +318,7 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
hourAngle = compound.getFloat("HourAngle"); hourAngle = compound.getFloat("HourAngle");
minuteAngle = compound.getFloat("MinuteAngle"); minuteAngle = compound.getFloat("MinuteAngle");
lastException = AssemblyException.read(compound); lastException = AssemblyException.read(compound);
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (!clientPacket) if (!clientPacket)
return; return;

View file

@ -1,7 +1,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement.bearing; package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import java.util.List; import java.util.List;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
@ -40,8 +38,8 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
private float prevAngle; private float prevAngle;
public MechanicalBearingTileEntity(BlockEntityType<? extends MechanicalBearingTileEntity> type) { public MechanicalBearingTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
setLazyTickRate(3); setLazyTickRate(3);
} }
@ -75,9 +73,9 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
if (wasMoved) { if (wasMoved) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
return; return;
} }
@ -85,7 +83,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
running = compound.getBoolean("Running"); running = compound.getBoolean("Running");
angle = compound.getFloat("Angle"); angle = compound.getFloat("Angle");
lastException = AssemblyException.read(compound); lastException = AssemblyException.read(compound);
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (!clientPacket) if (!clientPacket)
return; return;
if (running) { if (running) {
@ -145,7 +143,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
.getBlock() instanceof BearingBlock)) .getBlock() instanceof BearingBlock))
return; return;
Direction direction = getBlockState().getValue(FACING); Direction direction = getBlockState().getValue(BearingBlock.FACING);
BearingContraption contraption = new BearingContraption(isWindmill(), direction); BearingContraption contraption = new BearingContraption(isWindmill(), direction);
try { try {
if (!contraption.assemble(level, worldPosition)) if (!contraption.assemble(level, worldPosition))
@ -263,12 +261,12 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
BlockState blockState = getBlockState(); BlockState blockState = getBlockState();
if (!(contraption.getContraption() instanceof BearingContraption)) if (!(contraption.getContraption() instanceof BearingContraption))
return; return;
if (!blockState.hasProperty(FACING)) if (!blockState.hasProperty(BearingBlock.FACING))
return; return;
this.movedContraption = contraption; this.movedContraption = contraption;
setChanged(); setChanged();
BlockPos anchor = worldPosition.relative(blockState.getValue(FACING)); BlockPos anchor = worldPosition.relative(blockState.getValue(BearingBlock.FACING));
movedContraption.setPos(anchor.getX(), anchor.getY(), anchor.getZ()); movedContraption.setPos(anchor.getX(), anchor.getY(), anchor.getZ());
if (!level.isClientSide) { if (!level.isClientSide) {
this.running = true; this.running = true;

View file

@ -17,6 +17,7 @@ import com.simibubi.create.foundation.utility.placement.IPlacementHelper;
import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
import com.simibubi.create.foundation.utility.placement.PlacementOffset; import com.simibubi.create.foundation.utility.placement.PlacementOffset;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;

View file

@ -9,6 +9,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIco
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -19,8 +20,8 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
protected ScrollOptionBehaviour<RotationDirection> movementDirection; protected ScrollOptionBehaviour<RotationDirection> movementDirection;
protected float lastGeneratedSpeed; protected float lastGeneratedSpeed;
public WindmillBearingTileEntity(BlockEntityType<? extends MechanicalBearingTileEntity> type) { public WindmillBearingTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
@Override @Override
@ -64,10 +65,10 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
if (!wasMoved) if (!wasMoved)
lastGeneratedSpeed = compound.getFloat("LastGenerated"); lastGeneratedSpeed = compound.getFloat("LastGenerated");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
@Override @Override

View file

@ -1,17 +1,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement.chassis; package com.simibubi.create.content.contraptions.components.structureMovement.chassis;
import static net.minecraft.state.properties.BlockStateProperties.AXIS;
import javanet.minimport com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.BulkScrollValueBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -19,21 +7,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
import java.util.Set; import java.util.Set;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
ecraft.world.level.block.state.properties.BlockStatePropertiesport java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks;
@ -46,14 +19,14 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.core.Direction;
import net.minecraft.tileentity.TileEntity; import net.minecraft.core.Direction.Axis;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.util.Direction; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.util.Direction.Axis; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.util.Direction.AxisDirection; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
@ -61,8 +34,8 @@ public class ChassisTileEntity extends SmartTileEntity {
ScrollValueBehaviour range; ScrollValueBehaviour range;
public ChassisTileEntity(BlockEntityType<? extends ChassisTileEntity> type) { public ChassisTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
@Override @Override
@ -161,7 +134,7 @@ public class ChassisTileEntity extends SmartTileEntity {
continue; continue;
if (!LinearChassisBlock.sameKind(state, neighbourState)) if (!LinearChassisBlock.sameKind(state, neighbourState))
continue; continue;
if (neighbourState.getValue(AXIS) != axis) if (neighbourState.getValue(LinearChassisBlock.AXIS) != axis)
continue; continue;
frontier.add(current); frontier.add(current);

View file

@ -14,6 +14,7 @@ import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -27,8 +28,8 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende
LerpedFloat piston; LerpedFloat piston;
boolean update; boolean update;
public StickerTileEntity(BlockEntityType<?> tileEntityTypeIn) { public StickerTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(tileEntityTypeIn); super(type, pos, state);
piston = LerpedFloat.linear(); piston = LerpedFloat.linear();
update = false; update = false;
} }
@ -82,8 +83,8 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (clientPacket) if (clientPacket)
update = true; update = true;
} }

View file

@ -1,8 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.gantry; package com.simibubi.create.content.contraptions.components.structureMovement.gantry;
import static net.minecraft.state.properties.BlockStateProperties.FACING; import com.simibubi.create.AllBlocks;
import com.net.minimport com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException;
@ -10,6 +8,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
import com.simibubi.create.content.contraptions.components.structureMovement.IDisplayAssemblyExceptions; import com.simibubi.create.content.contraptions.components.structureMovement.IDisplayAssemblyExceptions;
import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock; import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock;
import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity; import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -18,29 +17,13 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
ecraft.world.level.block.state.properties.BlockStatePropertiesate.AllSoundEvents;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionCollider;
import com.simibubi.create.content.contraptions.components.structureMovement.IDisplayAssemblyExceptions;
import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock;
import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
public class GantryCarriageTileEntity extends KineticTileEntity implements IDisplayAssemblyExceptions { public class GantryCarriageTileEntity extends KineticTileEntity implements IDisplayAssemblyExceptions {
boolean assembleNextTick; boolean assembleNextTick;
protected AssemblyException lastException; protected AssemblyException lastException;
public GantryCarriageTileEntity(BlockEntityType<?> typeIn) { public GantryCarriageTileEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn); super(typeIn, pos, state);
} }
@Override @Override
@ -87,7 +70,7 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp
if (!(blockState.getBlock() instanceof GantryCarriageBlock)) if (!(blockState.getBlock() instanceof GantryCarriageBlock))
return; return;
Direction direction = blockState.getValue(FACING); Direction direction = blockState.getValue(GantryCarriageBlock.FACING);
GantryContraption contraption = new GantryContraption(direction); GantryContraption contraption = new GantryContraption(direction);
BlockEntity shaftTe = level.getBlockEntity(worldPosition.relative(direction.getOpposite())); BlockEntity shaftTe = level.getBlockEntity(worldPosition.relative(direction.getOpposite()));
@ -134,9 +117,9 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
lastException = AssemblyException.read(compound); lastException = AssemblyException.read(compound);
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
@Override @Override

View file

@ -14,7 +14,6 @@ import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.core.model.IModel;
import com.mojang.math.Quaternion; import com.mojang.math.Quaternion;
import com.mojang.math.Vector3d;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllStitchedTextures; import com.simibubi.create.AllStitchedTextures;
import com.simibubi.create.Create; import com.simibubi.create.Create;
@ -24,9 +23,11 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.LightType; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.phys.Vec3;
public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITickableInstance { public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITickableInstance {
@ -82,12 +83,12 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
private void updateLight(OrientedData model) { private void updateLight(OrientedData model) {
BlockPos pos = entity.getHangingPosition(); BlockPos pos = entity.getHangingPosition();
model.setBlockLight(world.getBrightness(LightType.BLOCK, pos)) model.setBlockLight(world.getBrightness(LightLayer.BLOCK, pos))
.setSkyLight(world.getBrightness(LightType.SKY, pos)); .setSkyLight(world.getBrightness(LightLayer.SKY, pos));
} }
private boolean shouldShow() { private boolean shouldShow() {
PlayerEntity player = Minecraft.getInstance().player; Player player = Minecraft.getInstance().player;
return entity.isVisible() return entity.isVisible()
|| AllItems.SUPER_GLUE.isIn(player.getMainHandItem()) || AllItems.SUPER_GLUE.isIn(player.getMainHandItem())
@ -97,29 +98,29 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
public static class GlueModel implements IModel { public static class GlueModel implements IModel {
@Override @Override
public void buffer(VecBuffer buffer) { public void buffer(VecBuffer buffer) {
Vector3d diff = Vector3d.atLowerCornerOf(Direction.SOUTH.getNormal()); Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
Vector3d extension = diff.normalize() Vec3 extension = diff.normalize()
.scale(1 / 32f - 1 / 128f); .scale(1 / 32f - 1 / 128f);
Vector3d plane = VecHelper.axisAlingedPlaneOf(diff); Vec3 plane = VecHelper.axisAlingedPlaneOf(diff);
Direction.Axis axis = Direction.getNearest(diff.x, diff.y, diff.z) Direction.Axis axis = Direction.getNearest(diff.x, diff.y, diff.z)
.getAxis(); .getAxis();
Vector3d start = Vector3d.ZERO.subtract(extension); Vec3 start = Vec3.ZERO.subtract(extension);
Vector3d end = Vector3d.ZERO.add(extension); Vec3 end = Vec3.ZERO.add(extension);
plane = plane.scale(1 / 2f); plane = plane.scale(1 / 2f);
Vector3d a1 = plane.add(start); Vec3 a1 = plane.add(start);
Vector3d b1 = plane.add(end); Vec3 b1 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis); plane = VecHelper.rotate(plane, -90, axis);
Vector3d a2 = plane.add(start); Vec3 a2 = plane.add(start);
Vector3d b2 = plane.add(end); Vec3 b2 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis); plane = VecHelper.rotate(plane, -90, axis);
Vector3d a3 = plane.add(start); Vec3 a3 = plane.add(start);
Vector3d b3 = plane.add(end); Vec3 b3 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis); plane = VecHelper.rotate(plane, -90, axis);
Vector3d a4 = plane.add(start); Vec3 a4 = plane.add(start);
Vector3d b4 = plane.add(end); Vec3 b4 = plane.add(end);
float minU; float minU;
float maxU; float maxU;

View file

@ -67,7 +67,8 @@ import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fmllegacy.network.NetworkHooks; import net.minecraftforge.fmllegacy.network.NetworkHooks;
import net.minecraftforge.fmllegacy.network.PacketDistributor; import net.minecraftforge.fmllegacy.network.PacketDistributor;
public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement, IInstanceRendered { public class SuperGlueEntity extends Entity
implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement, IInstanceRendered {
private int validationTimer; private int validationTimer;
protected BlockPos hangingPosition; protected BlockPos hangingPosition;
@ -112,16 +113,16 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
Validate.notNull(getFacingDirection()); Validate.notNull(getFacingDirection());
if (getFacingDirection().getAxis() if (getFacingDirection().getAxis()
.isHorizontal()) { .isHorizontal()) {
this.xRot = 0.0F; setXRot(0);
this.yRot = getFacingDirection().get2DDataValue() * 90; setYRot(getFacingDirection().get2DDataValue() * 90);
} else { } else {
this.xRot = -90 * getFacingDirection().getAxisDirection() setXRot(-90 * getFacingDirection().getAxisDirection()
.getStep(); .getStep());
this.yRot = 0.0F; setYRot(0);
} }
this.xRotO = this.xRot; this.xRotO = this.getXRot();
this.yRotO = this.yRot; this.yRotO = this.getYRot();
this.updateBoundingBox(); this.updateBoundingBox();
} }
@ -162,7 +163,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
if (this.validationTimer++ == 10 && !this.level.isClientSide) { if (this.validationTimer++ == 10 && !this.level.isClientSide) {
this.validationTimer = 0; this.validationTimer = 0;
if (isAlive() && !this.onValidSurface()) { if (isAlive() && !this.onValidSurface()) {
remove(); kill();
onBroken(null); onBroken(null);
} }
} }
@ -249,9 +250,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
@Override @Override
public boolean skipAttackInteraction(Entity entity) { public boolean skipAttackInteraction(Entity entity) {
return entity instanceof Player return entity instanceof Player ? hurt(DamageSource.playerAttack((Player) entity), 0) : false;
? hurt(DamageSource.playerAttack((Player) entity), 0)
: false;
} }
@Override @Override
@ -264,7 +263,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
if (this.isInvulnerableTo(source)) if (this.isInvulnerableTo(source))
return false; return false;
boolean mobGriefing = level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); boolean mobGriefing = level.getGameRules()
.getBoolean(GameRules.RULE_MOBGRIEFING);
Entity trueSource = source.getEntity(); Entity trueSource = source.getEntity();
if (!mobGriefing && trueSource instanceof Mob) if (!mobGriefing && trueSource instanceof Mob)
return false; return false;
@ -276,7 +276,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
} }
if (isAlive() && !level.isClientSide) { if (isAlive() && !level.isClientSide) {
remove(); kill();
markHurt(); markHurt();
onBroken(source.getEntity()); onBroken(source.getEntity());
} }
@ -287,7 +287,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
@Override @Override
public void move(MoverType typeIn, Vec3 pos) { public void move(MoverType typeIn, Vec3 pos) {
if (!level.isClientSide && isAlive() && pos.lengthSqr() > 0.0D) { if (!level.isClientSide && isAlive() && pos.lengthSqr() > 0.0D) {
remove(); discard();
onBroken(null); onBroken(null);
} }
} }
@ -295,7 +295,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
@Override @Override
public void push(double x, double y, double z) { public void push(double x, double y, double z) {
if (!level.isClientSide && isAlive() && x * x + y * y + z * z > 0.0D) { if (!level.isClientSide && isAlive() && x * x + y * y + z * z > 0.0D) {
remove(); discard();
onBroken(null); onBroken(null);
} }
} }
@ -334,8 +334,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
LocalPlayer cPlayer = (LocalPlayer) player; LocalPlayer cPlayer = (LocalPlayer) player;
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
HitResult ray = HitResult ray = cPlayer.pick(mc.gameMode.getPickRange(), AnimationTickHolder.getPartialTicks(), false);
cPlayer.pick(mc.gameMode.getPickRange(), AnimationTickHolder.getPartialTicks(), false);
if (!(ray instanceof BlockHitResult)) if (!(ray instanceof BlockHitResult))
return; return;
@ -423,7 +422,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
} }
} }
float f = Mth.wrapDegrees(this.yRot); float f = Mth.wrapDegrees(this.getYRot());
switch (transformRotation) { switch (transformRotation) {
case CLOCKWISE_180: case CLOCKWISE_180:
return f + 180.0F; return f + 180.0F;

View file

@ -2,3 +2,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement.glue; package com.simibubi.create.content.contraptions.components.structureMovement.glue;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -185,7 +185,7 @@ public class CartAssemblerBlock extends BaseRailBlock
if (!player.isCreative()) { if (!player.isCreative()) {
itemStack.shrink(1); itemStack.shrink(1);
player.inventory.placeItemBackInInventory(world, new ItemStack(previousItem)); player.getInventory().placeItemBackInInventory(new ItemStack(previousItem));
} }
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
@ -286,7 +286,7 @@ public class CartAssemblerBlock extends BaseRailBlock
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
if (player != null && !player.isCreative()) if (player != null && !player.isCreative())
getDropsNoRail(state, (ServerLevel) world, pos, world.getBlockEntity(pos), player, context.getItemInHand()) getDropsNoRail(state, (ServerLevel) world, pos, world.getBlockEntity(pos), player, context.getItemInHand())
.forEach(itemStack -> player.inventory.placeItemBackInInventory(world, itemStack)); .forEach(itemStack -> player.getInventory().placeItemBackInInventory(itemStack));
if (world instanceof ServerLevel) if (world instanceof ServerLevel)
state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY); state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY);
world.setBlockAndUpdate(pos, getRailBlock(state)); world.setBlockAndUpdate(pos, getRailBlock(state));

View file

@ -49,8 +49,8 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay
protected AssemblyException lastException; protected AssemblyException lastException;
protected AbstractMinecart cartToAssemble; protected AbstractMinecart cartToAssemble;
public CartAssemblerTileEntity(BlockEntityType<? extends CartAssemblerTileEntity> type) { public CartAssemblerTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
ticksSinceMinecartUpdate = assemblyCooldown; ticksSinceMinecartUpdate = assemblyCooldown;
} }
@ -242,9 +242,9 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
lastException = AssemblyException.read(compound); lastException = AssemblyException.read(compound);
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
@Override @Override

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.mo
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;

View file

@ -245,7 +245,7 @@ public class MinecartContraptionItem extends Item {
return; return;
} }
player.inventory.placeItemBackInInventory(event.getWorld(), generatedStack); player.getInventory().placeItemBackInInventory(event.getWorld(), generatedStack);
contraption.remove(); contraption.remove();
entity.remove(); entity.remove();
event.setCancellationResult(InteractionResult.SUCCESS); event.setCancellationResult(InteractionResult.SUCCESS);

View file

@ -36,8 +36,8 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
// Custom position sync // Custom position sync
protected float clientOffsetDiff; protected float clientOffsetDiff;
public LinearActuatorTileEntity(BlockEntityType<?> typeIn) { public LinearActuatorTileEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn); super(typeIn, pos, state);
setLazyTickRate(3); setLazyTickRate(3);
forceMove = true; forceMove = true;
} }
@ -179,7 +179,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
boolean forceMovement = compound.contains("ForceMovement"); boolean forceMovement = compound.contains("ForceMovement");
float offsetBefore = offset; float offsetBefore = offset;
@ -187,7 +187,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
waitingForSpeedChange = compound.getBoolean("Waiting"); waitingForSpeedChange = compound.getBoolean("Waiting");
offset = compound.getFloat("Offset"); offset = compound.getFloat("Offset");
lastException = AssemblyException.read(compound); lastException = AssemblyException.read(compound);
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (!clientPacket) if (!clientPacket)
return; return;

View file

@ -27,14 +27,14 @@ public class MechanicalPistonTileEntity extends LinearActuatorTileEntity {
protected boolean hadCollisionWithOtherPiston; protected boolean hadCollisionWithOtherPiston;
protected int extensionLength; protected int extensionLength;
public MechanicalPistonTileEntity(BlockEntityType<? extends MechanicalPistonTileEntity> type) { public MechanicalPistonTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
extensionLength = compound.getInt("ExtensionLength"); extensionLength = compound.getInt("ExtensionLength");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
@Override @Override

View file

@ -6,35 +6,11 @@ import static com.simibubi.create.content.contraptions.components.structureMovem
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPiston; import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPiston;
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPistonHead; import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPistonHead;
import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isStickyPiston; import static com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isStickyPiston;
import static net.minecraft.state.properties.BlockStateProperties.FACING; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
import javanet.minimport com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException;
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType;
import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.VecHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.WoolCarpetBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.PistonType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.commons.lang3.tuple.Pair;
ecraft.world.level.block.state.properties.BlockStatePropertiesva.util.Queue;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -47,19 +23,19 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pis
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.block.CarpetBlock; import net.minecraft.core.Direction;
import net.minecraft.block.material.PushReaction; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.level.Level;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.state.properties.PistonType; import net.minecraft.world.level.block.WoolCarpetBlock;
import net.minecraft.tileentity.TileEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.util.Direction; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.state.properties.PistonType;
import net.minecraft.world.IWorld; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraft.world.World; import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -166,7 +142,7 @@ public class PistonContraption extends TranslatingContraption {
BlockPos relPos = pole.pos.relative(direction, -extensionsInFront); BlockPos relPos = pole.pos.relative(direction, -extensionsInFront);
BlockPos localPos = relPos.subtract(anchor); BlockPos localPos = relPos.subtract(anchor);
getBlocks().put(localPos, new StructureBlockInfo(localPos, pole.state, null)); getBlocks().put(localPos, new StructureBlockInfo(localPos, pole.state, null));
//pistonExtensionCollisionBox = pistonExtensionCollisionBox.union(new AxisAlignedBB(localPos)); //pistonExtensionCollisionBox = pistonExtensionCollisionBox.union(new AABB(localPos));
} }
return true; return true;
@ -188,7 +164,7 @@ public class PistonContraption extends TranslatingContraption {
if (offset == 1 && retracting) if (offset == 1 && retracting)
return true; return true;
BlockPos currentPos = pos.relative(orientation, offset + initialExtensionProgress); BlockPos currentPos = pos.relative(orientation, offset + initialExtensionProgress);
if (retracting && Level.isOutsideBuildHeight(currentPos)) if (retracting && world.isOutsideBuildHeight(currentPos))
return true; return true;
if (!world.isLoaded(currentPos)) if (!world.isLoaded(currentPos))
throw AssemblyException.unloadedChunk(currentPos); throw AssemblyException.unloadedChunk(currentPos);

View file

@ -15,6 +15,7 @@ import com.simibubi.create.foundation.utility.placement.IPlacementHelper;
import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
import com.simibubi.create.foundation.utility.placement.util.PoleHelper; import com.simibubi.create.foundation.utility.placement.util.PoleHelper;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;

View file

@ -18,8 +18,9 @@ import com.mojang.math.Vector3f;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
import net.minecraft.util.math.MathHelper; import net.minecraft.core.Direction;
import net.minecraft.world.LightType; import net.minecraft.util.Mth;
import net.minecraft.world.level.LightLayer;
public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, IMovingListener { public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, IMovingListener {
@ -71,7 +72,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
magnet.update() magnet.update()
.get() .get()
.ifPresent(data -> { .ifPresent(data -> {
int i = Math.max(0, MathHelper.floor(offset)); int i = Math.max(0, Mth.floor(offset));
short packed = light.getPackedLight(pos.getX(), pos.getY() - i, pos.getZ()); short packed = light.getPackedLight(pos.getX(), pos.getY() - i, pos.getZ());
data.setPosition(getInstancePosition()) data.setPosition(getInstancePosition())
.nudge(0, -offset, 0) .nudge(0, -offset, 0)
@ -149,7 +150,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
} }
private boolean updateVolume() { private boolean updateVolume() {
int length = MathHelper.ceil(offset) + 2; int length = Mth.ceil(offset) + 2;
if (volume.sizeY() < length) { if (volume.sizeY() < length) {
volume.assign(pos.below(length), pos) volume.assign(pos.below(length), pos)
@ -164,7 +165,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
} }
private int getNeededRopeCount() { private int getNeededRopeCount() {
return Math.max(0, MathHelper.ceil(offset - 1.25f)); return Math.max(0, Mth.ceil(offset - 1.25f));
} }
private boolean shouldRenderHalfRope() { private boolean shouldRenderHalfRope() {
@ -191,7 +192,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
} }
@Override @Override
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed) { public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed) {
super.onLightUpdate(world, type, changed); super.onLightUpdate(world, type, changed);
light.onLightUpdate(world, type, changed); light.onLightUpdate(world, type, changed);
} }

View file

@ -44,7 +44,9 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) { int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return; if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
float offset = getOffset(te, partialTicks); float offset = getOffset(te, partialTicks);
@ -107,7 +109,13 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) { protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
return PartialBufferer.getFacing(getCoil(), blockState, Direction.get(AxisDirection.POSITIVE, getShaftAxis(te))); return PartialBufferer.getFacing(getCoil(), blockState,
Direction.get(AxisDirection.POSITIVE, getShaftAxis(te)));
}
@Override
public int getViewDistance() {
return 256;
} }
} }

View file

@ -63,4 +63,10 @@ public class PulleyRenderer extends AbstractPulleyRenderer {
return offset; return offset;
} }
@Override
public int getViewDistance() {
return 128;
}
} }

View file

@ -14,6 +14,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity.RemovalReason;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SimpleWaterloggedBlock; import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -29,8 +30,8 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
protected int initialOffset; protected int initialOffset;
private float prevAnimatedOffset; private float prevAnimatedOffset;
public PulleyTileEntity(BlockEntityType<? extends PulleyTileEntity> type) { public PulleyTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
@Override @Override
@ -38,11 +39,6 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
return super.makeRenderBoundingBox().expandTowards(0, -offset, 0); return super.makeRenderBoundingBox().expandTowards(0, -offset, 0);
} }
@Override
public double getViewDistance() {
return super.getViewDistance() + offset * offset;
}
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();
@ -157,7 +153,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
} }
if (movedContraption != null) if (movedContraption != null)
movedContraption.remove(); movedContraption.remove(RemovalReason.KILLED);
movedContraption = null; movedContraption = null;
initialOffset = 0; initialOffset = 0;
running = false; running = false;
@ -196,9 +192,9 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
initialOffset = compound.getInt("InitialOffset"); initialOffset = compound.getInt("InitialOffset");
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
} }
@Override @Override

View file

@ -9,13 +9,13 @@ import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager; import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl; import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
import com.jozufozu.flywheel.backend.pipeline.Template;
import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.Camera;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
public class ContraptionInstanceManager extends TileInstanceManager { public class ContraptionInstanceManager extends TileInstanceManager {
@ -33,7 +33,7 @@ public class ContraptionInstanceManager extends TileInstanceManager {
} }
@Override @Override
public void beginFrame(ActiveRenderInfo info) { public void beginFrame(Camera info) {
super.beginFrame(info); super.beginFrame(info);
actors.forEach(ActorInstance::beginFrame); actors.forEach(ActorInstance::beginFrame);
@ -45,8 +45,8 @@ public class ContraptionInstanceManager extends TileInstanceManager {
} }
@Nullable @Nullable
public ActorInstance createActor(Pair<Template.BlockInfo, MovementContext> actor) { public ActorInstance createActor(Pair<StructureBlockInfo, MovementContext> actor) {
Template.BlockInfo blockInfo = actor.getLeft(); StructureBlockInfo blockInfo = actor.getLeft();
MovementContext context = actor.getRight(); MovementContext context = actor.getRight();
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state); MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);

View file

@ -14,7 +14,7 @@ import com.jozufozu.flywheel.backend.model.ModelRenderer;
import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.core.model.IModel;
import com.jozufozu.flywheel.core.model.WorldModel; import com.jozufozu.flywheel.core.model.WorldModel;
import com.jozufozu.flywheel.event.BeginFrameEvent; import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f; import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3d; import com.mojang.math.Vector3d;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
@ -26,9 +26,9 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Mth;
import net.minecraft.util.math.MathHelper; import net.minecraft.world.level.Level;
import net.minecraft.world.World; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
public class RenderedContraption extends ContraptionRenderInfo { public class RenderedContraption extends ContraptionRenderInfo {
@ -89,7 +89,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
} }
@Override @Override
public void setupMatrices(MatrixStack viewProjection, double camX, double camY, double camZ) { public void setupMatrices(PoseStack viewProjection, double camX, double camY, double camZ) {
super.setupMatrices(viewProjection, camX, camY, camZ); super.setupMatrices(viewProjection, camX, camY, camZ);
if (!modelViewPartialReady) { if (!modelViewPartialReady) {
@ -139,16 +139,15 @@ public class RenderedContraption extends ContraptionRenderInfo {
} }
private void buildInstancedTiles() { private void buildInstancedTiles() {
Collection<TileEntity> tileEntities = contraption.maybeInstancedTileEntities; Collection<BlockEntity> tileEntities = contraption.maybeInstancedTileEntities;
if (!tileEntities.isEmpty()) { if (!tileEntities.isEmpty()) {
for (TileEntity te : tileEntities) { for (BlockEntity te : tileEntities) {
if (InstancedRenderRegistry.getInstance() if (InstancedRenderRegistry.getInstance()
.canInstance(te.getType())) { .canInstance(te.getType())) {
World world = te.getLevel(); Level world = te.getLevel();
BlockPos pos = te.getBlockPos(); te.setLevel(renderWorld);
te.setLevelAndPosition(renderWorld, pos);
kinetics.add(te); kinetics.add(te);
te.setLevelAndPosition(world, pos); te.setLevel(world);
} }
} }
} }
@ -159,9 +158,9 @@ public class RenderedContraption extends ContraptionRenderInfo {
} }
public static void setupModelViewPartial(Matrix4f matrix, Matrix4f modelMatrix, AbstractContraptionEntity entity, double camX, double camY, double camZ, float pt) { public static void setupModelViewPartial(Matrix4f matrix, Matrix4f modelMatrix, AbstractContraptionEntity entity, double camX, double camY, double camZ, float pt) {
float x = (float) (MathHelper.lerp(pt, entity.xOld, entity.getX()) - camX); float x = (float) (Mth.lerp(pt, entity.xOld, entity.getX()) - camX);
float y = (float) (MathHelper.lerp(pt, entity.yOld, entity.getY()) - camY); float y = (float) (Mth.lerp(pt, entity.yOld, entity.getY()) - camY);
float z = (float) (MathHelper.lerp(pt, entity.zOld, entity.getZ()) - camZ); float z = (float) (Mth.lerp(pt, entity.zOld, entity.getZ()) - camZ);
matrix.setTranslation(x, y, z); matrix.setTranslation(x, y, z);
matrix.multiply(modelMatrix); matrix.multiply(modelMatrix);
} }

View file

@ -2,3 +2,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render; package com.simibubi.create.content.contraptions.components.structureMovement.render;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -52,9 +52,9 @@ public class CouplingHandlerClient {
selectedCart = null; selectedCart = null;
} }
private static void spawnSelectionParticles(AABB axisAlignedBB, boolean highlight) { private static void spawnSelectionParticles(AABB AABB, boolean highlight) {
ClientLevel world = Minecraft.getInstance().level; ClientLevel world = Minecraft.getInstance().level;
Vec3 center = axisAlignedBB.getCenter(); Vec3 center = AABB.getCenter();
int amount = highlight ? 100 : 2; int amount = highlight ? 100 : 2;
ParticleOptions particleData = highlight ? ParticleTypes.END_ROD : new DustParticleOptions(1, 1, 1, 1); ParticleOptions particleData = highlight ? ParticleTypes.END_ROD : new DustParticleOptions(1, 1, 1, 1);
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {

View file

@ -1,6 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement.train; package com.simibubi.create.content.contraptions.components.structureMovement.train;
import static net.minecraft.util.math.MathHelpimport com.jozufozu.flywheel.util.transform.MatrixTransformStack; import static net.minecraft.util.Mth.lerp;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
@ -14,6 +16,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LevelRenderer;
@ -21,41 +24,12 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.vehicle.AbstractMinecart; import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
er.lerp;
import com.net.minecraft.util.MthatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
public class CouplingRenderer { public class CouplingRenderer {
public static void renderAll(PoseStack ms, MultiBufferSource buffer) { public static void renderAll(PoseStack ms, MultiBufferSource buffer) {
@ -149,8 +123,8 @@ public class CouplingRenderer {
double yIn = lerp(pt, cart.yOld, cart.getY()); double yIn = lerp(pt, cart.yOld, cart.getY());
double zIn = lerp(pt, cart.zOld, cart.getZ()); double zIn = lerp(pt, cart.zOld, cart.getZ());
float yaw = lerp(pt, cart.yRotO, cart.yRot); float yaw = lerp(pt, cart.yRotO, cart.getYRot());
float pitch = lerp(pt, cart.xRotO, cart.xRot); float pitch = lerp(pt, cart.xRotO, cart.getXRot());
float roll = cart.getHurtTime() - pt; float roll = cart.getHurtTime() - pt;
float rollAmplifier = cart.getDamage() - pt; float rollAmplifier = cart.getDamage() - pt;

View file

@ -87,7 +87,7 @@ public class MinecartCouplingItem extends Item {
CouplingHandler.status(player, "removed"); CouplingHandler.status(player, "removed");
controller.decouple(); controller.decouple();
if (!player.isCreative()) if (!player.isCreative())
player.inventory.placeItemBackInInventory(event.getWorld(), player.getInventory().placeItemBackInInventory(event.getWorld(),
new ItemStack(AllItems.MINECART_COUPLING.get(), couplings)); new ItemStack(AllItems.MINECART_COUPLING.get(), couplings));
return true; return true;
} }

View file

@ -1,13 +1,13 @@
package com.simibubi.create.content.contraptions.components.structureMovement.train; package com.simibubi.create.content.contraptions.components.structureMovement.train;
import static net.minecraft.entity.Entity.getHorizontalDistanceSqr; import java.util.Map;
importimport com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import java.util.Map;
import net.minecraft.Util; import net.minecraft.Util;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -19,25 +19,6 @@ import net.minecraft.world.level.block.BaseRailBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.LazyOptional;
javanet.minecraft.world.entity.Entityogle.common.collect.Maps;
import com.mojang.datafixers.util.Pair;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.item.minecart.FurnaceMinecartEntity;
import net.minecraft.state.properties.RailShape;
import net.minecraft.util.Direction;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
/** /**
@ -179,7 +160,7 @@ public class MinecartSim2020 {
if (Vector3d3 != null && actualVec != null) { if (Vector3d3 != null && actualVec != null) {
double d17 = (actualVec.y - Vector3d3.y) * 0.05D; double d17 = (actualVec.y - Vector3d3.y) * 0.05D;
Vec3 Vector3d4 = cart.getDeltaMovement(); Vec3 Vector3d4 = cart.getDeltaMovement();
double d18 = Math.sqrt(getHorizontalDistanceSqr(Vector3d4)); double d18 = Math.sqrt(Vector3d4.horizontalDistanceSqr());
if (d18 > 0.0D) { if (d18 > 0.0D) {
cart.setDeltaMovement(Vector3d4.multiply((d18 + d17) / d18, 1.0D, (d18 + d17) / d18)); cart.setDeltaMovement(Vector3d4.multiply((d18 + d17) / d18, 1.0D, (d18 + d17) / d18));
} }
@ -195,7 +176,7 @@ public class MinecartSim2020 {
int i = Mth.floor(z); int i = Mth.floor(z);
if (j != cartPos.getX() || i != cartPos.getZ()) { if (j != cartPos.getX() || i != cartPos.getZ()) {
Vec3 Vector3d5 = cart.getDeltaMovement(); Vec3 Vector3d5 = cart.getDeltaMovement();
double d26 = Math.sqrt(getHorizontalDistanceSqr(Vector3d5)); double d26 = Math.sqrt(Vector3d5.horizontalDistanceSqr());
cart.setDeltaMovement(d26 * (double) (j - cartPos.getX()), Vector3d5.y, d26 * (double) (i - cartPos.getZ())); cart.setDeltaMovement(d26 * (double) (j - cartPos.getX()), Vector3d5.y, d26 * (double) (i - cartPos.getZ()));
} }

View file

@ -398,16 +398,16 @@ public class MinecartController implements INBTSerializable<CompoundTag> {
StallData(AbstractMinecart entity) { StallData(AbstractMinecart entity) {
position = entity.position(); position = entity.position();
motion = entity.getDeltaMovement(); motion = entity.getDeltaMovement();
yaw = entity.yRot; yaw = entity.getYRot();
pitch = entity.xRot; pitch = entity.getXRot();
tick(entity); tick(entity);
} }
void tick(AbstractMinecart entity) { void tick(AbstractMinecart entity) {
entity.setPos(position.x, position.y, position.z); entity.setPos(position.x, position.y, position.z);
entity.setDeltaMovement(Vec3.ZERO); entity.setDeltaMovement(Vec3.ZERO);
entity.yRot = yaw; entity.setYRot(yaw);
entity.xRot = pitch; entity.setXRot(pitch);
} }
void release(AbstractMinecart entity) { void release(AbstractMinecart entity) {

View file

@ -1,14 +1,14 @@
package com.simibubi.create.content.contraptions.components.tracks; package com.simibubi.create.content.contraptions.components.tracks;
import static net.minecraft.state.properties.RailShape.NORTH_SOUTH; import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javanet.minimport com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -27,7 +27,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -35,44 +34,9 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
ecraft.world.level.block.state.properties.RailShapeotation.ParametersAreNonnullByDefault;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.VecHelper;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.item.minecart.FurnaceMinecartEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemUseContext;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.Property;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.RailShape;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault @MethodsReturnNonnullByDefault
public class ControllerRailBlock extends BaseRailBlock implements IWrenchable { public class ControllerRailBlock extends BaseRailBlock implements IWrenchable {
@ -86,7 +50,7 @@ public class ControllerRailBlock extends BaseRailBlock implements IWrenchable {
this.registerDefaultState(this.stateDefinition.any() this.registerDefaultState(this.stateDefinition.any()
.setValue(POWER, 0) .setValue(POWER, 0)
.setValue(BACKWARDS, false) .setValue(BACKWARDS, false)
.setValue(SHAPE, NORTH_SOUTH)); .setValue(SHAPE, RailShape.NORTH_SOUTH));
} }
public static Vec3i getAccelerationVector(BlockState state) { public static Vec3i getAccelerationVector(BlockState state) {

View file

@ -89,7 +89,7 @@ public class TurntableBlock extends KineticBlock implements ITE<TurntableTileEnt
e.hurtMarked = true; e.hurtMarked = true;
} }
e.yRot -= speed; e.setYRot(e.getYRot() - speed);
}); });
} }

View file

@ -39,8 +39,8 @@ public class TurntableHandler {
if (offset.length() > 1/4f) if (offset.length() > 1/4f)
speed *= Mth.clamp((1/2f - offset.length()) * 2, 0, 1); speed *= Mth.clamp((1/2f - offset.length()) * 2, 0, 1);
mc.player.yRot = mc.player.yRotO - speed * AnimationTickHolder.getPartialTicks(); mc.player.setYRot(mc.player.yRotO - speed * AnimationTickHolder.getPartialTicks());
mc.player.yBodyRot = mc.player.yRot; mc.player.yBodyRot = mc.player.getYRot();
} }
} }

View file

@ -2,12 +2,14 @@ package com.simibubi.create.content.contraptions.components.turntable;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
public class TurntableTileEntity extends KineticTileEntity { public class TurntableTileEntity extends KineticTileEntity {
public TurntableTileEntity(BlockEntityType<? extends TurntableTileEntity> type) { public TurntableTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
} }
} }

View file

@ -13,6 +13,7 @@ import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;

View file

@ -8,6 +8,7 @@ import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -18,8 +19,8 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity {
private Map<Direction, Float> flows; private Map<Direction, Float> flows;
public WaterWheelTileEntity(BlockEntityType<? extends WaterWheelTileEntity> type) { public WaterWheelTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type); super(type, pos, state);
flows = new HashMap<>(); flows = new HashMap<>();
for (Direction d : Iterate.directions) for (Direction d : Iterate.directions)
setFlow(d, 0); setFlow(d, 0);
@ -27,8 +28,8 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity {
} }
@Override @Override
protected void fromTag(BlockState state, CompoundTag compound, boolean clientPacket) { protected void fromTag(CompoundTag compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket); super.fromTag(compound, clientPacket);
if (compound.contains("Flows")) { if (compound.contains("Flows")) {
for (Direction d : Iterate.directions) for (Direction d : Iterate.directions)
setFlow(d, compound.getCompound("Flows") setFlow(d, compound.getCompound("Flows")

Some files were not shown because too many files have changed in this diff Show more