mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 14:33:57 +01:00
Port new changes
- Fix incompatible resource pack version
This commit is contained in:
parent
2700832dff
commit
d7a41b7810
@ -207,8 +207,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_east": "true"
|
||||
"sticky_east": "true",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
@ -217,8 +217,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_east": "true"
|
||||
"sticky_east": "true",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky",
|
||||
@ -227,8 +227,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_east": "true"
|
||||
"sticky_east": "true",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z_sticky"
|
||||
@ -236,8 +236,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_east": "false"
|
||||
"sticky_east": "false",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
@ -246,8 +246,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_east": "false"
|
||||
"sticky_east": "false",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y",
|
||||
@ -256,8 +256,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_east": "false"
|
||||
"sticky_east": "false",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z"
|
||||
|
@ -67,6 +67,8 @@
|
||||
"block.create.creative_crate": "Caja del Creativo",
|
||||
"block.create.creative_fluid_tank": "Tanque de Fluido del Creativo",
|
||||
"block.create.creative_motor": "Motor del Creativo",
|
||||
"block.create.crimson_window": "Ventana Carmesí",
|
||||
"block.create.crimson_window_pane": "Panel de Ventana Carmesí",
|
||||
"block.create.crushing_wheel": "Rueda Trituradora",
|
||||
"block.create.crushing_wheel_controller": "UNLOCALIZED:Crushing Wheel Controller",
|
||||
"block.create.cuckoo_clock": "Reloj Cuco",
|
||||
@ -384,6 +386,8 @@
|
||||
"block.create.turntable": "Mesa Giratoria",
|
||||
"block.create.vertical_framed_glass": "Vidrio Enmarcado Vertical",
|
||||
"block.create.vertical_framed_glass_pane": "Panel de Vidrio Enmarcado Vertical",
|
||||
"block.create.warped_window": "Ventana Distorsionada",
|
||||
"block.create.warped_window_pane": "Panel de ventana Distorsionada",
|
||||
"block.create.water_wheel": "Rueda Hidráulica",
|
||||
"block.create.weathered_limestone": "Caliza Meteorizada",
|
||||
"block.create.weathered_limestone_bricks": "Ladrillos de Caliza Meteorizada",
|
||||
|
@ -67,6 +67,8 @@
|
||||
"block.create.creative_crate": "創造板條箱",
|
||||
"block.create.creative_fluid_tank": "創造液體儲存罐",
|
||||
"block.create.creative_motor": "創造馬達",
|
||||
"block.create.crimson_window": "赤紅窗戶",
|
||||
"block.create.crimson_window_pane": "赤紅窗戶片",
|
||||
"block.create.crushing_wheel": "粉碎輪",
|
||||
"block.create.crushing_wheel_controller": "粉碎輪控制器",
|
||||
"block.create.cuckoo_clock": "布穀鳥鐘",
|
||||
@ -384,6 +386,8 @@
|
||||
"block.create.turntable": "轉盤",
|
||||
"block.create.vertical_framed_glass": "豎直邊框玻璃",
|
||||
"block.create.vertical_framed_glass_pane": "豎直邊框玻璃片",
|
||||
"block.create.warped_window": "扭曲蕈木窗戶",
|
||||
"block.create.warped_window_pane": "扭曲蕈木窗戶片",
|
||||
"block.create.water_wheel": "水車",
|
||||
"block.create.weathered_limestone": "風化石灰岩",
|
||||
"block.create.weathered_limestone_bricks": "風化石灰岩磚",
|
||||
|
@ -708,7 +708,7 @@ public class AllBlocks {
|
||||
boolean isFlipped = s.get(GantryShaftBlock.FACING)
|
||||
.getAxisDirection() == AxisDirection.NEGATIVE;
|
||||
String partName = s.get(GantryShaftBlock.PART)
|
||||
.getName();
|
||||
.getString();
|
||||
String flipped = isFlipped ? "_flipped" : "";
|
||||
String powered = isPowered ? "_powered" : "";
|
||||
ModelFile existing = AssetLookup.partialBaseModel(c, p, partName);
|
||||
|
@ -91,7 +91,7 @@ public class AllSpriteShifts {
|
||||
}
|
||||
|
||||
for (DyeColor color : DyeColor.values()) {
|
||||
String id = color.getName();
|
||||
String id = color.getString();
|
||||
DYED_BELTS.put(color, SpriteShifter.get("block/belt", "block/belt/" + id));
|
||||
DYED_OFFSET_BELTS.put(color, SpriteShifter.get("block/belt_offset", "block/belt/" + id));
|
||||
DYED_DIAGONAL_BELTS.put(color, SpriteShifter.get("block/belt_diagonal", "block/belt/" + id + "_diagonal"));
|
||||
|
@ -13,6 +13,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra
|
||||
import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler;
|
||||
import com.simibubi.create.content.palettes.AllPaletteBlocks;
|
||||
import com.simibubi.create.content.palettes.PalettesItemGroup;
|
||||
import com.simibubi.create.content.schematics.SchematicProcessor;
|
||||
import com.simibubi.create.content.schematics.ServerSchematicLoader;
|
||||
import com.simibubi.create.content.schematics.filtering.SchematicInstances;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
@ -114,6 +115,10 @@ public class Create {
|
||||
|
||||
AllPackets.registerPackets();
|
||||
AllTriggers.register();
|
||||
|
||||
event.enqueueWork(() -> {
|
||||
SchematicProcessor.register();
|
||||
});
|
||||
}
|
||||
|
||||
public static void onBiomeLoad(BiomeLoadingEvent event) {
|
||||
|
@ -89,11 +89,8 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||
@Override
|
||||
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
||||
|
||||
// TODO 1.16 is this the right replacement for updateNeighbors?
|
||||
@Override
|
||||
@Deprecated
|
||||
public void updateDiagonalNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) {
|
||||
super.updateDiagonalNeighbors(stateIn, worldIn, pos, flags, count);
|
||||
if (worldIn.isRemote())
|
||||
return;
|
||||
|
||||
|
@ -37,8 +37,8 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE<Enca
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags) {
|
||||
super.updateNeighbors(stateIn, worldIn, pos, flags);
|
||||
public void updateDiagonalNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) {
|
||||
super.updateDiagonalNeighbors(stateIn, worldIn, pos, flags, count);
|
||||
blockUpdate(stateIn, worldIn, pos);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
|
||||
|
||||
for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class,
|
||||
new AxisAlignedBB(pos.down()).shrink(.125f))) {
|
||||
if (!itemEntity.isAlive() || !itemEntity.onGround)
|
||||
if (!itemEntity.isAlive() || !itemEntity.isOnGround())
|
||||
continue;
|
||||
ItemStack stack = itemEntity.getItem();
|
||||
Optional<PressingRecipe> recipe = getRecipe(stack);
|
||||
@ -236,7 +236,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
|
||||
for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(null, bb)) {
|
||||
if (!(entity instanceof ItemEntity))
|
||||
continue;
|
||||
if (!entity.isAlive() || !entity.onGround)
|
||||
if (!entity.isAlive() || !entity.isOnGround())
|
||||
continue;
|
||||
ItemEntity itemEntity = (ItemEntity) entity;
|
||||
pressedItems.add(itemEntity.getItem());
|
||||
|
@ -21,7 +21,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@ -57,7 +57,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||
|
||||
checkPinionShaft();
|
||||
tickActors();
|
||||
Vec3d movementVec = getMotion();
|
||||
Vector3d movementVec = getMotion();
|
||||
|
||||
if (ContraptionCollider.collideBlocks(this)) {
|
||||
if (!world.isRemote)
|
||||
@ -73,15 +73,15 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||
}
|
||||
|
||||
protected void checkPinionShaft() {
|
||||
Vec3d movementVec;
|
||||
Vector3d movementVec;
|
||||
Direction facing = ((GantryContraption) contraption).getFacing();
|
||||
Vec3d currentPosition = getAnchorVec().add(.5, .5, .5);
|
||||
Vector3d currentPosition = getAnchorVec().add(.5, .5, .5);
|
||||
BlockPos gantryShaftPos = new BlockPos(currentPosition).offset(facing.getOpposite());
|
||||
|
||||
TileEntity te = world.getTileEntity(gantryShaftPos);
|
||||
if (!(te instanceof GantryShaftTileEntity) || !AllBlocks.GANTRY_SHAFT.has(te.getBlockState())) {
|
||||
if (!world.isRemote) {
|
||||
setContraptionMotion(Vec3d.ZERO);
|
||||
setContraptionMotion(Vector3d.ZERO);
|
||||
disassemble();
|
||||
}
|
||||
return;
|
||||
@ -92,16 +92,16 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||
GantryShaftTileEntity gantryShaftTileEntity = (GantryShaftTileEntity) te;
|
||||
|
||||
float pinionMovementSpeed = gantryShaftTileEntity.getPinionMovementSpeed();
|
||||
movementVec = new Vec3d(direction.getDirectionVec()).scale(pinionMovementSpeed);
|
||||
movementVec = Vector3d.of(direction.getDirectionVec()).scale(pinionMovementSpeed);
|
||||
|
||||
if (blockState.get(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) {
|
||||
setContraptionMotion(Vec3d.ZERO);
|
||||
setContraptionMotion(Vector3d.ZERO);
|
||||
if (!world.isRemote)
|
||||
disassemble();
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3d nextPosition = currentPosition.add(movementVec);
|
||||
Vector3d nextPosition = currentPosition.add(movementVec);
|
||||
double currentCoord = direction.getAxis()
|
||||
.getCoordinate(currentPosition.x, currentPosition.y, currentPosition.z);
|
||||
double nextCoord = direction.getAxis()
|
||||
@ -110,7 +110,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||
if ((MathHelper.floor(currentCoord) + .5f < nextCoord != (pinionMovementSpeed * direction.getAxisDirection()
|
||||
.getOffset() < 0)))
|
||||
if (!gantryShaftTileEntity.canAssembleOn()) {
|
||||
setContraptionMotion(Vec3d.ZERO);
|
||||
setContraptionMotion(Vector3d.ZERO);
|
||||
if (!world.isRemote)
|
||||
disassemble();
|
||||
return;
|
||||
@ -135,12 +135,12 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d applyRotation(Vec3d localPos, float partialTicks) {
|
||||
public Vector3d applyRotation(Vector3d localPos, float partialTicks) {
|
||||
return localPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d reverseRotation(Vec3d localPos, float partialTicks) {
|
||||
public Vector3d reverseRotation(Vector3d localPos, float partialTicks) {
|
||||
return localPos;
|
||||
}
|
||||
|
||||
@ -175,12 +175,12 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||
public void updateClientMotion() {
|
||||
float modifier = movementAxis.getAxisDirection()
|
||||
.getOffset();
|
||||
setContraptionMotion(new Vec3d(movementAxis.getDirectionVec())
|
||||
setContraptionMotion(Vector3d.of(movementAxis.getDirectionVec())
|
||||
.scale((axisMotion + clientOffsetDiff * modifier / 2f) * ServerSpeedProvider.get()));
|
||||
}
|
||||
|
||||
public double getAxisCoord() {
|
||||
Vec3d anchorVec = getAnchorVec();
|
||||
Vector3d anchorVec = getAnchorVec();
|
||||
return movementAxis.getAxis()
|
||||
.getCoordinate(anchorVec.x, anchorVec.y, anchorVec.z);
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ public class GantryPinionBlock extends DirectionalAxisKineticBlock implements IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags) {
|
||||
super.updateNeighbors(stateIn, worldIn, pos, flags);
|
||||
public void updateDiagonalNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) {
|
||||
super.updateDiagonalNeighbors(stateIn, worldIn, pos, flags, count);
|
||||
withTileEntityDo(worldIn, pos, GantryPinionTileEntity::checkValidGantryShaft);
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,12 @@ import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
||||
public class GantryPinionRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
|
@ -12,6 +12,7 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class ContraptionInteractionPacket extends SimplePacketBase {
|
||||
@ -54,7 +55,7 @@ public class ContraptionInteractionPacket extends SimplePacketBase {
|
||||
if (!(entityByID instanceof AbstractContraptionEntity))
|
||||
return;
|
||||
AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID;
|
||||
double d = sender.getAttribute(PlayerEntity.REACH_DISTANCE).getValue();
|
||||
double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue();
|
||||
if (!sender.canEntityBeSeen(entityByID))
|
||||
d -= 3;
|
||||
d *= d;
|
||||
|
@ -18,7 +18,7 @@ import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.Property;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -36,14 +36,14 @@ import net.minecraft.world.World;
|
||||
|
||||
public class GantryShaftBlock extends DirectionalKineticBlock {
|
||||
|
||||
public static final IProperty<Part> PART = EnumProperty.create("part", Part.class);
|
||||
public static final Property<Part> PART = EnumProperty.create("part", Part.class);
|
||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||
|
||||
public enum Part implements IStringSerializable {
|
||||
START, MIDDLE, END, SINGLE;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getString() {
|
||||
return Lang.asId(name());
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ public class BeltTileEntity extends KineticTileEntity {
|
||||
|
||||
@Override
|
||||
protected boolean canPropagateDiagonally(IRotate block, BlockState state) {
|
||||
return state.has(BeltBlock.SLOPE)
|
||||
return state.contains(BeltBlock.SLOPE)
|
||||
&& (state.get(BeltBlock.SLOPE) == BeltSlope.UPWARD || state.get(BeltBlock.SLOPE) == BeltSlope.DOWNWARD);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock {
|
||||
// .updateNeighbors(context.getWorld(), context.getPos(), 1);
|
||||
Axis axis = newState.get(AXIS);
|
||||
newState = getDefaultState().with(AXIS, axis);
|
||||
if (newState.has(BlockStateProperties.POWERED))
|
||||
if (newState.contains(BlockStateProperties.POWERED))
|
||||
newState = newState.with(BlockStateProperties.POWERED, context.getWorld()
|
||||
.isBlockPowered(context.getPos()));
|
||||
for (Direction facing : Iterate.directions) {
|
||||
|
@ -10,6 +10,7 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class ExtendoGripInteractionPacket extends SimplePacketBase {
|
||||
@ -60,7 +61,7 @@ public class ExtendoGripInteractionPacket extends SimplePacketBase {
|
||||
return;
|
||||
Entity entityByID = sender.getServerWorld().getEntityByID(target);
|
||||
if (entityByID != null && ExtendoGripItem.isHoldingExtendoGrip(sender)) {
|
||||
double d = sender.getAttribute(PlayerEntity.REACH_DISTANCE).getValue();
|
||||
double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue();
|
||||
if (!sender.canEntityBeSeen(entityByID))
|
||||
d -= 3;
|
||||
d *= d;
|
||||
|
@ -7,15 +7,15 @@ import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
public class SmartChuteFilterSlotPositioning extends ValueBoxTransform.Sided {
|
||||
|
||||
@Override
|
||||
protected Vec3d getLocalOffset(BlockState state) {
|
||||
protected Vector3d getLocalOffset(BlockState state) {
|
||||
Direction side = getSide();
|
||||
float horizontalAngle = AngleHelper.horizontalAngle(side);
|
||||
Vec3d southLocation = VecHelper.voxelSpace(8, 12, 15.5f);
|
||||
Vector3d southLocation = VecHelper.voxelSpace(8, 12, 15.5f);
|
||||
return VecHelper.rotateCentered(southLocation, horizontalAngle, Axis.Y);
|
||||
}
|
||||
|
||||
@ -26,8 +26,8 @@ public class SmartChuteFilterSlotPositioning extends ValueBoxTransform.Sided {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3d getSouthLocation() {
|
||||
return Vec3d.ZERO;
|
||||
protected Vector3d getSouthLocation() {
|
||||
return Vector3d.ZERO;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class SmartChuteTileEntity extends ChuteTileEntity {
|
||||
@Override
|
||||
protected boolean canCollectItemsFromBelow() {
|
||||
BlockState blockState = getBlockState();
|
||||
return blockState.has(SmartChuteBlock.POWERED) && !blockState.get(SmartChuteBlock.POWERED);
|
||||
return blockState.contains(SmartChuteBlock.POWERED) && !blockState.get(SmartChuteBlock.POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,128 +0,0 @@
|
||||
package com.simibubi.create.content.logistics.block.funnel;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class HorizontalInteractionFunnelBlock extends HorizontalBlock implements IWrenchable {
|
||||
|
||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||
public static final BooleanProperty PUSHING = BooleanProperty.create("pushing");
|
||||
private BlockEntry<? extends FunnelBlock> parent;
|
||||
|
||||
public HorizontalInteractionFunnelBlock(BlockEntry<? extends FunnelBlock> parent, Properties p_i48377_1_) {
|
||||
super(p_i48377_1_);
|
||||
this.parent = parent;
|
||||
BlockState defaultState = getDefaultState().with(PUSHING, true);
|
||||
if (hasPoweredProperty())
|
||||
defaultState = defaultState.with(POWERED, false);
|
||||
setDefaultState(defaultState);
|
||||
}
|
||||
|
||||
public abstract boolean hasPoweredProperty();
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return AllTileEntities.FUNNEL.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(Builder<Block, BlockState> p_206840_1_) {
|
||||
if (hasPoweredProperty())
|
||||
p_206840_1_.add(POWERED);
|
||||
super.fillStateContainer(p_206840_1_.add(HORIZONTAL_FACING, PUSHING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
|
||||
BlockState stateForPlacement = super.getStateForPlacement(ctx);
|
||||
if (hasPoweredProperty())
|
||||
stateForPlacement = stateForPlacement.with(POWERED, ctx.getWorld()
|
||||
.isBlockPowered(ctx.getPos()));
|
||||
return stateForPlacement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_,
|
||||
boolean p_196243_5_) {
|
||||
if (p_196243_1_.hasTileEntity()
|
||||
&& (p_196243_1_.getBlock() != p_196243_4_.getBlock() && !FunnelBlock.isFunnel(p_196243_4_)
|
||||
|| !p_196243_4_.hasTileEntity())) {
|
||||
p_196243_2_.removeTileEntity(p_196243_3_);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
|
||||
PlayerEntity player) {
|
||||
return parent.asStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction direction, BlockState neighbour, IWorld world,
|
||||
BlockPos pos, BlockPos p_196271_6_) {
|
||||
if (!canStillInteract(state, world, pos)) {
|
||||
BlockState parentState = parent.getDefaultState();
|
||||
if (state.method_28500(POWERED).orElse(false))
|
||||
parentState = parentState.with(POWERED, true);
|
||||
return parentState.with(FunnelBlock.FACING, state.get(HORIZONTAL_FACING));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) {
|
||||
return !world.getBlockState(pos.offset(state.get(HORIZONTAL_FACING)
|
||||
.getOpposite()))
|
||||
.getShape(world, pos)
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
protected abstract boolean canStillInteract(BlockState state, IWorldReader world, BlockPos pos);
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
if (!hasPoweredProperty())
|
||||
return;
|
||||
if (worldIn.isRemote)
|
||||
return;
|
||||
boolean previouslyPowered = state.get(POWERED);
|
||||
if (previouslyPowered != worldIn.isBlockPowered(pos))
|
||||
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||
if (!context.getWorld().isRemote)
|
||||
context.getWorld()
|
||||
.setBlockState(context.getPos(), state.cycle(PUSHING));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
package com.simibubi.create.content.schematics;
|
||||
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
import com.mojang.datafixers.types.DynamicOps;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.simibubi.create.foundation.utility.NBTProcessors;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
@ -16,15 +19,22 @@ import net.minecraft.world.gen.feature.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.feature.template.StructureProcessor;
|
||||
import net.minecraft.world.gen.feature.template.Template;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SchematicProcessor extends StructureProcessor {
|
||||
|
||||
public static final SchematicProcessor INSTANCE = new SchematicProcessor();
|
||||
|
||||
public static final Codec<SchematicProcessor> CODEC = Codec.unit(() -> {
|
||||
return INSTANCE;
|
||||
});
|
||||
|
||||
public static IStructureProcessorType<SchematicProcessor> TYPE;
|
||||
|
||||
public static void register() {
|
||||
TYPE = IStructureProcessorType.register("schematic", CODEC);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Template.BlockInfo process(IWorldReader world, BlockPos pos, Template.BlockInfo rawInfo,
|
||||
public Template.BlockInfo process(IWorldReader world, BlockPos pos, BlockPos anotherPos, Template.BlockInfo rawInfo,
|
||||
Template.BlockInfo info, PlacementSettings settings, @Nullable Template template) {
|
||||
if (info.nbt != null) {
|
||||
TileEntity te = info.state.createTileEntity(world);
|
||||
@ -53,12 +63,8 @@ public class SchematicProcessor extends StructureProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IStructureProcessorType getType() {
|
||||
return dynamic -> INSTANCE;
|
||||
protected IStructureProcessorType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> Dynamic<T> serialize0(DynamicOps<T> ops) {
|
||||
return new Dynamic<>(ops, ops.emptyMap());
|
||||
}
|
||||
}
|
||||
|
@ -61,11 +61,7 @@ public class SchematicInstances {
|
||||
.getCompound("Anchor"));
|
||||
SchematicWorld world = new SchematicWorld(anchor, wrapped);
|
||||
PlacementSettings settings = SchematicItem.getSettings(schematic);
|
||||
activeTemplate.addBlocksToWorld(world, anchor, settings);
|
||||
|
||||
Debug.debugChat("Loading Schematic Instance of " + schematic.getTag()
|
||||
.getString("File") + ". Total active instances: " + (loadedSchematics.get(wrapped).size() + 1));
|
||||
|
||||
activeTemplate.place(world, anchor, settings, wrapped.getRandom());
|
||||
|
||||
return world;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "create resources",
|
||||
"pack_format": 5
|
||||
"pack_format": 6
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user