diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 8f1dae6d2..c4f51771a 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -1,13 +1,13 @@ package com.simibubi.create; -import com.simibubi.create.foundation.block.IRenderUtilityBlock; +import com.simibubi.create.foundation.block.IWithoutBlockItem; import com.simibubi.create.foundation.block.RenderUtilityBlock; import com.simibubi.create.modules.kinetics.base.HalfAxisBlock; import com.simibubi.create.modules.kinetics.generators.MotorBlock; import com.simibubi.create.modules.kinetics.receivers.TurntableBlock; import com.simibubi.create.modules.kinetics.relays.AxisBlock; import com.simibubi.create.modules.kinetics.relays.AxisTunnelBlock; -import com.simibubi.create.modules.kinetics.relays.BeltPulleyBlock; +import com.simibubi.create.modules.kinetics.relays.BeltBlock; import com.simibubi.create.modules.kinetics.relays.CogWheelBlock; import com.simibubi.create.modules.kinetics.relays.GearboxBlock; import com.simibubi.create.modules.kinetics.relays.GearshifterBlock; @@ -41,8 +41,8 @@ public enum AllBlocks { LARGE_GEAR(new CogWheelBlock(true)), AXIS_TUNNEL(new AxisTunnelBlock()), GEARSHIFTER(new GearshifterBlock()), - BELT_PULLEY(new BeltPulleyBlock()), - BELT(new RenderUtilityBlock()), + BELT(new BeltBlock()), + BELT_ANIMATION(new RenderUtilityBlock()), TURNTABLE(new TurntableBlock()), HALF_AXIS(new HalfAxisBlock()), @@ -71,7 +71,7 @@ public enum AllBlocks { public static void registerItemBlocks(IForgeRegistry registry) { for (AllBlocks block : values()) { - if (block.get() instanceof IRenderUtilityBlock) + if (block.get() instanceof IWithoutBlockItem) continue; registry.register(new BlockItem(block.get(), AllItems.standardProperties()) diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index e2fceec77..f4bd4d005 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -5,7 +5,6 @@ import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunItem; import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunItemRenderer; import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunModel; import com.simibubi.create.modules.kinetics.relays.BeltItem; -import com.simibubi.create.modules.kinetics.relays.BeltPulleyTileEntityRenderer; import com.simibubi.create.modules.schematics.item.BlueprintAndQuillItem; import com.simibubi.create.modules.schematics.item.BlueprintItem; import com.simibubi.create.modules.symmetry.SymmetryWandItem; @@ -18,9 +17,9 @@ import net.minecraft.client.renderer.model.ModelRotation; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.item.Item; import net.minecraft.item.Item.Properties; +import net.minecraft.util.ResourceLocation; import net.minecraft.item.ItemStack; import net.minecraft.item.Rarity; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.ModelBakeEvent; @@ -45,7 +44,7 @@ public enum AllItems { BLUEPRINT_AND_QUILL(new BlueprintAndQuillItem(standardProperties().maxStackSize(1))), BLUEPRINT(new BlueprintItem(standardProperties())), - BELT(new BeltItem(standardProperties())), + BELT_CONNECTOR(new BeltItem(standardProperties())), ; @@ -94,9 +93,6 @@ public enum AllItems { ModelResourceLocation handgunLocation = getModelLocation(PLACEMENT_HANDGUN); template = event.getModelRegistry().get(handgunLocation); event.getModelRegistry().put(handgunLocation, new BuilderGunModel(template).loadPartials(event)); - - BeltPulleyTileEntityRenderer.beltModel = event.getModelLoader() - .func_217845_a(new ResourceLocation(Create.ID, "block/belt"), ModelRotation.X0_Y0); } protected static ModelResourceLocation getModelLocation(AllItems item) { diff --git a/src/main/java/com/simibubi/create/AllSpecialTextures.java b/src/main/java/com/simibubi/create/AllSpecialTextures.java index 07ec79251..88ed6a813 100644 --- a/src/main/java/com/simibubi/create/AllSpecialTextures.java +++ b/src/main/java/com/simibubi/create/AllSpecialTextures.java @@ -2,7 +2,10 @@ package com.simibubi.create; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +@EventBusSubscriber(value = Dist.CLIENT) public enum AllSpecialTextures { Selection("selection.png"), diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 1146a63eb..0f11318c4 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -9,8 +9,8 @@ import com.simibubi.create.modules.kinetics.receivers.TurntableTileEntity; import com.simibubi.create.modules.kinetics.relays.AxisTileEntity; import com.simibubi.create.modules.kinetics.relays.AxisTunnelTileEntity; import com.simibubi.create.modules.kinetics.relays.AxisTunnelTileEntityRenderer; -import com.simibubi.create.modules.kinetics.relays.BeltPulleyTileEntity; -import com.simibubi.create.modules.kinetics.relays.BeltPulleyTileEntityRenderer; +import com.simibubi.create.modules.kinetics.relays.BeltTileEntity; +import com.simibubi.create.modules.kinetics.relays.BeltTileEntityRenderer; import com.simibubi.create.modules.kinetics.relays.GearboxTileEntity; import com.simibubi.create.modules.kinetics.relays.GearboxTileEntityRenderer; import com.simibubi.create.modules.kinetics.relays.GearshifterTileEntity; @@ -46,7 +46,7 @@ public enum AllTileEntities { TURNTABLE(TurntableTileEntity::new, AllBlocks.TURNTABLE), AXIS_TUNNEL(AxisTunnelTileEntity::new, AllBlocks.AXIS_TUNNEL), GEARSHIFTER(GearshifterTileEntity::new, AllBlocks.GEARSHIFTER), - BELT_PULLEY(BeltPulleyTileEntity::new, AllBlocks.BELT_PULLEY), + BELT(BeltTileEntity::new, AllBlocks.BELT), ; @@ -83,7 +83,7 @@ public enum AllTileEntities { bind(AxisTunnelTileEntity.class, new AxisTunnelTileEntityRenderer()); bind(GearboxTileEntity.class, new GearboxTileEntityRenderer()); bind(GearshifterTileEntity.class, new GearshifterTileEntityRenderer()); - bind(BeltPulleyTileEntity.class, new BeltPulleyTileEntityRenderer()); + bind(BeltTileEntity.class, new BeltTileEntityRenderer()); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/foundation/block/IRenderUtilityBlock.java b/src/main/java/com/simibubi/create/foundation/block/IRenderUtilityBlock.java index 9757cd295..da73fdf92 100644 --- a/src/main/java/com/simibubi/create/foundation/block/IRenderUtilityBlock.java +++ b/src/main/java/com/simibubi/create/foundation/block/IRenderUtilityBlock.java @@ -3,6 +3,6 @@ package com.simibubi.create.foundation.block; /** * Blocks only registered for use in other blocks' renderers. */ -public interface IRenderUtilityBlock { +public interface IRenderUtilityBlock extends IWithoutBlockItem { } diff --git a/src/main/java/com/simibubi/create/foundation/block/IWithoutBlockItem.java b/src/main/java/com/simibubi/create/foundation/block/IWithoutBlockItem.java new file mode 100644 index 000000000..6c01df08b --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/block/IWithoutBlockItem.java @@ -0,0 +1,8 @@ +package com.simibubi.create.foundation.block; + +/** + * Blocks only registered for use outside of the inventory + */ +public interface IWithoutBlockItem { + +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/BufferManipulator.java b/src/main/java/com/simibubi/create/foundation/utility/BufferManipulator.java new file mode 100644 index 000000000..8ee1dad37 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/BufferManipulator.java @@ -0,0 +1,65 @@ +package com.simibubi.create.foundation.utility; + +import java.nio.ByteBuffer; +import java.util.function.Consumer; + +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.Direction.Axis; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; + +public abstract class BufferManipulator { + + protected ByteBuffer original; + protected ByteBuffer mutable; + + public BufferManipulator(ByteBuffer original) { + original.rewind(); + this.original = original; + + this.mutable = GLAllocation.createDirectByteBuffer(original.capacity()); + this.mutable.order(original.order()); + this.mutable.limit(original.limit()); + mutable.put(this.original); + mutable.rewind(); + } + + protected void forEachVertex(ByteBuffer buffer, Consumer consumer) { + final int formatLength = DefaultVertexFormats.BLOCK.getSize(); + for (int i = 0; i < buffer.limit() / formatLength; i++) { + final int position = i * formatLength; + consumer.accept(position); + } + } + + protected Vec3d getPos(ByteBuffer buffer, int vertex) { + return new Vec3d(buffer.getFloat(vertex), buffer.getFloat(vertex + 4), buffer.getFloat(vertex + 8)); + } + + protected void putPos(ByteBuffer buffer, int vertex, Vec3d pos) { + buffer.putFloat(vertex, (float) pos.x); + buffer.putFloat(vertex + 4, (float) pos.y); + buffer.putFloat(vertex + 8, (float) pos.z); + } + + protected Vec3d rotatePos(Vec3d pos, float angle, Axis axis) { + return rotatePos(pos, MathHelper.sin(angle), MathHelper.cos(angle), axis); + } + + protected Vec3d rotatePos(Vec3d pos, float sin, float cos, Axis axis) { + final float x = (float) pos.x; + final float y = (float) pos.y; + final float z = (float) pos.z; + + if (axis == Axis.X) + return new Vec3d(x, y * cos - z * sin, z * cos + y * sin); + if (axis == Axis.Y) + return new Vec3d(x * cos + z * sin, y, z * cos - x * sin); + if (axis == Axis.Z) + return new Vec3d(x * cos - y * sin, y * cos + x * sin, z); + + return pos; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/kinetics/RotationPropagator.java b/src/main/java/com/simibubi/create/modules/kinetics/RotationPropagator.java index 5e2358c44..446aebe91 100644 --- a/src/main/java/com/simibubi/create/modules/kinetics/RotationPropagator.java +++ b/src/main/java/com/simibubi/create/modules/kinetics/RotationPropagator.java @@ -6,6 +6,7 @@ import java.util.List; import com.simibubi.create.AllBlocks; import com.simibubi.create.modules.kinetics.base.IRotate; import com.simibubi.create.modules.kinetics.base.KineticTileEntity; +import com.simibubi.create.modules.kinetics.relays.BeltTileEntity; import com.simibubi.create.modules.kinetics.relays.GearboxTileEntity; import com.simibubi.create.modules.kinetics.relays.GearshifterTileEntity; @@ -43,6 +44,11 @@ public class RotationPropagator { boolean connectedByGears = definitionFrom.isGearTowards(world, from.getPos(), stateFrom, direction) && definitionTo.isGearTowards(world, to.getPos(), stateTo, direction.getOpposite()); + // Belt <-> Belt + if (from instanceof BeltTileEntity && to instanceof BeltTileEntity && !connectedByAxis) { + return ((BeltTileEntity) from).getController().equals(((BeltTileEntity) to).getController()) ? 1 : 0; + } + // Gearbox <-> Gearbox if (from instanceof GearboxTileEntity && to instanceof GearboxTileEntity) return 0; @@ -273,14 +279,15 @@ public class RotationPropagator { if (!te.getWorld().isAreaLoaded(te.getPos(), 1)) return neighbours; - for (Direction facing : Direction.values()) { + for (Direction facing : Direction.values()) neighbours.add(te.getPos().offset(facing)); - } - // gears can interface diagonally + // Some Blocks can interface diagonally BlockState blockState = te.getBlockState(); - if (AllBlocks.GEAR.typeOf(blockState) || AllBlocks.LARGE_GEAR.typeOf(blockState)) { - Axis axis = blockState.get(BlockStateProperties.AXIS); + if (AllBlocks.GEAR.typeOf(blockState) || AllBlocks.LARGE_GEAR.typeOf(blockState) + || AllBlocks.BELT.typeOf(blockState)) { + Axis axis = ((IRotate) blockState.getBlock()).getRotationAxis(blockState); + BlockPos.getAllInBox(new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1)).forEach(offset -> { if (axis.getCoordinate(offset.getX(), offset.getY(), offset.getZ()) != 0) return; diff --git a/src/main/java/com/simibubi/create/modules/kinetics/base/KineticBlock.java b/src/main/java/com/simibubi/create/modules/kinetics/base/KineticBlock.java index e5bd1afb5..d320d1a30 100644 --- a/src/main/java/com/simibubi/create/modules/kinetics/base/KineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/kinetics/base/KineticBlock.java @@ -59,7 +59,10 @@ public abstract class KineticBlock extends Block implements IRotate { @Override public void updateNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags) { - RotationPropagator.handleAdded(worldIn.getWorld(), pos, (KineticTileEntity) worldIn.getTileEntity(pos)); + KineticTileEntity tileEntity = (KineticTileEntity) worldIn.getTileEntity(pos); + if (tileEntity == null) + return; + RotationPropagator.handleAdded(worldIn.getWorld(), pos, tileEntity); } @Override diff --git a/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntity.java index 20c45a992..196d73d27 100644 --- a/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntity.java @@ -21,8 +21,8 @@ public abstract class KineticTileEntity extends SyncedTileEntity { public KineticTileEntity(TileEntityType typeIn) { super(typeIn); - setSpeed(0); - setForce(0); + speed = 0; + force = 0; source = Optional.empty(); } @@ -86,15 +86,8 @@ public abstract class KineticTileEntity extends SyncedTileEntity { } public void setSpeed(float speed) { - -// if (hasWorld()) -// Minecraft.getInstance().player.sendStatusMessage( -// new StringTextComponent((getWorld().isRemote ? TextFormatting.RED : TextFormatting.GREEN) -// + "" + getClass().getSimpleName() + getPos().toString() + " to " + speed), -// false); - this.speed = speed; - if (hasWorld() && speed != 0) { + if (hasWorld() && speed != 0 && world.isRemote) { Random r = getWorld().rand; for (int i = 0; i < 10; i++) { float x = getPos().getX() + (r.nextFloat() - .5f) / 2f + .5f; diff --git a/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntityRenderer.java index 2511da036..9459e3545 100644 --- a/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/kinetics/base/KineticTileEntityRenderer.java @@ -4,44 +4,39 @@ import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; import java.util.Random; +import java.util.function.Function; import org.lwjgl.opengl.GL11; import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.utility.BufferManipulator; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockModelRenderer; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.model.animation.Animation; import net.minecraftforge.client.model.animation.TileEntityRendererFast; import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +@EventBusSubscriber(value = Dist.CLIENT) public class KineticTileEntityRenderer extends TileEntityRendererFast { - protected static Map cachedBuffers; + protected static Map cachedBuffers; - protected class CachedByteBuffer { - ByteBuffer original; - ByteBuffer mutable; + protected class BlockModelSpinner extends BufferManipulator { - public CachedByteBuffer(ByteBuffer original) { - original.rewind(); - this.original = original; - - this.mutable = GLAllocation.createDirectByteBuffer(original.capacity()); - this.mutable.order(original.order()); - this.mutable.limit(original.limit()); - mutable.put(this.original); - mutable.rewind(); + public BlockModelSpinner(ByteBuffer original) { + super(original); } public ByteBuffer getTransformed(Vec3d translation, float angle, Axis axis, int packedLightCoords) { @@ -49,38 +44,14 @@ public class KineticTileEntityRenderer extends TileEntityRendererFast { + final Vec3d vertex = getPos(original, index).subtract(half); + putPos(mutable, index, rotatePos(vertex, sin, cos, axis).add(translation).add(half)); + mutable.putInt(index + 24, packedLightCoords); + }); - float xr = x; - float yr = y; - float zr = z; - - if (axis == Axis.X) { - yr = y * cos - z * sin; - zr = z * cos + y * sin; - } - - if (axis == Axis.Y) { - xr = x * cos + z * sin; - zr = z * cos - x * sin; - } - - if (axis == Axis.Z) { - yr = y * cos + x * sin; - xr = x * cos - y * sin; - } - - mutable.putFloat(position, (float) (xr + translation.x + .5f)); - mutable.putFloat(position + 4, (float) (yr + translation.y + .5f)); - mutable.putFloat(position + 8, (float) (zr + translation.z + .5f)); - mutable.putInt(position + 24, packedLightCoords); - } return mutable; } } @@ -94,7 +65,7 @@ public class KineticTileEntityRenderer extends TileEntityRendererFast factory) { if (!cachedBuffers.containsKey(state)) { BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); @@ -125,7 +97,7 @@ public class KineticTileEntityRenderer extends TileEntityRendererFast SLOPE = EnumProperty.create("slope", Slope.class); + public static final IProperty PART = EnumProperty.create("part", Part.class); + + public BeltBlock() { + super(Properties.from(Blocks.BROWN_WOOL)); + setDefaultState(getDefaultState().with(SLOPE, Slope.HORIZONTAL).with(PART, Part.START)); + } + + @Override + protected void fillStateContainer(Builder builder) { + builder.add(SLOPE, PART); + super.fillStateContainer(builder); + } + + @Override + public boolean hasTileEntity(BlockState state) { + return true; + } + + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return new BeltTileEntity(); + } + + @Override + protected boolean hasStaticPart() { + return false; + } + + @Override + public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + if (worldIn.isRemote) + return; + TileEntity tileEntity = worldIn.getTileEntity(pos); + if (tileEntity == null) + return; + if (!(tileEntity instanceof BeltTileEntity)) + return; + BeltTileEntity beltEntity = (BeltTileEntity) tileEntity; + BlockPos controller = beltEntity.getController(); + beltEntity.setSource(null); + beltEntity.remove(); + + int limit = 1000; + BlockPos toDestroy = controller; + BlockState destroyedBlock = null; + + do { + + if (!toDestroy.equals(pos)) { + destroyedBlock = worldIn.getBlockState(toDestroy); + if (!AllBlocks.BELT.typeOf(destroyedBlock)) + break; + + BeltTileEntity te = (BeltTileEntity) worldIn.getTileEntity(toDestroy); + boolean hasPulley = te.hasPulley(); + te.setSource(null); + te.remove(); + + if (hasPulley) { + worldIn.setBlockState(toDestroy, AllBlocks.AXIS.get().getDefaultState() + .with(BlockStateProperties.AXIS, getRotationAxis(destroyedBlock)), 3); + } else { + worldIn.destroyBlock(toDestroy, false); + } + + if (destroyedBlock.get(PART) == Part.END) + break; + } + + Slope slope = state.get(SLOPE); + Direction direction = state.get(HORIZONTAL_FACING); + + if (slope == Slope.VERTICAL) { + toDestroy = toDestroy.up(direction.getAxisDirection() == AxisDirection.POSITIVE ? 1 : -1); + continue; + } + + toDestroy = toDestroy.offset(direction); + if (slope != Slope.HORIZONTAL) + toDestroy = toDestroy.up(slope == Slope.UPWARD ? 1 : -1); + + } while (limit-- > 0); + + } + + @Override + public boolean isAxisTowards(World world, BlockPos pos, BlockState state, Direction face) { + if (face.getAxis() != getRotationAxis(state)) + return false; + BeltTileEntity beltEntity = (BeltTileEntity) world.getTileEntity(pos); + return beltEntity != null && beltEntity.hasPulley(); + } + + @Override + public Axis getRotationAxis(BlockState state) { + return state.get(HORIZONTAL_FACING).getAxis() == Axis.X ? Axis.Z : Axis.X; + } + + public enum Slope implements IStringSerializable { + HORIZONTAL, UPWARD, DOWNWARD, VERTICAL; + + @Override + public String getName() { + return name().toLowerCase(); + } + } + + public enum Part implements IStringSerializable { + START, MIDDLE, END; + + @Override + public String getName() { + return name().toLowerCase(); + } + } + + public static List getBeltChain(World world, BlockPos controllerPos) { + List positions = new LinkedList<>(); + + BlockState blockState = world.getBlockState(controllerPos); + if (!AllBlocks.BELT.typeOf(blockState)) + return positions; + + Slope slope = blockState.get(SLOPE); + Direction direction = blockState.get(HORIZONTAL_FACING); + + int limit = 1000; + BlockPos current = controllerPos; + do { + positions.add(current); + + if (!AllBlocks.BELT.typeOf(world.getBlockState(current))) + break; + if (world.getBlockState(current).get(PART) == Part.END) + break; + if (slope == Slope.VERTICAL) { + current = current.up(direction.getAxisDirection() == AxisDirection.POSITIVE ? 1 : -1); + continue; + } + current = current.offset(direction); + if (slope != Slope.HORIZONTAL) + current = current.up(slope == Slope.UPWARD ? 1 : -1); + } while (limit-- > 0); + + return positions; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltItem.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltItem.java index cd365edda..d22a54e8e 100644 --- a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltItem.java +++ b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltItem.java @@ -1,14 +1,23 @@ package com.simibubi.create.modules.kinetics.relays; -import com.simibubi.create.AllBlocks; +import java.util.LinkedList; +import java.util.List; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.modules.kinetics.base.KineticTileEntity; +import com.simibubi.create.modules.kinetics.relays.BeltBlock.Part; +import com.simibubi.create.modules.kinetics.relays.BeltBlock.Slope; + +import net.minecraft.block.BlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.state.properties.BlockStateProperties; 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.math.BlockPos; import net.minecraft.world.World; @@ -50,11 +59,8 @@ public class BeltItem extends Item { return ActionResultType.FAIL; if (!firstPulley.equals(pos)) { - makePulley(world, firstPulley); - makePulley(world, pos); - connectPulley(world, firstPulley, pos, true); - connectPulley(world, pos, firstPulley, false); - + createBelts(world, firstPulley, pos); + if (!context.getPlayer().isCreative()) context.getItem().shrink(1); } @@ -73,19 +79,81 @@ public class BeltItem extends Item { return ActionResultType.SUCCESS; } - private void makePulley(World world, BlockPos pos) { - world.setBlockState(pos, AllBlocks.BELT_PULLEY.get().getDefaultState().with(BlockStateProperties.AXIS, - world.getBlockState(pos).get(BlockStateProperties.AXIS))); - } - - private void connectPulley(World world, BlockPos pos, BlockPos target, boolean controller) { - BeltPulleyTileEntity te = (BeltPulleyTileEntity) world.getTileEntity(pos); - if (te != null) { - te.setController(controller); - te.setTarget(target); + private void createBelts(World world, BlockPos start, BlockPos end) { + + BeltBlock.Slope slope = getSlopeBetween(start, end); + Direction facing = getFacingFromTo(start, end); + + BlockPos diff = end.subtract(start); + if (diff.getX() == diff.getZ()) + facing = Direction.getFacingFromAxis(facing.getAxisDirection(), + world.getBlockState(start).get(BlockStateProperties.AXIS) == Axis.X ? Axis.Z : Axis.X); + + List beltsToCreate = getBeltChainBetween(start, end, slope, facing); + BlockState beltBlock = AllBlocks.BELT.get().getDefaultState(); + + for (BlockPos pos : beltsToCreate) { + BeltBlock.Part part = pos.equals(start) ? Part.START : pos.equals(end) ? Part.END : Part.MIDDLE; + world.setBlockState(pos, beltBlock.with(BeltBlock.SLOPE, slope).with(BeltBlock.PART, part) + .with(BeltBlock.HORIZONTAL_FACING, facing), 3); + connectBelt(world, pos, start); } } + private Direction getFacingFromTo(BlockPos start, BlockPos end) { + Axis beltAxis = start.getX() == end.getX() ? Axis.Z : Axis.X; + BlockPos diff = end.subtract(start); + AxisDirection axisDirection = AxisDirection.POSITIVE; + + if (diff.getX() == 0 && diff.getZ() == 0) + axisDirection = diff.getY() > 0 ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; + else + axisDirection = beltAxis.getCoordinate(diff.getX(), 0, diff.getZ()) > 0 ? AxisDirection.POSITIVE + : AxisDirection.NEGATIVE; + + return Direction.getFacingFromAxis(axisDirection, beltAxis); + } + + private Slope getSlopeBetween(BlockPos start, BlockPos end) { + BlockPos diff = end.subtract(start); + + if (diff.getY() != 0) { + if (diff.getZ() != 0 || diff.getX() != 0) + return diff.getY() > 0 ? Slope.UPWARD : Slope.DOWNWARD; + return Slope.VERTICAL; + } + return Slope.HORIZONTAL; + } + + private List getBeltChainBetween(BlockPos start, BlockPos end, Slope slope, Direction direction) { + List positions = new LinkedList<>(); + int limit = 1000; + BlockPos current = start; + + do { + positions.add(current); + + if (slope == Slope.VERTICAL) { + current = current.up(direction.getAxisDirection() == AxisDirection.POSITIVE ? 1 : -1); + continue; + } + + current = current.offset(direction); + if (slope != Slope.HORIZONTAL) + current = current.up(slope == Slope.UPWARD ? 1 : -1); + + } while (!current.equals(end) && limit-- > 0); + + positions.add(end); + return positions; + } + + private void connectBelt(World world, BlockPos pos, BlockPos target) { + BeltTileEntity te = (BeltTileEntity) world.getTileEntity(pos); + if (te != null) + te.setController(target); + } + private boolean canConnect(World world, BlockPos first, BlockPos second) { if (!world.isAreaLoaded(first, 1)) return false; @@ -96,12 +164,25 @@ public class BeltItem extends Item { BlockPos diff = second.subtract(first); Axis axis = world.getBlockState(first).get(BlockStateProperties.AXIS); - - if (axis.getCoordinate(diff.getX(), diff.getY(), diff.getZ()) != 0) + + int x = diff.getX(); + int y = diff.getY(); + int z = diff.getZ(); + int sames = ((Math.abs(x) == Math.abs(y)) ? 1 : 0) + ((Math.abs(y) == Math.abs(z)) ? 1 : 0) + + ((Math.abs(z) == Math.abs(x)) ? 1 : 0); + + if (axis.getCoordinate(x, y, z) != 0) + return false; + if (sames != 1) return false; if (axis != world.getBlockState(second).get(BlockStateProperties.AXIS)) return false; + float speed1 = ((KineticTileEntity) world.getTileEntity(first)).getSpeed(); + float speed2 = ((KineticTileEntity) world.getTileEntity(second)).getSpeed(); + if (speed1 != speed2 && speed1 != 0 && speed2 != 0) + return false; + return true; } @@ -110,6 +191,8 @@ public class BeltItem extends Item { return false; if (!AllBlocks.AXIS.typeOf(world.getBlockState(pos))) return false; + if (world.getBlockState(pos).get(BlockStateProperties.AXIS) == Axis.Y) + return false; return true; } diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyBlock.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyBlock.java deleted file mode 100644 index 4bdf53ac6..000000000 --- a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyBlock.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.simibubi.create.modules.kinetics.relays; - -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; - -public class BeltPulleyBlock extends AxisBlock { - - public BeltPulleyBlock() { - super(Properties.from(Blocks.ANDESITE)); - } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return makeCuboidShape(-16, -16, -16, 32, 32, 32); - } - - @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return new BeltPulleyTileEntity(); - } - - @Override - protected boolean hasStaticPart() { - return false; // static addons like chutes - } - -} diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyTileEntity.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyTileEntity.java deleted file mode 100644 index a0d6cdbcc..000000000 --- a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyTileEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.simibubi.create.modules.kinetics.relays; - -import com.simibubi.create.AllTileEntities; -import com.simibubi.create.modules.kinetics.base.KineticTileEntity; - -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.math.BlockPos; - -public class BeltPulleyTileEntity extends KineticTileEntity { - - protected boolean controller; - protected BlockPos target; - - public BeltPulleyTileEntity() { - super(AllTileEntities.BELT_PULLEY.type); - controller = false; - target = BlockPos.ZERO; - } - - @Override - public CompoundNBT write(CompoundNBT compound) { - compound.putBoolean("Controller", isController()); - compound.put("Target", NBTUtil.writeBlockPos(target)); - return super.write(compound); - } - - @Override - public void read(CompoundNBT compound) { - controller = compound.getBoolean("Controller"); - target = NBTUtil.readBlockPos(compound.getCompound("Target")); - super.read(compound); - } - - public void setController(boolean controller) { - this.controller = controller; - } - - public boolean isController() { - return controller; - } - - public void setTarget(BlockPos target) { - this.target = target; - } - - public BlockPos getTarget() { - return target; - } - -} diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyTileEntityRenderer.java deleted file mode 100644 index a5b82e229..000000000 --- a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltPulleyTileEntityRenderer.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.simibubi.create.modules.kinetics.relays; - -import java.nio.ByteBuffer; -import java.util.Random; -import java.util.concurrent.TimeUnit; - -import org.lwjgl.opengl.GL11; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.simibubi.create.AllBlocks; -import com.simibubi.create.modules.kinetics.base.KineticTileEntity; -import com.simibubi.create.modules.kinetics.base.KineticTileEntityRenderer; - -import net.minecraft.block.BlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GLAllocation; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.state.properties.BlockStateProperties; -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.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraftforge.client.model.animation.Animation; -import net.minecraftforge.client.model.data.EmptyModelData; - -public class BeltPulleyTileEntityRenderer extends KineticTileEntityRenderer { - - protected static Cache cachedBelts; - public static IBakedModel beltModel; - - protected class CachedBeltBuffer { - ByteBuffer original; - ByteBuffer mutable; - - public CachedBeltBuffer(ByteBuffer original, float beltLength, float angle, Axis axis) { - original.rewind(); - this.original = original; - this.mutable = GLAllocation.createDirectByteBuffer(original.capacity()); - this.mutable.order(original.order()); - - int limitBefore = this.original.limit(); - int integerSize = DefaultVertexFormats.BLOCK.getIntegerSize(); - int amtBytesCopied = 0; // 2/*Blocks*/ * 6/*Quads*/ * 4/*Vertices*/ * integerSize; - - this.original.limit(limitBefore + amtBytesCopied); - this.mutable.limit(limitBefore + amtBytesCopied); - -// for (int i = 0; i < amtBytesCopied; i++) -// this.original.put(i + limitBefore, this.original.get(i)); -// int vertex = limitBefore / integerSize; -// putPos(this.original, vertex, getPos(this.original, vertex).add(0,1,0)); - - mutable.put(this.original); - this.original.rewind(); - mutable.rewind(); - } - - private Vec3d getPos(ByteBuffer buffer, int vertex) { - return new Vec3d(buffer.getFloat(vertex), buffer.getFloat(vertex + 4), buffer.getFloat(vertex + 8)); - } - - private void putPos(ByteBuffer buffer, int vertex, Vec3d pos) { - buffer.putFloat(vertex, (float) pos.x); - buffer.putFloat(vertex + 4, (float) pos.y); - buffer.putFloat(vertex + 8, (float) pos.z); - } - - private Vec3d rotatePos(Vec3d pos, float angle, Axis axis) { - return rotatePos(pos, MathHelper.sin(angle), MathHelper.cos(angle), axis); - } - - private Vec3d rotatePos(Vec3d pos, float sin, float cos, Axis axis) { - final float x = (float) pos.x; - final float y = (float) pos.y; - final float z = (float) pos.z; - - if (axis == Axis.X) - return new Vec3d(x, y * cos - z * sin, z * cos + y * sin); - if (axis == Axis.Y) - return new Vec3d(x * cos + z * sin, y, z * cos - x * sin); - if (axis == Axis.Z) - return new Vec3d(x * cos - y * sin, y * cos + x * sin, z); - - return pos; - } - - public ByteBuffer getTransformed(Vec3d translation, BeltPulleyTileEntity te, boolean flipped) { - original.rewind(); - mutable.rewind(); - - final Axis axis = te.getBlockState().get(BlockStateProperties.AXIS); - final BlockPos diff = te.getTarget().subtract(te.getPos()); - float angle = 0; - - if (axis == Axis.X) - angle = (float) MathHelper.atan2(-diff.getY(), diff.getZ()); - if (axis == Axis.Y) - angle = (float) MathHelper.atan2(diff.getX(), diff.getZ()); - if (axis == Axis.Z) - angle = (float) MathHelper.atan2(diff.getY(), diff.getX()); - - final float time = Animation.getWorldTime(Minecraft.getInstance().world, - Minecraft.getInstance().getRenderPartialTicks()); - final float progress = ((te.getSpeed() * time / 16) % 16) / 16f; - float beltLength = (float) new Vec3d(te.getPos()).distanceTo(new Vec3d(te.getTarget())) + .5f; - - final BlockState blockState = te.getBlockState(); - final int packedLightCoords = blockState.getPackedLightmapCoords(getWorld(), te.getPos()); - final int formatLength = DefaultVertexFormats.BLOCK.getSize(); - final Vec3d half = new Vec3d(.5f, .5f, .5f); - final float cos = MathHelper.cos(angle); - final float sin = MathHelper.sin(angle); - final Vec3d offset = new Vec3d(0, .25f, -.25f + progress + (te.getSpeed() < 0 ? 0 : -1)); - Vec3d trans = new Vec3d(Direction.getFacingFromAxis(AxisDirection.NEGATIVE, axis).getDirectionVec()) - .scale(.5f); - TextureAtlasSprite sprite = Minecraft.getInstance().getTextureMap() - .getSprite(AtlasTexture.LOCATION_BLOCKS_TEXTURE); - final int texHeight = sprite.getHeight(); - - for (int i = 0; i < original.limit() / formatLength; i++) { - final int position = i * formatLength; - - // Cut-off - mutable.putFloat(position + 20, original.getFloat(position + 20)); - - Vec3d localPos = getPos(this.original, position).add(offset); - if (localPos.z < -.25f) { - mutable.putFloat(position + 20, (float) (original.getFloat(position + 20) - - (Math.min(localPos.z + .25f, 0)) * .5f / texHeight)); - localPos = new Vec3d(localPos.x, localPos.y, -.25f); - } - if (localPos.z > beltLength - .25f) { - mutable.putFloat(position + 20, (float) (original.getFloat(position + 20) - - (Math.min(localPos.z - beltLength + .25f, 1f)) * .5f / texHeight)); - localPos = new Vec3d(localPos.x, localPos.y, beltLength - .25f); - } - - // Transform Vertex - Vec3d pos = localPos; - - if (axis == Axis.Z) - pos = rotatePos(pos.subtract(half), (float) (Math.PI / 2f), Axis.Y).add(half); - if (axis == Axis.Y) - pos = rotatePos(pos, (float) (Math.PI / 2f), Axis.Z); - - pos = rotatePos(pos, sin, cos, axis).add(trans).add(half); - - // Flip - if (flipped) { - pos = rotatePos(pos.subtract(half), (float) Math.PI, axis); - pos = pos.add(half).add(new Vec3d(diff)); - } - - putPos(mutable, position, pos.add(translation)); - mutable.putInt(position + 24, packedLightCoords); - } - return mutable; - } - } - - public BeltPulleyTileEntityRenderer() { - super(); - cachedBelts = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.SECONDS).build(); - } - - @Override - public void renderTileEntityFast(KineticTileEntity te, double x, double y, double z, float partialTicks, - int destroyStage, BufferBuilder buffer) { - super.renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, buffer); - - BeltPulleyTileEntity beltPulleyTE = (BeltPulleyTileEntity) te; - if (!beltPulleyTE.isController()) - return; - - cacheBeltIfMissing(beltPulleyTE); - renderBeltFromCache(te, new Vec3d(x, y, z), buffer); - } - - @Override - protected BlockState getRenderedBlockState(KineticTileEntity te) { - return AllBlocks.AXIS.get().getDefaultState().with(BlockStateProperties.AXIS, - te.getBlockState().get(BlockStateProperties.AXIS)); - } - - protected void cacheBeltIfMissing(BeltPulleyTileEntity te) { - if (cachedBelts.getIfPresent(te) != null) - return; - - BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); - BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); - BufferBuilder builder = new BufferBuilder(0); - Random random = new Random(); - - builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - - float beltLength = (float) new Vec3d(te.getPos()).distanceTo(new Vec3d(te.getTarget())) + .5f; - int length = MathHelper.ceil(beltLength) + 1; - for (int segment = 0; segment < length; segment++) { - builder.setTranslation(0, 0, segment); - blockRenderer.renderModelFlat(getWorld(), beltModel, te.getBlockState(), BlockPos.ZERO, builder, true, - random, 42, EmptyModelData.INSTANCE); - } - builder.finishDrawing(); - - Axis axis = te.getBlockState().get(BlockStateProperties.AXIS); - BlockPos diff = te.getTarget().subtract(te.getPos()); - float angle = 0; - - if (axis == Axis.X) - angle = (float) MathHelper.atan2(-diff.getY(), diff.getZ()); - if (axis == Axis.Y) - angle = (float) MathHelper.atan2(diff.getX(), diff.getZ()); - if (axis == Axis.Z) - angle = (float) MathHelper.atan2(diff.getY(), diff.getX()); - - cachedBelts.put(te, new CachedBeltBuffer(builder.getByteBuffer(), beltLength, angle, axis)); - - } - - public void renderBeltFromCache(KineticTileEntity te, Vec3d translation, BufferBuilder buffer) { - if (buffer == null) - return; - buffer.putBulkData(cachedBelts.getIfPresent(te).getTransformed(translation, (BeltPulleyTileEntity) te, false)); - buffer.putBulkData(cachedBelts.getIfPresent(te).getTransformed(translation, (BeltPulleyTileEntity) te, true)); - } -} diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltTileEntity.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltTileEntity.java new file mode 100644 index 000000000..565dd9f9c --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltTileEntity.java @@ -0,0 +1,51 @@ +package com.simibubi.create.modules.kinetics.relays; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllTileEntities; +import com.simibubi.create.modules.kinetics.base.KineticTileEntity; +import com.simibubi.create.modules.kinetics.relays.BeltBlock.Part; + +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.NBTUtil; +import net.minecraft.util.math.BlockPos; + +public class BeltTileEntity extends KineticTileEntity { + + protected BlockPos controller; + + public BeltTileEntity() { + super(AllTileEntities.BELT.type); + controller = BlockPos.ZERO; + } + + @Override + public CompoundNBT write(CompoundNBT compound) { + compound.put("Controller", NBTUtil.writeBlockPos(controller)); + return super.write(compound); + } + + @Override + public void read(CompoundNBT compound) { + controller = NBTUtil.readBlockPos(compound.getCompound("Controller")); + super.read(compound); + } + + public void setController(BlockPos controller) { + this.controller = controller; + } + + public BlockPos getController() { + return controller; + } + + public boolean isController() { + return controller.equals(pos); + } + + public boolean hasPulley() { + if (!AllBlocks.BELT.typeOf(getBlockState())) + return false; + return getBlockState().get(BeltBlock.PART) == Part.END || getBlockState().get(BeltBlock.PART) == Part.START; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltTileEntityRenderer.java new file mode 100644 index 000000000..faaf9e7a7 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/kinetics/relays/BeltTileEntityRenderer.java @@ -0,0 +1,102 @@ +package com.simibubi.create.modules.kinetics.relays; + +import java.nio.ByteBuffer; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.utility.BufferManipulator; +import com.simibubi.create.modules.kinetics.base.IRotate; +import com.simibubi.create.modules.kinetics.base.KineticTileEntity; +import com.simibubi.create.modules.kinetics.base.KineticTileEntityRenderer; + +import net.minecraft.block.BlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.Vec3d; +import net.minecraftforge.client.model.animation.Animation; + +public class BeltTileEntityRenderer extends KineticTileEntityRenderer { + + protected static class BeltModelAnimator extends BufferManipulator { + protected static TextureAtlasSprite beltTextures; + protected static TextureAtlasSprite originalTexture; + + public BeltModelAnimator(ByteBuffer template) { + super(template); + + if (beltTextures == null) + initSprites(); + } + + private void initSprites() { + AtlasTexture textureMap = Minecraft.getInstance().getTextureMap(); + + originalTexture = textureMap.getSprite(new ResourceLocation(Create.ID, "block/belt")); + beltTextures = textureMap.getSprite(new ResourceLocation(Create.ID, "block/belt_animated")); + } + + public ByteBuffer getTransformed(Vec3d translation, BeltTileEntity te) { + original.rewind(); + mutable.rewind(); + + float textureOffsetX = 0; + float textureOffsetY = 0; + + if (te.getSpeed() != 0) { + float time = Animation.getWorldTime(Minecraft.getInstance().world, + Minecraft.getInstance().getRenderPartialTicks()); + Direction direction = te.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING); + if (direction == Direction.EAST || direction == Direction.NORTH) + time = -time; + int textureIndex = (int) ((te.getSpeed() * time / 8) % 16); + if (textureIndex < 0) + textureIndex += 16; + + textureOffsetX = beltTextures.getInterpolatedU((textureIndex % 4) * 4) - originalTexture.getMinU(); + textureOffsetY = beltTextures.getInterpolatedV((textureIndex / 4) * 4) - originalTexture.getMinV(); + } + + final BlockState blockState = te.getBlockState(); + final int packedLightCoords = blockState.getPackedLightmapCoords(te.getWorld(), te.getPos()); + final float texOffX = textureOffsetX; + final float texOffY = textureOffsetY; + + forEachVertex(original, index -> { + Vec3d pos = getPos(original, index); + putPos(mutable, index, pos.add(translation)); + mutable.putFloat(index + 16, original.getFloat(index + 16) + texOffX); + mutable.putFloat(index + 20, original.getFloat(index + 20) + texOffY); + mutable.putInt(index + 24, packedLightCoords); + }); + + return mutable; + } + } + + @Override + public void renderTileEntityFast(KineticTileEntity te, double x, double y, double z, float partialTicks, + int destroyStage, BufferBuilder buffer) { + BeltTileEntity beltEntity = (BeltTileEntity) te; + + if (beltEntity.hasPulley()) + super.renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, buffer); + + cacheIfMissing(beltEntity.getBlockState(), BeltModelAnimator::new); + renderBeltFromCache(beltEntity, new Vec3d(x, y, z), buffer); + } + + @Override + protected BlockState getRenderedBlockState(KineticTileEntity te) { + return AllBlocks.AXIS.get().getDefaultState().with(BlockStateProperties.AXIS, + ((IRotate) AllBlocks.BELT.get()).getRotationAxis(te.getBlockState())); + } + + public void renderBeltFromCache(BeltTileEntity te, Vec3d translation, BufferBuilder buffer) { + buffer.putBulkData(((BeltModelAnimator) cachedBuffers.get(te.getBlockState())).getTransformed(translation, te)); + } +} diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/GearboxTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/GearboxTileEntityRenderer.java index 5a19bcb26..1fffd32b5 100644 --- a/src/main/java/com/simibubi/create/modules/kinetics/relays/GearboxTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/kinetics/relays/GearboxTileEntityRenderer.java @@ -33,7 +33,7 @@ public class GearboxTileEntityRenderer extends KineticTileEntityRenderer { continue; BlockState state = defaultState.with(BlockStateProperties.FACING, direction); - cacheIfMissing(state); + cacheIfMissing(state, BlockModelSpinner::new); float offset = getRotationOffsetForPosition(te, pos, axis); float angle = (time * te.getSpeed()) % 360; diff --git a/src/main/java/com/simibubi/create/modules/kinetics/relays/GearshifterTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/kinetics/relays/GearshifterTileEntityRenderer.java index 64d6f9d45..94c10088b 100644 --- a/src/main/java/com/simibubi/create/modules/kinetics/relays/GearshifterTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/kinetics/relays/GearshifterTileEntityRenderer.java @@ -31,7 +31,7 @@ public class GearshifterTileEntityRenderer extends KineticTileEntityRenderer { continue; BlockState state = defaultState.with(BlockStateProperties.FACING, direction); - cacheIfMissing(state); + cacheIfMissing(state, BlockModelSpinner::new); float offset = getRotationOffsetForPosition(te, pos, axis); float angle = (time * te.getSpeed()) % 360; diff --git a/src/main/resources/assets/create/blockstates/belt.json b/src/main/resources/assets/create/blockstates/belt.json index 7584621cc..77cac73ca 100644 --- a/src/main/resources/assets/create/blockstates/belt.json +++ b/src/main/resources/assets/create/blockstates/belt.json @@ -1,9 +1,75 @@ { "forgemarker": 1, "defaults": { - "model": "create:block/belt" + "model": "create:block/belt/horizontal_middle" }, "variants": { - "": { "model": "create:block/belt" } + + "slope=horizontal,part=start,facing=north": { "model": "create:block/belt/horizontal_end", "x": 0, "y": 180 }, + "slope=horizontal,part=start,facing=south": { "model": "create:block/belt/horizontal_end", "x": 0, "y": 0 }, + "slope=horizontal,part=start,facing=east": { "model": "create:block/belt/horizontal_end", "x": 0, "y": 270 }, + "slope=horizontal,part=start,facing=west": { "model": "create:block/belt/horizontal_end", "x": 0, "y": 90 }, + + "slope=horizontal,part=middle,facing=north": { "model": "create:block/belt/horizontal_middle", "x": 0, "y": 180 }, + "slope=horizontal,part=middle,facing=south": { "model": "create:block/belt/horizontal_middle", "x": 0, "y": 0 }, + "slope=horizontal,part=middle,facing=east": { "model": "create:block/belt/horizontal_middle", "x": 0, "y": 270 }, + "slope=horizontal,part=middle,facing=west": { "model": "create:block/belt/horizontal_middle", "x": 0, "y": 90 }, + + "slope=horizontal,part=end,facing=north": { "model": "create:block/belt/horizontal_start", "x": 0, "y": 180 }, + "slope=horizontal,part=end,facing=south": { "model": "create:block/belt/horizontal_start", "x": 0, "y": 0 }, + "slope=horizontal,part=end,facing=east": { "model": "create:block/belt/horizontal_start", "x": 0, "y": 270 }, + "slope=horizontal,part=end,facing=west": { "model": "create:block/belt/horizontal_start", "x": 0, "y": 90 }, + + + + "slope=vertical,part=end,facing=north": { "model": "create:block/belt/horizontal_end", "x": 90, "y": 180 }, + "slope=vertical,part=end,facing=south": { "model": "create:block/belt/horizontal_start", "x": 90, "y": 0 }, + "slope=vertical,part=end,facing=east": { "model": "create:block/belt/horizontal_start", "x": 90, "y": 270 }, + "slope=vertical,part=end,facing=west": { "model": "create:block/belt/horizontal_end", "x": 90, "y": 90 }, + + "slope=vertical,part=middle,facing=north": { "model": "create:block/belt/horizontal_middle", "x": 90, "y": 180 }, + "slope=vertical,part=middle,facing=south": { "model": "create:block/belt/horizontal_middle", "x": 90, "y": 0 }, + "slope=vertical,part=middle,facing=east": { "model": "create:block/belt/horizontal_middle", "x": 90, "y": 270 }, + "slope=vertical,part=middle,facing=west": { "model": "create:block/belt/horizontal_middle", "x": 90, "y": 90 }, + + "slope=vertical,part=start,facing=north": { "model": "create:block/belt/horizontal_start", "x": 90, "y": 180 }, + "slope=vertical,part=start,facing=south": { "model": "create:block/belt/horizontal_end", "x": 90, "y": 0 }, + "slope=vertical,part=start,facing=east": { "model": "create:block/belt/horizontal_end", "x": 90, "y": 270 }, + "slope=vertical,part=start,facing=west": { "model": "create:block/belt/horizontal_start", "x": 90, "y": 90 }, + + + + "slope=upward,part=start,facing=north": { "model": "create:block/belt/downward_end", "x": 0, "y": 180 }, + "slope=upward,part=start,facing=south": { "model": "create:block/belt/downward_end", "x": 0, "y": 0 }, + "slope=upward,part=start,facing=east": { "model": "create:block/belt/downward_end", "x": 0, "y": 270 }, + "slope=upward,part=start,facing=west": { "model": "create:block/belt/downward_end", "x": 0, "y": 90 }, + + "slope=upward,part=middle,facing=north": { "model": "create:block/belt/downward_middle", "x": 0, "y": 180 }, + "slope=upward,part=middle,facing=south": { "model": "create:block/belt/downward_middle", "x": 0, "y": 0 }, + "slope=upward,part=middle,facing=east": { "model": "create:block/belt/downward_middle", "x": 0, "y": 270 }, + "slope=upward,part=middle,facing=west": { "model": "create:block/belt/downward_middle", "x": 0, "y": 90 }, + + "slope=upward,part=end,facing=north": { "model": "create:block/belt/downward_start", "x": 0, "y": 180 }, + "slope=upward,part=end,facing=south": { "model": "create:block/belt/downward_start", "x": 0, "y": 0 }, + "slope=upward,part=end,facing=east": { "model": "create:block/belt/downward_start", "x": 0, "y": 270 }, + "slope=upward,part=end,facing=west": { "model": "create:block/belt/downward_start", "x": 0, "y": 90 }, + + + + "slope=downward,part=start,facing=north": { "model": "create:block/belt/upward_end", "x": 0, "y": 180 }, + "slope=downward,part=start,facing=south": { "model": "create:block/belt/upward_end", "x": 0, "y": 0 }, + "slope=downward,part=start,facing=east": { "model": "create:block/belt/upward_end", "x": 0, "y": 270 }, + "slope=downward,part=start,facing=west": { "model": "create:block/belt/upward_end", "x": 0, "y": 90 }, + + "slope=downward,part=middle,facing=north": { "model": "create:block/belt/upward_middle", "x": 0, "y": 180 }, + "slope=downward,part=middle,facing=south": { "model": "create:block/belt/upward_middle", "x": 0, "y": 0 }, + "slope=downward,part=middle,facing=east": { "model": "create:block/belt/upward_middle", "x": 0, "y": 270 }, + "slope=downward,part=middle,facing=west": { "model": "create:block/belt/upward_middle", "x": 0, "y": 90 }, + + "slope=downward,part=end,facing=north": { "model": "create:block/belt/upward_start", "x": 0, "y": 180 }, + "slope=downward,part=end,facing=south": { "model": "create:block/belt/upward_start", "x": 0, "y": 0 }, + "slope=downward,part=end,facing=east": { "model": "create:block/belt/upward_start", "x": 0, "y": 270 }, + "slope=downward,part=end,facing=west": { "model": "create:block/belt/upward_start", "x": 0, "y": 90 } + } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/blockstates/belt_animation.json b/src/main/resources/assets/create/blockstates/belt_animation.json new file mode 100644 index 000000000..5735632c4 --- /dev/null +++ b/src/main/resources/assets/create/blockstates/belt_animation.json @@ -0,0 +1,9 @@ +{ + "forgemarker": 1, + "defaults": { + "model": "create:block/belt/belt_textures" + }, + "variants": { + "": { "model": "create:block/belt/belt_textures" } + } +} diff --git a/src/main/resources/assets/create/blockstates/belt_pulley.json b/src/main/resources/assets/create/blockstates/belt_pulley.json deleted file mode 100644 index 8078a810d..000000000 --- a/src/main/resources/assets/create/blockstates/belt_pulley.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "forgemarker": 1, - "defaults": { - "model": "block/dirt" - }, - "variants": { - "axis=y": { "model": "block/dirt" }, - "axis=z": { "model": "block/dirt", "x": 90 }, - "axis=x": { "model": "block/dirt", "x": 90, "y": 90 } - } -} \ No newline at end of file diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index 93a31a744..11e1f004d 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -8,7 +8,7 @@ "item.create.chorus_chrome_cube": "Chorus Chrome", "item.create.blueprint_and_quill": "Schematic and Quill", "item.create.blueprint": "Schematic", - "item.create.belt": "Mechanical Belt", + "item.create.belt_connector": "Mechanical Belt", "block.create.gear": "Cogwheel", "block.create.large_gear": "Large Cogwheel", "block.create.turntable": "Turntable", @@ -17,7 +17,7 @@ "block.create.axis_tunnel": "Encased Axis", "block.create.axis": "Axis", "block.create.motor": "Motor", - "block.create.belt_pulley": "Belt Pulley", + "block.create.belt": "Mechanical Belt", "block.create.schematicannon": "Schematicannon", "block.create.schematic_table": "Schematic Table", "block.create.creative_crate": "Schematicannon Creatifier", diff --git a/src/main/resources/assets/create/models/block/belt/belt_textures.json b/src/main/resources/assets/create/models/block/belt/belt_textures.json new file mode 100644 index 000000000..60edee6c3 --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/belt_textures.json @@ -0,0 +1,16 @@ +{ + "parent": "block/cube", + "textures": { + "0": "create:block/belt_animated" + }, + "elements": [ + { + "name": "Cheese", + "from": [ 0.0, 0.0, 0.0 ], + "to": [ 1.0, 1.0, 1.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/downward_end.json b/src/main/resources/assets/create/models/block/belt/downward_end.json new file mode 100644 index 000000000..caa528528 --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/downward_end.json @@ -0,0 +1,73 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Top", + "from": [ 1.0, 11.0, 1.0 ], + "to": [ 15.0, 13.0, 6.8 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 7.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 7.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 6.8 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 6.8 ] } + } + }, + { + "name": "Bottom", + "from": [ 1.0, 3.0, 1.0 ], + "to": [ 15.0, 5.0, 10.1 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 10.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 10.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 10.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 10.0 ], "rotation": 180 } + } + }, + { + "name": "Side", + "from": [ 1.0, 4.0, 0.0 ], + "to": [ 15.0, 12.0, 2.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 4.0, 2.0, 12.0 ] }, + "south": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ] }, + "west": { "texture": "#0", "uv": [ 14.0, 4.0, 16.0, 12.0 ] }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 } + } + }, + { + "name": "Top Diagonal", + "from": [ 1.0, 11.0, 9.2 ], + "to": [ 15.0, 13.0, 19.325 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 10.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 10.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ] } + } + }, + { + "name": "Bottom Diagonal", + "from": [ 1.0, 3.0, 5.9 ], + "to": [ 15.0, 5.0, 19.325 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 3.0, 2.0, 16.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 3.0, 16.0, 16.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ], "rotation": 180 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/downward_middle.json b/src/main/resources/assets/create/models/block/belt/downward_middle.json new file mode 100644 index 000000000..6df1312f3 --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/downward_middle.json @@ -0,0 +1,62 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Bottom Diagonal", + "from": [ 1.0, 3.0, -3.325 ], + "to": [ 15.0, 5.0, 6.6 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 10.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 10.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.1 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ], "rotation": 180 } + } + }, + { + "name": "Top Diagonal", + "from": [ 1.0, 11.0, -3.325 ], + "to": [ 15.0, 13.0, 10.0 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 3.0, 2.0, 16.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 3.0, 16.0, 16.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ] } + } + }, + { + "name": "Top Diagonal First", + "from": [ 1.0, 11.0, 9.98 ], + "to": [ 15.0, 13.0, 19.3 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 10.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 10.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ] } + } + }, + { + "name": "Bottom Diagonal First", + "from": [ 1.0, 3.0, 6.58 ], + "to": [ 15.0, 5.0, 19.3 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 3.0, 2.0, 16.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 3.0, 16.0, 16.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ], "rotation": 180 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/downward_start.json b/src/main/resources/assets/create/models/block/belt/downward_start.json new file mode 100644 index 000000000..c49ccce75 --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/downward_start.json @@ -0,0 +1,73 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Bottom", + "from": [ 1.0, 3.0, 9.2 ], + "to": [ 15.0, 5.0, 15.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 9.0, 2.0, 15.0 ], "rotation": 90 }, + "south": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 9.0, 16.0, 15.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 9.0, 15.0, 14.8 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 9.0, 15.0, 14.8 ], "rotation": 180 } + } + }, + { + "name": "Top", + "from": [ 1.0, 11.0, 5.9 ], + "to": [ 15.0, 13.0, 15.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 10.0 ], "rotation": 270 }, + "south": { "texture": "#0", "uv": [ 1.0, 13.0, 15.0, 11.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 10.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 10.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 10.0 ] } + } + }, + { + "name": "Side", + "from": [ 1.0, 4.0, 14.0 ], + "to": [ 15.0, 12.0, 16.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 4.0, 2.0, 12.0 ], "rotation": 180 }, + "south": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 4.0, 16.0, 12.0 ], "rotation": 180 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ] } + } + }, + { + "name": "Bottom Diagonal", + "from": [ 1.0, 3.0, -3.328 ], + "to": [ 15.0, 5.0, 6.75 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 10.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 10.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.1 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ], "rotation": 180 } + } + }, + { + "name": "Top Diagonal", + "from": [ 1.0, 11.0, -3.328 ], + "to": [ 15.0, 13.0, 10.1 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 3.0, 2.0, 16.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 3.0, 16.0, 16.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/horizontal_end.json b/src/main/resources/assets/create/models/block/belt/horizontal_end.json new file mode 100644 index 000000000..228167eee --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/horizontal_end.json @@ -0,0 +1,47 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Bottom", + "from": [ 1.0, 3.0, 1.0 ], + "to": [ 15.0, 5.0, 16.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 16.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 16.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 16.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 16.0 ], "rotation": 180 } + } + }, + { + "name": "Top", + "from": [ 1.0, 11.0, 1.0 ], + "to": [ 15.0, 13.0, 16.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 16.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 16.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 15.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 16.0 ] } + } + }, + { + "name": "Side", + "from": [ 1.0, 4.0, 0.0 ], + "to": [ 15.0, 12.0, 2.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 4.0, 2.0, 12.0 ] }, + "south": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ] }, + "west": { "texture": "#0", "uv": [ 14.0, 4.0, 16.0, 12.0 ] }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/horizontal_middle.json b/src/main/resources/assets/create/models/block/belt/horizontal_middle.json new file mode 100644 index 000000000..4d3ada53e --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/horizontal_middle.json @@ -0,0 +1,32 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Bottom", + "from": [ 1.0, 3.0, 0.0 ], + "to": [ 15.0, 5.0, 16.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 16.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 16.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ], "rotation": 180 } + } + }, + { + "name": "Top", + "from": [ 1.0, 11.0, 0.0 ], + "to": [ 15.0, 13.0, 16.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 16.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 16.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 16.0 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/horizontal_start.json b/src/main/resources/assets/create/models/block/belt/horizontal_start.json new file mode 100644 index 000000000..5f320e4fb --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/horizontal_start.json @@ -0,0 +1,47 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Bottom", + "from": [ 1.0, 3.0, 0.0 ], + "to": [ 15.0, 5.0, 15.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 15.0 ], "rotation": 90 }, + "south": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 15.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 15.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 15.0 ], "rotation": 180 } + } + }, + { + "name": "Top", + "from": [ 1.0, 11.0, 0.0 ], + "to": [ 15.0, 13.0, 15.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 16.0 ], "rotation": 270 }, + "south": { "texture": "#0", "uv": [ 1.0, 5.0, 15.0, 3.0 ] }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 16.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 16.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 16.0 ] } + } + }, + { + "name": "Side", + "from": [ 1.0, 4.0, 14.0 ], + "to": [ 15.0, 12.0, 16.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 4.0, 2.0, 12.0 ], "rotation": 180 }, + "south": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 4.0, 16.0, 12.0 ], "rotation": 180 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/upward_end.json b/src/main/resources/assets/create/models/block/belt/upward_end.json new file mode 100644 index 000000000..5dd6f2cdb --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/upward_end.json @@ -0,0 +1,73 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Bottom", + "from": [ 1.0, 3.0, 1.0 ], + "to": [ 15.0, 5.0, 6.8 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 7.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 7.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 6.8 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 6.8 ], "rotation": 180 } + } + }, + { + "name": "Top", + "from": [ 1.0, 11.0, 1.0 ], + "to": [ 15.0, 13.0, 10.1 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 6.0, 2.0, 15.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 6.0, 16.0, 15.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 6.0, 15.0, 15.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 6.0, 15.0, 15.0 ] } + } + }, + { + "name": "Side", + "from": [ 1.0, 4.0, 0.0 ], + "to": [ 15.0, 12.0, 2.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 4.0, 2.0, 12.0 ] }, + "south": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ] }, + "west": { "texture": "#0", "uv": [ 14.0, 4.0, 16.0, 12.0 ] }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 } + } + }, + { + "name": "Bottom Diagonal", + "from": [ 1.0, 3.0, 9.2 ], + "to": [ 15.0, 5.0, 19.3 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 11.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 11.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 11.1 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 11.1 ], "rotation": 180 } + } + }, + { + "name": "Top Diagonal", + "from": [ 1.0, 11.0, 5.9 ], + "to": [ 15.0, 13.0, 19.3 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 13.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 13.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 13.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 13.0 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/upward_middle.json b/src/main/resources/assets/create/models/block/belt/upward_middle.json new file mode 100644 index 000000000..21b48ed92 --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/upward_middle.json @@ -0,0 +1,62 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Bottom Diagonal", + "from": [ 1.0, 3.0, -3.325 ], + "to": [ 15.0, 5.0, 6.6 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 10.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 10.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.1 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ], "rotation": 180 } + } + }, + { + "name": "Top Diagonal", + "from": [ 1.0, 11.0, -3.325 ], + "to": [ 15.0, 13.0, 10.0 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 3.0, 2.0, 16.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 3.0, 16.0, 16.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ] } + } + }, + { + "name": "Top Diagonal First", + "from": [ 1.0, 11.0, 10.0 ], + "to": [ 15.0, 13.0, 19.3 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 10.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 10.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 10.2 ] } + } + }, + { + "name": "Bottom Diagonal First", + "from": [ 1.0, 3.0, 6.6 ], + "to": [ 15.0, 5.0, 19.3 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 3.0, 2.0, 16.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 3.0, 16.0, 16.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 16.0 ], "rotation": 180 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt/upward_start.json b/src/main/resources/assets/create/models/block/belt/upward_start.json new file mode 100644 index 000000000..6b8a6242d --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt/upward_start.json @@ -0,0 +1,73 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", + "parent": "block/cube", + "textures": { + "particle": "create:block/belt", + "0": "create:block/belt" + }, + "elements": [ + { + "name": "Top", + "from": [ 1.0, 11.0, 9.2 ], + "to": [ 15.0, 13.0, 15.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 1.0, 2.0, 7.0 ], "rotation": 270 }, + "south": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 1.0, 16.0, 7.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 6.8 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 6.8 ] } + } + }, + { + "name": "Bottom", + "from": [ 1.0, 3.0, 5.9 ], + "to": [ 15.0, 5.0, 15.0 ], + "faces": { + "east": { "texture": "#0", "uv": [ 0.0, 6.0, 2.0, 15.0 ], "rotation": 90 }, + "south": { "texture": "#0", "uv": [ 1.0, 5.0, 15.0, 3.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 6.0, 16.0, 15.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 6.0, 15.0, 15.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 6.0, 15.0, 15.0 ], "rotation": 180 } + } + }, + { + "name": "Side", + "from": [ 1.0, 4.0, 14.0 ], + "to": [ 15.0, 12.0, 16.0 ], + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 4.0, 2.0, 12.0 ], "rotation": 180 }, + "south": { "texture": "#0", "uv": [ 1.0, 4.0, 15.0, 12.0 ], "rotation": 180 }, + "west": { "texture": "#0", "uv": [ 14.0, 4.0, 16.0, 12.0 ], "rotation": 180 }, + "up": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ] } + } + }, + { + "name": "Top Diagonal", + "from": [ 1.0, 11.0, -3.325 ], + "to": [ 15.0, 13.0, 6.7 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 11.0, 15.0, 13.0 ], "rotation": 180 }, + "east": { "texture": "#0", "uv": [ 0.0, 6.0, 2.0, 16.0 ], "rotation": 270 }, + "west": { "texture": "#0", "uv": [ 14.0, 6.0, 16.0, 16.0 ], "rotation": 90 }, + "up": { "texture": "#0", "uv": [ 1.0, 5.8, 15.0, 16.0 ], "rotation": 180 }, + "down": { "texture": "#0", "uv": [ 1.0, 5.8, 15.0, 16.0 ] } + } + }, + { + "name": "Bottom Diagonal", + "from": [ 1.0, 3.0, -3.325 ], + "to": [ 15.0, 5.0, 10.1 ], + "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": 45.0 }, + "faces": { + "north": { "texture": "#0", "uv": [ 1.0, 3.0, 15.0, 5.0 ] }, + "east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 13.0 ], "rotation": 90 }, + "west": { "texture": "#0", "uv": [ 14.0, 0.0, 16.0, 13.0 ], "rotation": 270 }, + "up": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 13.0 ] }, + "down": { "texture": "#0", "uv": [ 1.0, 0.0, 15.0, 13.0 ], "rotation": 180 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/item/belt.json b/src/main/resources/assets/create/models/item/belt_connector.json similarity index 100% rename from src/main/resources/assets/create/models/item/belt.json rename to src/main/resources/assets/create/models/item/belt_connector.json diff --git a/src/main/resources/assets/create/textures/block/belt.png b/src/main/resources/assets/create/textures/block/belt.png index ce2eef513..d325e29d8 100644 Binary files a/src/main/resources/assets/create/textures/block/belt.png and b/src/main/resources/assets/create/textures/block/belt.png differ diff --git a/src/main/resources/assets/create/textures/block/belt_animated.png b/src/main/resources/assets/create/textures/block/belt_animated.png new file mode 100644 index 000000000..c9504b7f1 Binary files /dev/null and b/src/main/resources/assets/create/textures/block/belt_animated.png differ diff --git a/src/main/resources/assets/create/textures/block/belt_moving_reversed.png b/src/main/resources/assets/create/textures/block/belt_moving_reversed.png deleted file mode 100644 index fb689903f..000000000 Binary files a/src/main/resources/assets/create/textures/block/belt_moving_reversed.png and /dev/null differ diff --git a/src/main/resources/assets/create/textures/block/belt_moving_reversed.png.mcmeta b/src/main/resources/assets/create/textures/block/belt_moving_reversed.png.mcmeta deleted file mode 100644 index a328ca58d..000000000 --- a/src/main/resources/assets/create/textures/block/belt_moving_reversed.png.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "animation": { - "interpolate": false, - "frametime": 1 - } -}