whoops, forgot about this 😳 👉👈

- encased shaft supports multiple casings, applied with right click
- fix gl state after rendering our cube particle
This commit is contained in:
Zelophed 2020-08-18 13:53:05 +02:00
parent 7e3dd8f701
commit bc5bcd0a6d
11 changed files with 168 additions and 39 deletions

View file

@ -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
}

View file

@ -1,3 +0,0 @@
{
"parent": "create:block/encased_shaft/item"
}

View file

@ -6,7 +6,7 @@
"entries": [
{
"type": "minecraft:item",
"name": "create:encased_shaft"
"name": "create:shaft"
}
],
"conditions": [

View file

@ -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<EncasedShaftBlock> ENCASED_SHAFT =
REGISTRATE.block("encased_shaft", EncasedShaftBlock::new)
public static final BlockEntry<EncasedShaftBlock> 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<GearboxBlock> GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new)

View file

@ -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();
}
};

View file

@ -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

View file

@ -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> 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<Block, BlockState> 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<CasingBlock> casingEntry;
Casing(BlockEntry<CasingBlock> casingEntry) {
this.casingEntry = casingEntry;
}
public BlockEntry<CasingBlock> getCasingEntry() {
return casingEntry;
}
@Override
public String getName() {
return Lang.asId(name());
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "create:block/encased_shaft/base",
"textures": {
"casing": "create:block/andesite_casing"
}
}

View file

@ -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"}
}
}
]

View file

@ -0,0 +1,6 @@
{
"parent": "create:block/encased_shaft/base",
"textures": {
"casing": "create:block/brass_casing"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "create:block/encased_shaft/base",
"textures": {
"casing": "create:block/copper_casing"
}
}