diff --git a/src/generated/resources/assets/create/blockstates/encased_shaft.json b/src/generated/resources/assets/create/blockstates/encased_shaft.json index ae5973592..d904e950d 100644 --- a/src/generated/resources/assets/create/blockstates/encased_shaft.json +++ b/src/generated/resources/assets/create/blockstates/encased_shaft.json @@ -1,15 +1,41 @@ { "variants": { - "axis=x": { - "model": "create:block/encased_shaft/block", + "axis=x,casing=andesite": { + "model": "create:block/encased_shaft/andesite", "x": 90, "y": 90 }, - "axis=y": { - "model": "create:block/encased_shaft/block" + "axis=y,casing=andesite": { + "model": "create:block/encased_shaft/andesite" }, - "axis=z": { - "model": "create:block/encased_shaft/block", + "axis=z,casing=andesite": { + "model": "create:block/encased_shaft/andesite", + "x": 90, + "y": 180 + }, + "axis=x,casing=copper": { + "model": "create:block/encased_shaft/copper", + "x": 90, + "y": 90 + }, + "axis=y,casing=copper": { + "model": "create:block/encased_shaft/copper" + }, + "axis=z,casing=copper": { + "model": "create:block/encased_shaft/copper", + "x": 90, + "y": 180 + }, + "axis=x,casing=brass": { + "model": "create:block/encased_shaft/brass", + "x": 90, + "y": 90 + }, + "axis=y,casing=brass": { + "model": "create:block/encased_shaft/brass" + }, + "axis=z,casing=brass": { + "model": "create:block/encased_shaft/brass", "x": 90, "y": 180 } diff --git a/src/generated/resources/assets/create/models/item/encased_shaft.json b/src/generated/resources/assets/create/models/item/encased_shaft.json deleted file mode 100644 index 479412d0e..000000000 --- a/src/generated/resources/assets/create/models/item/encased_shaft.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "create:block/encased_shaft/item" -} \ No newline at end of file diff --git a/src/generated/resources/data/create/loot_tables/blocks/encased_shaft.json b/src/generated/resources/data/create/loot_tables/blocks/encased_shaft.json index 46c9ae96a..84f976dfb 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/encased_shaft.json +++ b/src/generated/resources/data/create/loot_tables/blocks/encased_shaft.json @@ -6,7 +6,7 @@ "entries": [ { "type": "minecraft:item", - "name": "create:encased_shaft" + "name": "create:shaft" } ], "conditions": [ diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 6e293278b..29d52c071 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -3,6 +3,7 @@ package com.simibubi.create; import static com.simibubi.create.AllTags.forgeItemTag; import static com.simibubi.create.AllTags.tagBlockAndItem; import static com.simibubi.create.content.AllSections.SCHEMATICS; +import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock; import static com.simibubi.create.foundation.data.BlockStateGen.oxidizedBlockstate; import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures; import static com.simibubi.create.foundation.data.ModelGen.customItemModel; @@ -218,14 +219,15 @@ public class AllBlocks { .build() .register(); - public static final BlockEntry ENCASED_SHAFT = - REGISTRATE.block("encased_shaft", EncasedShaftBlock::new) + public static final BlockEntry ENCASED_SHAFT = REGISTRATE.block("encased_shaft", EncasedShaftBlock::new) .initialProperties(SharedProperties::stone) .properties(Block.Properties::nonOpaque) .transform(StressConfigDefaults.setNoImpact()) - .blockstate(BlockStateGen.axisBlockProvider(true)) - .item() - .transform(customItemModel()) + //.blockstate(BlockStateGen.axisBlockProvider(true)) + .blockstate((c, p) -> axisBlock(c, p, blockState -> p.models().getExistingFile(p.modLoc("block/encased_shaft/" + blockState.get(EncasedShaftBlock.CASING).getName())))) + .loot((p, b) -> p.registerDropping(b, SHAFT.get())) + //.item() + //.transform(customItemModel()) .register(); public static final BlockEntry GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new) diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java index ad133bc4e..a9df78e38 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java @@ -1,11 +1,8 @@ package com.simibubi.create.content.contraptions.particle; -import org.lwjgl.opengl.GL11; - import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; - import net.minecraft.client.particle.IParticleFactory; import net.minecraft.client.particle.IParticleRenderType; import net.minecraft.client.particle.Particle; @@ -18,6 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; public class CubeParticle extends Particle { @@ -76,6 +74,7 @@ public class CubeParticle extends Particle { tessellator.draw(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.disableLighting(); RenderSystem.enableTexture(); } }; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java index e13efbdd8..c63cde09c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/ShaftBlock.java @@ -3,12 +3,15 @@ package com.simibubi.create.content.contraptions.relays.elementary; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; +import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.block.IWaterLoggable; import net.minecraft.block.material.PushReaction; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluids; import net.minecraft.fluid.IFluidState; import net.minecraft.item.BlockItemUseContext; @@ -17,15 +20,19 @@ import net.minecraft.item.ItemStack; 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.Direction.Axis; +import net.minecraft.util.Hand; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; +import net.minecraft.world.World; public class ShaftBlock extends RotatedPillarKineticBlock implements IWaterLoggable { @@ -73,6 +80,26 @@ public class ShaftBlock extends RotatedPillarKineticBlock implements IWaterLogga super.fillItemGroup(group, items); } + @Override + public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult p_225533_6_) { + if (player.isSneaking() || !player.isAllowEdit()) + return ActionResultType.PASS; + + ItemStack heldItem = player.getHeldItem(hand); + + for (EncasedShaftBlock.Casing casing : EncasedShaftBlock.Casing.values()) { + if (casing.getCasingEntry().isIn(heldItem)) { + if (world.isRemote) + return ActionResultType.SUCCESS; + + KineticTileEntity.switchToBlockState(world, pos, AllBlocks.ENCASED_SHAFT.getDefaultState().with(EncasedShaftBlock.CASING, casing).with(AXIS, state.get(AXIS))); + return ActionResultType.SUCCESS; + } + } + + return ActionResultType.PASS; + } + // IRotate: @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java index ef275df56..2230b833a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java @@ -1,22 +1,51 @@ package com.simibubi.create.content.contraptions.relays.encased; +import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTileEntities; +import com.simibubi.create.content.contraptions.base.CasingBlock; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; +import com.simibubi.create.foundation.utility.Lang; +import com.tterrag.registrate.util.entry.BlockEntry; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.PushReaction; +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.EnumProperty; +import net.minecraft.state.IProperty; +import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; +import net.minecraft.util.IStringSerializable; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; public class EncasedShaftBlock extends RotatedPillarKineticBlock { + public static final IProperty CASING = EnumProperty.create("casing", Casing.class); + public EncasedShaftBlock(Properties properties) { super(properties); + this.setDefaultState(this.getDefaultState().with(CASING, Casing.ANDESITE)); + } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(CASING); + } + + @Override + public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) { + return new ItemStack(state.get(CASING).getCasingEntry().get().asItem()); } @Override @@ -55,4 +84,36 @@ public class EncasedShaftBlock extends RotatedPillarKineticBlock { return state.get(AXIS); } + @Override + public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) { + if (context.getWorld().isRemote) + return ActionResultType.SUCCESS; + + KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), AllBlocks.SHAFT.getDefaultState().with(AXIS, state.get(AXIS))); + return ActionResultType.SUCCESS; + } + + public enum Casing implements IStringSerializable { + ANDESITE(AllBlocks.ANDESITE_CASING), + BRASS(AllBlocks.BRASS_CASING), + //COPPER(AllBlocks.COPPER_CASING) + + ; + + private final BlockEntry casingEntry; + + Casing(BlockEntry casingEntry) { + this.casingEntry = casingEntry; + } + + public BlockEntry getCasingEntry() { + return casingEntry; + } + + @Override + public String getName() { + return Lang.asId(name()); + } + } + } diff --git a/src/main/resources/assets/create/models/block/encased_shaft/andesite.json b/src/main/resources/assets/create/models/block/encased_shaft/andesite.json new file mode 100644 index 000000000..b30279387 --- /dev/null +++ b/src/main/resources/assets/create/models/block/encased_shaft/andesite.json @@ -0,0 +1,6 @@ +{ + "parent": "create:block/encased_shaft/base", + "textures": { + "casing": "create:block/andesite_casing" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/encased_shaft/block.json b/src/main/resources/assets/create/models/block/encased_shaft/base.json similarity index 70% rename from src/main/resources/assets/create/models/block/encased_shaft/block.json rename to src/main/resources/assets/create/models/block/encased_shaft/base.json index 56fd88197..b280f78ab 100644 --- a/src/main/resources/assets/create/models/block/encased_shaft/block.json +++ b/src/main/resources/assets/create/models/block/encased_shaft/base.json @@ -2,7 +2,6 @@ "credit": "Made with Blockbench", "parent": "block/block", "textures": { - "0": "create:block/andesite_casing", "1": "create:block/gearbox", "particle": "create:block/andesite_casing" }, @@ -12,12 +11,12 @@ "from": [0, 0, 0], "to": [16, 16, 2], "faces": { - "north": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#0"}, - "east": {"uv": [0, 14, 16, 16], "rotation": 270, "texture": "#0"}, - "south": {"uv": [0, 0, 16, 16], "texture": "#0"}, - "west": {"uv": [0, 14, 16, 16], "rotation": 90, "texture": "#0"}, - "up": {"uv": [0, 14, 16, 16], "rotation": 180, "texture": "#0"}, - "down": {"uv": [0, 14, 16, 16], "texture": "#0"} + "north": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#casing"}, + "east": {"uv": [0, 14, 16, 16], "rotation": 270, "texture": "#casing"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#casing"}, + "west": {"uv": [0, 14, 16, 16], "rotation": 90, "texture": "#casing"}, + "up": {"uv": [0, 14, 16, 16], "rotation": 180, "texture": "#casing"}, + "down": {"uv": [0, 14, 16, 16], "texture": "#casing"} } }, { @@ -34,12 +33,12 @@ "from": [0, 0, 14], "to": [16, 16, 16], "faces": { - "north": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#0"}, - "east": {"uv": [0, 0, 16, 2], "rotation": 270, "texture": "#0"}, - "south": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#0"}, - "west": {"uv": [0, 0, 16, 2], "rotation": 90, "texture": "#0"}, - "up": {"uv": [0, 0, 16, 2], "rotation": 180, "texture": "#0"}, - "down": {"uv": [0, 0, 16, 2], "texture": "#0"} + "north": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#casing"}, + "east": {"uv": [0, 0, 16, 2], "rotation": 270, "texture": "#casing"}, + "south": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#casing"}, + "west": {"uv": [0, 0, 16, 2], "rotation": 90, "texture": "#casing"}, + "up": {"uv": [0, 0, 16, 2], "rotation": 180, "texture": "#casing"}, + "down": {"uv": [0, 0, 16, 2], "texture": "#casing"} } }, { @@ -47,10 +46,10 @@ "from": [0, 0, 2], "to": [2, 16, 14], "faces": { - "east": {"uv": [0, 2, 16, 14], "rotation": 270, "texture": "#0"}, - "west": {"uv": [0, 2, 16, 14], "rotation": 90, "texture": "#0"}, - "up": {"uv": [14, 2, 16, 14], "rotation": 180, "texture": "#0"}, - "down": {"uv": [0, 2, 2, 14], "texture": "#0"} + "east": {"uv": [0, 2, 16, 14], "rotation": 270, "texture": "#casing"}, + "west": {"uv": [0, 2, 16, 14], "rotation": 90, "texture": "#casing"}, + "up": {"uv": [14, 2, 16, 14], "rotation": 180, "texture": "#casing"}, + "down": {"uv": [0, 2, 2, 14], "texture": "#casing"} } }, { @@ -58,10 +57,10 @@ "from": [14, 0, 2], "to": [16, 16, 14], "faces": { - "east": {"uv": [0, 2, 16, 14], "rotation": 270, "texture": "#0"}, - "west": {"uv": [0, 2, 16, 14], "rotation": 90, "texture": "#0"}, - "up": {"uv": [0, 2, 2, 14], "rotation": 180, "texture": "#0"}, - "down": {"uv": [14, 2, 16, 14], "texture": "#0"} + "east": {"uv": [0, 2, 16, 14], "rotation": 270, "texture": "#casing"}, + "west": {"uv": [0, 2, 16, 14], "rotation": 90, "texture": "#casing"}, + "up": {"uv": [0, 2, 2, 14], "rotation": 180, "texture": "#casing"}, + "down": {"uv": [14, 2, 16, 14], "texture": "#casing"} } } ] diff --git a/src/main/resources/assets/create/models/block/encased_shaft/brass.json b/src/main/resources/assets/create/models/block/encased_shaft/brass.json new file mode 100644 index 000000000..2d2907d69 --- /dev/null +++ b/src/main/resources/assets/create/models/block/encased_shaft/brass.json @@ -0,0 +1,6 @@ +{ + "parent": "create:block/encased_shaft/base", + "textures": { + "casing": "create:block/brass_casing" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/encased_shaft/copper.json b/src/main/resources/assets/create/models/block/encased_shaft/copper.json new file mode 100644 index 000000000..e9407b71c --- /dev/null +++ b/src/main/resources/assets/create/models/block/encased_shaft/copper.json @@ -0,0 +1,6 @@ +{ + "parent": "create:block/encased_shaft/base", + "textures": { + "casing": "create:block/copper_casing" + } +} \ No newline at end of file