The return of dyed belts

- Dyes can now be used to change the appearance of Mechanical Belts
- Fluid items containing water can be used to clean dyed belts
This commit is contained in:
simibubi 2021-01-23 23:00:27 +01:00
parent 667f27d9b7
commit d35bdab51a
40 changed files with 95 additions and 88 deletions

View file

@ -335,7 +335,7 @@ e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets/create/blockstates/powered_toggl
d06cd9a1101b18d306a786320aab12018b1325d6 assets/create/blockstates/purple_sail.json
92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json
61035f8afe75ff7bbd291da5d8690bcbebe679eb assets/create/blockstates/purple_valve_handle.json
89b63c6e5875da07226854651079bcea85439f5b assets/create/blockstates/radial_chassis.json
bdd56f32ce0a148b6e466a55ab2777f69fc08cfc assets/create/blockstates/radial_chassis.json
45877c4d90a7185c2f304edbd67379d800920439 assets/create/blockstates/red_sail.json
da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json
722fc77bbf387af8a4016e42cbf9501d2b968881 assets/create/blockstates/red_valve_handle.json

View file

@ -89,8 +89,8 @@
},
{
"when": {
"sticky_west": "true",
"axis": "x"
"axis": "x",
"sticky_west": "true"
},
"apply": {
"model": "create:block/radial_chassis_side_x_sticky",
@ -99,8 +99,8 @@
},
{
"when": {
"sticky_west": "true",
"axis": "y"
"axis": "y",
"sticky_west": "true"
},
"apply": {
"model": "create:block/radial_chassis_side_y_sticky",
@ -109,8 +109,8 @@
},
{
"when": {
"sticky_west": "true",
"axis": "z"
"axis": "z",
"sticky_west": "true"
},
"apply": {
"model": "create:block/radial_chassis_side_z_sticky",
@ -119,8 +119,8 @@
},
{
"when": {
"sticky_west": "false",
"axis": "x"
"axis": "x",
"sticky_west": "false"
},
"apply": {
"model": "create:block/radial_chassis_side_x",
@ -129,8 +129,8 @@
},
{
"when": {
"sticky_west": "false",
"axis": "y"
"axis": "y",
"sticky_west": "false"
},
"apply": {
"model": "create:block/radial_chassis_side_y",
@ -139,8 +139,8 @@
},
{
"when": {
"sticky_west": "false",
"axis": "z"
"axis": "z",
"sticky_west": "false"
},
"apply": {
"model": "create:block/radial_chassis_side_z",
@ -207,8 +207,8 @@
},
{
"when": {
"sticky_east": "true",
"axis": "x"
"axis": "x",
"sticky_east": "true"
},
"apply": {
"model": "create:block/radial_chassis_side_x_sticky",
@ -217,8 +217,8 @@
},
{
"when": {
"sticky_east": "true",
"axis": "y"
"axis": "y",
"sticky_east": "true"
},
"apply": {
"model": "create:block/radial_chassis_side_y_sticky",
@ -227,8 +227,8 @@
},
{
"when": {
"sticky_east": "true",
"axis": "z"
"axis": "z",
"sticky_east": "true"
},
"apply": {
"model": "create:block/radial_chassis_side_z_sticky"
@ -236,8 +236,8 @@
},
{
"when": {
"sticky_east": "false",
"axis": "x"
"axis": "x",
"sticky_east": "false"
},
"apply": {
"model": "create:block/radial_chassis_side_x",
@ -246,8 +246,8 @@
},
{
"when": {
"sticky_east": "false",
"axis": "y"
"axis": "y",
"sticky_east": "false"
},
"apply": {
"model": "create:block/radial_chassis_side_y",
@ -256,8 +256,8 @@
},
{
"when": {
"sticky_east": "false",
"axis": "z"
"axis": "z",
"sticky_east": "false"
},
"apply": {
"model": "create:block/radial_chassis_side_z"

View file

@ -94,7 +94,6 @@ import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerB
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.SequencedGearshiftBlock;
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.SequencedGearshiftGenerator;
import com.simibubi.create.content.contraptions.relays.belt.BeltBlock;
import com.simibubi.create.content.contraptions.relays.belt.BeltColor;
import com.simibubi.create.content.contraptions.relays.belt.BeltGenerator;
import com.simibubi.create.content.contraptions.relays.belt.BeltModel;
import com.simibubi.create.content.contraptions.relays.elementary.BracketedKineticBlockModel;
@ -314,7 +313,6 @@ public class AllBlocks {
.properties(p -> p.hardnessAndResistance(0.8F))
.blockstate(new BeltGenerator()::generate)
.transform(StressConfigDefaults.setImpact(1.0))
.onRegister(CreateRegistrate.blockColors(() -> BeltColor::new))
.onRegister(CreateRegistrate.blockModel(() -> BeltModel::new))
.register();

View file

@ -18,44 +18,40 @@ import com.simibubi.create.foundation.block.render.SpriteShifter;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.block.WoodType;
import net.minecraft.item.DyeColor;
public class AllSpriteShifts {
static final Map<WoodType, CTSpriteShiftEntry>
WOODEN_WINDOWS = new IdentityHashMap<>();
static final Map<PaletteStoneVariants, Map<PaletteBlockPatterns.CTs, CTSpriteShiftEntry>>
PALETTE_VARIANT_PATTERNS = new IdentityHashMap<>();
static final Map<WoodType, CTSpriteShiftEntry> WOODEN_WINDOWS = new IdentityHashMap<>();
static final Map<PaletteStoneVariants, Map<PaletteBlockPatterns.CTs, CTSpriteShiftEntry>> PALETTE_VARIANT_PATTERNS =
new IdentityHashMap<>();
public static final CTSpriteShiftEntry
FRAMED_GLASS = getCT(OMNIDIRECTIONAL, "palettes/framed_glass", "palettes/framed_glass"),
public static final Map<DyeColor, SpriteShiftEntry> DYED_BELTS = new IdentityHashMap<>(),
DYED_OFFSET_BELTS = new IdentityHashMap<>(), DYED_DIAGONAL_BELTS = new IdentityHashMap<>();
public static final CTSpriteShiftEntry FRAMED_GLASS =
getCT(OMNIDIRECTIONAL, "palettes/framed_glass", "palettes/framed_glass"),
HORIZONTAL_FRAMED_GLASS = getCT(HORIZONTAL, "palettes/framed_glass", "palettes/horizontal_framed_glass"),
VERTICAL_FRAMED_GLASS = getCT(VERTICAL, "palettes/framed_glass", "palettes/vertical_framed_glass"),
ORNATE_IRON_WINDOW = vertical("palettes/ornate_iron_window");
public static final CTSpriteShiftEntry
CRAFTER_FRONT = getCT(CTType.OMNIDIRECTIONAL, "crafter_top", "brass_casing"),
public static final CTSpriteShiftEntry CRAFTER_FRONT = getCT(CTType.OMNIDIRECTIONAL, "crafter_top", "brass_casing"),
CRAFTER_SIDE = getCT(CTType.VERTICAL, "crafter_side"),
CRAFTER_OTHERSIDE = getCT(CTType.HORIZONTAL, "crafter_side");
public static final CTSpriteShiftEntry
ANDESITE_CASING = omni("andesite_casing"),
BRASS_CASING = omni("brass_casing"),
COPPER_CASING = omni("copper_casing"),
SHADOW_STEEL_CASING = omni("shadow_steel_casing"),
REFINED_RADIANCE_CASING = omni("refined_radiance_casing"),
public static final CTSpriteShiftEntry ANDESITE_CASING = omni("andesite_casing"),
BRASS_CASING = omni("brass_casing"), COPPER_CASING = omni("copper_casing"),
SHADOW_STEEL_CASING = omni("shadow_steel_casing"), REFINED_RADIANCE_CASING = omni("refined_radiance_casing"),
CREATIVE_CASING = getCT(CTType.CROSS, "creative_casing");
public static final CTSpriteShiftEntry
CHASSIS = getCT(CTType.OMNIDIRECTIONAL, "linear_chassis_end"),
public static final CTSpriteShiftEntry CHASSIS = getCT(CTType.OMNIDIRECTIONAL, "linear_chassis_end"),
CHASSIS_STICKY = getCT(CTType.OMNIDIRECTIONAL, "linear_chassis_end_sticky");
public static final CTSpriteShiftEntry
BRASS_TUNNEL_TOP = vertical("brass_tunnel_top"),
public static final CTSpriteShiftEntry BRASS_TUNNEL_TOP = vertical("brass_tunnel_top"),
FLUID_TANK = getCT(CTType.CROSS, "fluid_tank"),
CREATIVE_FLUID_TANK = getCT(CTType.CROSS, "creative_fluid_tank");
public static final SpriteShiftEntry
BELT = SpriteShifter.get("block/belt", "block/belt_animated"),
public static final SpriteShiftEntry BELT = SpriteShifter.get("block/belt", "block/belt_animated"),
BELT_OFFSET = SpriteShifter.get("block/belt_offset", "block/belt_animated"),
BELT_DIAGONAL = SpriteShifter.get("block/belt_diagonal", "block/belt_diagonal_animated"),
ANDESIDE_BELT_CASING = SpriteShifter.get("block/brass_casing_belt", "block/andesite_casing_belt"),
@ -93,6 +89,13 @@ public class AllSpriteShifts {
map.put(texture, getCT(texture.type, target));
}
}
for (DyeColor color : DyeColor.values()) {
String id = color.getName();
DYED_BELTS.put(color, SpriteShifter.get("block/belt", "block/belt/" + id));
DYED_OFFSET_BELTS.put(color, SpriteShifter.get("block/belt_offset", "block/belt/" + id));
DYED_DIAGONAL_BELTS.put(color, SpriteShifter.get("block/belt_diagonal", "block/belt/" + id + "_diagonal"));
}
}
//

View file

@ -9,6 +9,7 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.processing.EmptyingByBasin;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType;
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltMovementHandler.TransportedEntityInfo;
import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock;
@ -31,6 +32,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
@ -62,6 +65,7 @@ import net.minecraft.world.WorldType;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.Tags;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
@ -211,8 +215,19 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
return ActionResultType.PASS;
ItemStack heldItem = player.getHeldItem(handIn);
boolean isShaft = AllBlocks.SHAFT.isIn(heldItem);
boolean isDye = Tags.Items.DYES.contains(heldItem.getItem());
boolean hasWater = EmptyingByBasin.emptyItem(world, heldItem, true)
.getFirst()
.getFluid()
.isEquivalentTo(Fluids.WATER);
boolean isHand = heldItem.isEmpty() && handIn == Hand.MAIN_HAND;
if (isDye || hasWater) {
if (!world.isRemote)
withTileEntityDo(world, pos, te -> te.applyColor(DyeColor.getColor(heldItem)));
return ActionResultType.SUCCESS;
}
BeltTileEntity belt = BeltHelper.getSegmentTE(world, pos);
if (belt == null)
return ActionResultType.PASS;

View file

@ -1,27 +0,0 @@
package com.simibubi.create.content.contraptions.relays.belt;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BeltColor implements IBlockColor {
@Override
public int getColor(BlockState state, ILightReader reader, BlockPos pos, int layer) {
if (reader == null)
return 0;
TileEntity tileEntity = reader.getTileEntity(pos);
if (tileEntity instanceof BeltTileEntity) {
BeltTileEntity te = (BeltTileEntity) tileEntity;
if (te.color != -1)
return te.color;
}
return 0;
}
}

View file

@ -28,6 +28,7 @@ import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.item.DyeColor;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection;
@ -97,14 +98,22 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
SuperByteBuffer beltBuffer = beltPartial.renderOn(blockState)
.light(light);
SpriteShiftEntry spriteShift =
diagonal ? AllSpriteShifts.BELT_DIAGONAL : bottom ? AllSpriteShifts.BELT_OFFSET : AllSpriteShifts.BELT;
SpriteShiftEntry spriteShift = null;
if (te.color.isPresent()) {
DyeColor color = te.color.get();
spriteShift = (diagonal ? AllSpriteShifts.DYED_DIAGONAL_BELTS
: bottom ? AllSpriteShifts.DYED_OFFSET_BELTS : AllSpriteShifts.DYED_BELTS).get(color);
} else
spriteShift = diagonal ? AllSpriteShifts.BELT_DIAGONAL
: bottom ? AllSpriteShifts.BELT_OFFSET : AllSpriteShifts.BELT;
int cycleLength = diagonal ? 12 : 16;
int cycleOffset = bottom ? 8 : 0;
// UV shift
float speed = te.getSpeed();
if (speed != 0) {
if (speed != 0 || te.color.isPresent()) {
float time = renderTick * axisDirection.getOffset();
if (diagonal && (downward ^ alongX) || !sideways && !diagonal && alongX
|| sideways && axisDirection == AxisDirection.NEGATIVE)

View file

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import com.simibubi.create.AllBlocks;
@ -24,7 +25,6 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.block.Block;
@ -54,7 +54,7 @@ import net.minecraftforge.items.IItemHandler;
public class BeltTileEntity extends KineticTileEntity {
public Map<Entity, TransportedEntityInfo> passengers;
public int color;
public Optional<DyeColor> color;
public int beltLength;
public int index;
public Direction lastInsert;
@ -75,7 +75,7 @@ public class BeltTileEntity extends KineticTileEntity {
controller = BlockPos.ZERO;
itemHandler = LazyOptional.empty();
casing = CasingType.NONE;
color = -1;
color = Optional.empty();
}
@Override
@ -182,11 +182,13 @@ public class BeltTileEntity extends KineticTileEntity {
if (controller != null)
compound.put("Controller", NBTUtil.writeBlockPos(controller));
compound.putBoolean("IsController", isController());
compound.putInt("Color", color);
compound.putInt("Length", beltLength);
compound.putInt("Index", index);
NBTHelper.writeEnum(compound, "Casing", casing);
if (color.isPresent())
NBTHelper.writeEnum(compound, "Dye", color.get());
if (isController())
compound.put("Inventory", getInventory().write());
super.write(compound, clientPacket);
@ -199,11 +201,13 @@ public class BeltTileEntity extends KineticTileEntity {
if (compound.getBoolean("IsController"))
controller = pos;
color = compound.contains("Dye") ? Optional.of(NBTHelper.readEnum(compound, "Dye", DyeColor.class))
: Optional.empty();
if (!wasMoved) {
if (!isController())
controller = NBTUtil.readBlockPos(compound.getCompound("Controller"));
trackerUpdateTag = compound;
color = compound.getInt("Color");
beltLength = compound.getInt("Length");
index = compound.getInt("Index");
}
@ -233,12 +237,17 @@ public class BeltTileEntity extends KineticTileEntity {
}
public void applyColor(DyeColor colorIn) {
int colorValue = colorIn.getMapColor().colorValue;
if (colorIn == null) {
if (!color.isPresent())
return;
} else if (color.isPresent() && color.get() == colorIn)
return;
for (BlockPos blockPos : BeltBlock.getBeltChain(world, getController())) {
BeltTileEntity belt = BeltHelper.getSegmentTE(world, blockPos);
if (belt == null)
continue;
belt.color = belt.color == -1 ? colorValue : ColorHelper.mixColors(belt.color, colorValue, .5f);
belt.color = Optional.ofNullable(colorIn);
belt.markDirty();
belt.sendData();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB