mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-05 03:22:37 +01:00
Fix up style cycling
This commit is contained in:
parent
cbd0cf20da
commit
171897bed2
10 changed files with 116 additions and 64 deletions
|
@ -559,7 +559,7 @@ bf2b0310500213ff853c748c236eb5d01f61658e assets/create/blockstates/yellow_toolbo
|
|||
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
|
||||
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
|
||||
f85edc574ee6de0de7693ffb031266643db6724a assets/create/lang/en_ud.json
|
||||
eb624aafc91b284143c3a0cc7d9bbb8de66e8950 assets/create/lang/en_us.json
|
||||
c0b485449804a49390ef01491350a2878b2b57bd assets/create/lang/en_us.json
|
||||
487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json
|
||||
b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json
|
||||
3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
||||
|
|
|
@ -1754,6 +1754,12 @@
|
|||
"enchantment.create.capacity.desc": "Increases Backtank air capacity.",
|
||||
"enchantment.create.potato_recovery.desc": "Potato Cannon projectiles have a chance to be reused.",
|
||||
|
||||
"create.bogey.style.updated_style": "Updated style",
|
||||
"create.bogey.style.updated_style_and_size": "Updated style and size",
|
||||
"create.bogey.style.no_other_sizes": "No other sizes",
|
||||
"create.bogey.style.invalid": "Unnamed style",
|
||||
"create.bogey.style.standard": "Standard",
|
||||
|
||||
|
||||
"_": "->------------------------] Subtitles [------------------------<-",
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.simibubi.create.content.logistics.trains.AbstractBogeyBlock;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer.CommonRenderer;
|
||||
|
@ -16,7 +17,6 @@ import net.minecraft.core.particles.ParticleOptions;
|
|||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -28,20 +28,26 @@ import static com.simibubi.create.Create.LOGGER;
|
|||
|
||||
public class AllBogeyStyles {
|
||||
public static final Map<ResourceLocation, BogeyStyle> BOGEY_STYLES = new HashMap<>();
|
||||
public static final Map<ResourceLocation, Map<ResourceLocation, BogeyStyle>> STYLE_GROUPS = new HashMap<>(); // each set of styles that should be cycled through
|
||||
private static final Map<ResourceLocation, BogeyStyle> EMPTY_GROUP = ImmutableMap.of();
|
||||
|
||||
public static BogeyStyle STANDARD = create("standard")
|
||||
public static Map<ResourceLocation, BogeyStyle> getCycleGroup(ResourceLocation cycleGroup) {
|
||||
return STYLE_GROUPS.getOrDefault(cycleGroup, EMPTY_GROUP);
|
||||
}
|
||||
|
||||
public static BogeyStyle STANDARD = create("standard", "standard")
|
||||
.commonRenderer(CommonStandardBogeyRenderer::new)
|
||||
.displayName(Components.translatable("create.bogeys.styles.standard"))
|
||||
.displayName(Components.translatable("create.bogey.style.standard"))
|
||||
.size(BogeySizes.SMALL, SmallStandardBogeyRenderer::new, AllBlocks.SMALL_BOGEY)
|
||||
.size(BogeySizes.LARGE, LargeStandardBogeyRenderer::new, AllBlocks.LARGE_BOGEY)
|
||||
.build();
|
||||
|
||||
public static BogeyStyleBuilder create(String name) {
|
||||
return create(Create.asResource(name));
|
||||
public static BogeyStyleBuilder create(String name, String cycleGroup) {
|
||||
return create(Create.asResource(name), Create.asResource(cycleGroup));
|
||||
}
|
||||
|
||||
public static BogeyStyleBuilder create(ResourceLocation name) {
|
||||
return new BogeyStyleBuilder(name);
|
||||
public static BogeyStyleBuilder create(ResourceLocation name, ResourceLocation cycleGroup) {
|
||||
return new BogeyStyleBuilder(name, cycleGroup);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
@ -51,16 +57,18 @@ public class AllBogeyStyles {
|
|||
public static class BogeyStyleBuilder {
|
||||
protected final Map<BogeySizes.BogeySize, BogeyStyle.SizeData> sizes = new HashMap<>();
|
||||
protected final ResourceLocation name;
|
||||
protected final ResourceLocation cycleGroup;
|
||||
|
||||
protected Component displayName = Lang.translateDirect("create.bogeys.invalid");
|
||||
protected Component displayName = Lang.translateDirect("bogey.style.invalid");
|
||||
protected ResourceLocation soundType = AllSoundEvents.TRAIN2.getId();
|
||||
protected CompoundTag defaultData = new CompoundTag();
|
||||
protected ParticleOptions contactParticle = ParticleTypes.CRIT;
|
||||
protected ParticleOptions smokeParticle = ParticleTypes.POOF;
|
||||
protected Optional<CommonRenderer> commonRenderer = Optional.empty();
|
||||
|
||||
public BogeyStyleBuilder(ResourceLocation name) {
|
||||
public BogeyStyleBuilder(ResourceLocation name, ResourceLocation cycleGroup) {
|
||||
this.name = name;
|
||||
this.cycleGroup = cycleGroup;
|
||||
}
|
||||
|
||||
public BogeyStyleBuilder displayName(Component displayName) {
|
||||
|
@ -107,8 +115,9 @@ public class AllBogeyStyles {
|
|||
|
||||
public BogeyStyle build() {
|
||||
BogeyStyle entry =
|
||||
new BogeyStyle(name, displayName, soundType, contactParticle, smokeParticle, defaultData, sizes, commonRenderer);
|
||||
new BogeyStyle(name, cycleGroup, displayName, soundType, contactParticle, smokeParticle, defaultData, sizes, commonRenderer);
|
||||
BOGEY_STYLES.put(name, entry);
|
||||
STYLE_GROUPS.computeIfAbsent(cycleGroup, l -> new HashMap<>()).put(name, entry);
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
@ -46,6 +47,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -67,7 +69,11 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
this.size = size;
|
||||
}
|
||||
|
||||
public static void register(ResourceLocation block) {
|
||||
/**
|
||||
* Only for internal Create use. If you have your own style set, do not call this method
|
||||
*/
|
||||
@Deprecated
|
||||
public static void registerStandardBogey(ResourceLocation block) {
|
||||
BOGEYS.add(block);
|
||||
}
|
||||
|
||||
|
@ -124,13 +130,10 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(@Nullable BlockState state, boolean upsideDown, float wheelAngle, PoseStack ms, float partialTicks,
|
||||
MultiBufferSource buffers, int light, int overlay, AbstractBogeyTileEntity sbte) {
|
||||
BogeyStyle style;
|
||||
if (sbte != null) { // on trains, sbte can be null.
|
||||
style = sbte.getStyle();
|
||||
} else {
|
||||
MultiBufferSource buffers, int light, int overlay, BogeyStyle style, CompoundTag bogeyData) {
|
||||
if (style == null)
|
||||
style = getDefaultStyle();
|
||||
}
|
||||
|
||||
final Optional<BogeyRenderer.CommonRenderer> commonRenderer
|
||||
= style.getNewCommonRenderInstance();
|
||||
final BogeyRenderer renderer = style.getInWorldRenderInstance(this.getSize());
|
||||
|
@ -141,15 +144,17 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
}
|
||||
ms.translate(0, -1.5 - 1 / 128f, 0);
|
||||
VertexConsumer vb = buffers.getBuffer(RenderType.cutoutMipped());
|
||||
CompoundTag bogeyData = sbte != null ? sbte.getBogeyData() : new CompoundTag();
|
||||
if (bogeyData == null)
|
||||
bogeyData = new CompoundTag();
|
||||
renderer.render(upsideDown, bogeyData, wheelAngle, ms, light, vb, state == null);
|
||||
CompoundTag finalBogeyData = bogeyData;
|
||||
commonRenderer.ifPresent(common ->
|
||||
common.render(upsideDown, bogeyData, wheelAngle, ms, light, vb, state == null));
|
||||
common.render(upsideDown, finalBogeyData, wheelAngle, ms, light, vb, state == null));
|
||||
}
|
||||
|
||||
public BogeySizes.BogeySize getSize() {
|
||||
return this.size;
|
||||
};
|
||||
}
|
||||
|
||||
public Direction getBogeyUpDirection() {
|
||||
return Direction.UP;
|
||||
|
@ -175,10 +180,6 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
|
||||
if (!player.isShiftKeyDown() && stack.is(AllItems.WRENCH.get()) && !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
&& AllBogeyStyles.BOGEY_STYLES.size() > 1) {
|
||||
Collection<BogeyStyle> styles = AllBogeyStyles.BOGEY_STYLES.values();
|
||||
|
||||
if (styles.size() <= 1)
|
||||
return InteractionResult.PASS;
|
||||
|
||||
BlockEntity be = level.getBlockEntity(pos);
|
||||
|
||||
|
@ -187,9 +188,13 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 20);
|
||||
BogeyStyle currentStyle = sbte.getStyle();
|
||||
|
||||
BogeySizes.BogeySize size = getSize();
|
||||
|
||||
BogeyStyle style = this.getNextStyle(currentStyle);
|
||||
if (style == currentStyle)
|
||||
return InteractionResult.PASS;
|
||||
|
||||
Set<BogeySizes.BogeySize> validSizes = style.validSizes();
|
||||
|
||||
for (int i = 0; i < BogeySizes.count(); i++) {
|
||||
|
@ -203,8 +208,8 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
sbte.setBogeyData(sbte.getBogeyData().merge(defaultData));
|
||||
|
||||
if (size == getSize()) {
|
||||
player.displayClientMessage(Lang.translateDirect("create.bogey.style.updated_style")
|
||||
.append(": " + style.displayName), true);
|
||||
player.displayClientMessage(Lang.translateDirect("bogey.style.updated_style")
|
||||
.append(": ").append(style.displayName), true);
|
||||
} else {
|
||||
CompoundTag oldData = sbte.getBogeyData();
|
||||
level.setBlock(pos, this.getStateOfSize(sbte, size), 3);
|
||||
|
@ -212,8 +217,8 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
if (!(newBlockEntity instanceof AbstractBogeyTileEntity newTileEntity))
|
||||
return InteractionResult.FAIL;
|
||||
newTileEntity.setBogeyData(oldData);
|
||||
player.displayClientMessage(Lang.translateDirect("create.bogey.style.updated_style_and_size")
|
||||
.append(": " + style.displayName), true);
|
||||
player.displayClientMessage(Lang.translateDirect("bogey.style.updated_style_and_size")
|
||||
.append(": ").append(style.displayName), true);
|
||||
}
|
||||
|
||||
return InteractionResult.CONSUME;
|
||||
|
@ -222,28 +227,34 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* If, instead of using the style-based cycling system you prefer to use separate blocks, return them from this method
|
||||
*/
|
||||
protected List<ResourceLocation> getBogeyBlockCycle() {
|
||||
return BOGEYS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getRotatedBlockState(BlockState state, Direction targetedFace) {
|
||||
Block block = state.getBlock();
|
||||
int indexOf = BOGEYS.indexOf(RegisteredObjects.getKeyOrThrow(block));
|
||||
List<ResourceLocation> bogeyCycle = getBogeyBlockCycle();
|
||||
int indexOf = bogeyCycle.indexOf(RegisteredObjects.getKeyOrThrow(block));
|
||||
if (indexOf == -1)
|
||||
return state;
|
||||
int index = (indexOf + 1) % BOGEYS.size();
|
||||
int index = (indexOf + 1) % bogeyCycle.size();
|
||||
Direction bogeyUpDirection = getBogeyUpDirection();
|
||||
boolean trackAxisAlongFirstCoordinate = isTrackAxisAlongFirstCoordinate(state);
|
||||
|
||||
while (index != indexOf) {
|
||||
ResourceLocation id = BOGEYS.get(index);
|
||||
ResourceLocation id = bogeyCycle.get(index);
|
||||
Block newBlock = ForgeRegistries.BLOCKS.getValue(id);
|
||||
if (newBlock instanceof AbstractBogeyBlock bogey) {
|
||||
if (newBlock instanceof AbstractBogeyBlock<?> bogey) {
|
||||
BlockState matchingBogey = bogey.getMatchingBogey(bogeyUpDirection, trackAxisAlongFirstCoordinate);
|
||||
if (matchingBogey != null)
|
||||
return matchingBogey.hasProperty(WATERLOGGED)
|
||||
? matchingBogey.setValue(WATERLOGGED, state.getValue(WATERLOGGED))
|
||||
: matchingBogey;
|
||||
return copyProperties(state, matchingBogey);
|
||||
}
|
||||
index = (index + 1) % BOGEYS.size();
|
||||
index = (index + 1) % bogeyCycle.size();
|
||||
}
|
||||
|
||||
return state;
|
||||
|
@ -256,21 +267,39 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
return level.getBlockState(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of BlockState Properties to copy between sizes
|
||||
*/
|
||||
public List<Property<?>> propertiesToCopy() {
|
||||
return ImmutableList.of(WATERLOGGED, AXIS);
|
||||
}
|
||||
|
||||
// generic method needed to satisfy Property and BlockState's generic requirements
|
||||
private <V extends Comparable<V>> BlockState copyProperty(BlockState source, BlockState target, Property<V> property) {
|
||||
if (source.hasProperty(property) && target.hasProperty(property)) {
|
||||
return target.setValue(property, source.getValue(property));
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
private BlockState copyProperties(BlockState source, BlockState target) {
|
||||
for (Property<?> property : propertiesToCopy())
|
||||
target = copyProperty(source, target, property);
|
||||
return target;
|
||||
}
|
||||
|
||||
public BlockState getNextSize(AbstractBogeyTileEntity sbte) {
|
||||
BogeySizes.BogeySize size = this.getSize();
|
||||
BogeyStyle style = sbte.getStyle();
|
||||
BlockState nextBlock = style.getNextBlock(size).defaultBlockState();
|
||||
return nextBlock.hasProperty(WATERLOGGED)
|
||||
? nextBlock.setValue(WATERLOGGED, sbte.getBlockState().getValue(WATERLOGGED))
|
||||
: nextBlock;
|
||||
nextBlock = copyProperties(sbte.getBlockState(), nextBlock);
|
||||
return nextBlock;
|
||||
}
|
||||
|
||||
public BlockState getStateOfSize(AbstractBogeyTileEntity sbte, BogeySizes.BogeySize size) {
|
||||
BogeyStyle style = sbte.getStyle();
|
||||
BlockState state = style.getBlockOfSize(size).defaultBlockState();
|
||||
return state.hasProperty(WATERLOGGED)
|
||||
? state.setValue(WATERLOGGED, sbte.getBlockState().getValue(WATERLOGGED))
|
||||
: state;
|
||||
return copyProperties(sbte.getBlockState(), state);
|
||||
}
|
||||
|
||||
public BogeyStyle getNextStyle(Level level, BlockPos pos) {
|
||||
|
@ -281,7 +310,7 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
}
|
||||
|
||||
public BogeyStyle getNextStyle(BogeyStyle style) {
|
||||
Collection<BogeyStyle> allStyles = AllBogeyStyles.BOGEY_STYLES.values();
|
||||
Collection<BogeyStyle> allStyles = style.getCycleGroup().values();
|
||||
if (allStyles.size() <= 1)
|
||||
return style;
|
||||
List<BogeyStyle> list = new ArrayList<>(allStyles);
|
||||
|
|
|
@ -19,8 +19,8 @@ public class BogeyTileEntityRenderer<T extends BlockEntity> extends SafeTileEnti
|
|||
BlockState blockState = te.getBlockState();
|
||||
if (te instanceof AbstractBogeyTileEntity sbte) {
|
||||
float angle = sbte.getVirtualAngle(partialTicks);
|
||||
if (blockState.getBlock() instanceof AbstractBogeyBlock bogey)
|
||||
bogey.render(blockState, bogey.isUpsideDown(blockState), angle, ms, partialTicks, buffer, light, overlay, sbte);
|
||||
if (blockState.getBlock() instanceof AbstractBogeyBlock<?> bogey)
|
||||
bogey.render(blockState, bogey.isUpsideDown(blockState), angle, ms, partialTicks, buffer, light, overlay, sbte.getStyle(), sbte.getBogeyData());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.content.logistics.trains.entity;
|
||||
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.simibubi.create.AllBogeyStyles;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
|
||||
|
@ -25,6 +26,7 @@ import java.util.stream.Stream;
|
|||
|
||||
public class BogeyStyle {
|
||||
public final ResourceLocation name;
|
||||
public final ResourceLocation cycleGroup;
|
||||
private final Optional<CommonRenderer> commonRenderer;
|
||||
private final Map<BogeySizes.BogeySize, SizeData> sizes;
|
||||
public final Component displayName;
|
||||
|
@ -33,9 +35,10 @@ public class BogeyStyle {
|
|||
public final ParticleOptions smokeParticle;
|
||||
public final CompoundTag defaultData;
|
||||
|
||||
public BogeyStyle(ResourceLocation name, Component displayName, ResourceLocation soundType, ParticleOptions contactParticle, ParticleOptions smokeParticle,
|
||||
public BogeyStyle(ResourceLocation name, ResourceLocation cycleGroup, Component displayName, ResourceLocation soundType, ParticleOptions contactParticle, ParticleOptions smokeParticle,
|
||||
CompoundTag defaultData, Map<BogeySizes.BogeySize, SizeData> sizes, Optional<CommonRenderer> commonRenderer) {
|
||||
this.name = name;
|
||||
this.cycleGroup = cycleGroup;
|
||||
this.displayName = displayName;
|
||||
this.soundType = soundType;
|
||||
this.contactParticle = contactParticle;
|
||||
|
@ -46,6 +49,10 @@ public class BogeyStyle {
|
|||
this.commonRenderer = commonRenderer;
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, BogeyStyle> getCycleGroup() {
|
||||
return AllBogeyStyles.getCycleGroup(cycleGroup);
|
||||
}
|
||||
|
||||
public Block getNextBlock(BogeySizes.BogeySize currentSize) {
|
||||
return Stream.iterate(currentSize.increment(), BogeySizes.BogeySize::increment)
|
||||
.filter(sizes::containsKey)
|
||||
|
|
|
@ -7,8 +7,6 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionEntityRenderer;
|
||||
|
||||
import com.simibubi.create.content.logistics.trains.track.AbstractBogeyTileEntity;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
|
@ -68,10 +66,9 @@ public class CarriageContraptionEntityRenderer extends ContraptionEntityRenderer
|
|||
translateBogey(ms, bogey, bogeySpacing, viewYRot, viewXRot, partialTicks);
|
||||
|
||||
int light = getBogeyLightCoords(entity, bogey, partialTicks);
|
||||
BlockEntity be = entity.getContraption().presentTileEntities.get(bogeyPos);
|
||||
|
||||
bogey.type.render(null, bogey.isUpsideDown(), bogey.wheelAngle.getValue(partialTicks), ms, partialTicks, buffers, light,
|
||||
overlay, (AbstractBogeyTileEntity) be);
|
||||
overlay, bogey.getStyle(), bogey.bogeyData);
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
Direction assemblyDirection;
|
||||
int assemblyLength;
|
||||
int[] bogeyLocations;
|
||||
AbstractBogeyBlock[] bogeyTypes;
|
||||
AbstractBogeyBlock<?>[] bogeyTypes;
|
||||
boolean[] upsideDownBogeys;
|
||||
int bogeyCount;
|
||||
|
||||
|
@ -285,7 +285,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
CompoundTag oldData = oldTE.getBogeyData();
|
||||
BlockState newBlock = bogey.getNextSize(oldTE);
|
||||
if (newBlock.getBlock() == bogey)
|
||||
player.displayClientMessage(Lang.translateDirect("create.bogey.style.no_other_sizes")
|
||||
player.displayClientMessage(Lang.translateDirect("bogey.style.no_other_sizes")
|
||||
.withStyle(ChatFormatting.RED), true);
|
||||
level.setBlock(bogeyPos, newBlock, 3);
|
||||
BlockEntity newEntity = level.getBlockEntity(bogeyPos);
|
||||
|
@ -307,7 +307,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean upsideDown = (player.getViewXRot(1.0F) < 0 && (track.getBogeyAnchor(level, pos, state)).getBlock() instanceof AbstractBogeyBlock bogey && bogey.canBeUpsideDown());
|
||||
boolean upsideDown = (player.getViewXRot(1.0F) < 0 && (track.getBogeyAnchor(level, pos, state)).getBlock() instanceof AbstractBogeyBlock<?> bogey && bogey.canBeUpsideDown());
|
||||
|
||||
BlockPos targetPos = upsideDown ? pos.offset(down) : pos.offset(up);
|
||||
if (level.getBlockState(targetPos)
|
||||
|
@ -318,7 +318,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
level.destroyBlock(targetPos, true);
|
||||
|
||||
BlockState bogeyAnchor = track.getBogeyAnchor(level, pos, state);
|
||||
if (bogeyAnchor.getBlock() instanceof AbstractBogeyBlock bogey) {
|
||||
if (bogeyAnchor.getBlock() instanceof AbstractBogeyBlock<?> bogey) {
|
||||
bogeyAnchor = bogey.getVersion(bogeyAnchor, upsideDown);
|
||||
}
|
||||
bogeyAnchor = ProperWaterloggedBlock.withWater(level, bogeyAnchor, pos);
|
||||
|
@ -415,12 +415,12 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
BlockState potentialBogeyState = level.getBlockState(bogeyOffset.offset(currentPos));
|
||||
BlockPos upsideDownBogeyOffset = new BlockPos(bogeyOffset.getX(), bogeyOffset.getY()*-1, bogeyOffset.getZ());
|
||||
if (bogeyIndex < bogeyLocations.length) {
|
||||
if (potentialBogeyState.getBlock() instanceof AbstractBogeyBlock bogey && !bogey.isUpsideDown(potentialBogeyState)) {
|
||||
if (potentialBogeyState.getBlock() instanceof AbstractBogeyBlock<?> bogey && !bogey.isUpsideDown(potentialBogeyState)) {
|
||||
bogeyTypes[bogeyIndex] = bogey;
|
||||
bogeyLocations[bogeyIndex] = i;
|
||||
upsideDownBogeys[bogeyIndex] = false;
|
||||
bogeyIndex++;
|
||||
} else if ((potentialBogeyState = level.getBlockState(upsideDownBogeyOffset.offset(currentPos))).getBlock() instanceof AbstractBogeyBlock bogey && bogey.isUpsideDown(potentialBogeyState)) {
|
||||
} else if ((potentialBogeyState = level.getBlockState(upsideDownBogeyOffset.offset(currentPos))).getBlock() instanceof AbstractBogeyBlock<?> bogey && bogey.isUpsideDown(potentialBogeyState)) {
|
||||
bogeyTypes[bogeyIndex] = bogey;
|
||||
bogeyLocations[bogeyIndex] = i;
|
||||
upsideDownBogeys[bogeyIndex] = true;
|
||||
|
@ -629,7 +629,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
return;
|
||||
}
|
||||
|
||||
AbstractBogeyBlock typeOfFirstBogey = bogeyTypes[bogeyIndex];
|
||||
AbstractBogeyBlock<?> typeOfFirstBogey = bogeyTypes[bogeyIndex];
|
||||
boolean firstBogeyIsUpsideDown = upsideDownBogeys[bogeyIndex];
|
||||
BlockPos firstBogeyPos = contraption.anchor;
|
||||
AbstractBogeyTileEntity firstBogeyTileEntity = (AbstractBogeyTileEntity) level.getBlockEntity(firstBogeyPos);
|
||||
|
@ -637,9 +637,6 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
new CarriageBogey(typeOfFirstBogey, firstBogeyIsUpsideDown, firstBogeyTileEntity.getBogeyData(), points.get(pointIndex), points.get(pointIndex + 1));
|
||||
CarriageBogey secondBogey = null;
|
||||
BlockPos secondBogeyPos = contraption.getSecondBogeyPos();
|
||||
/*if (secondBogeyPos != null && (bogeyIndex + 1 < upsideDownBogeys.length && upsideDownBogeys[bogeyIndex + 1])) {
|
||||
secondBogeyPos = secondBogeyPos.above(2);
|
||||
}*/
|
||||
int bogeySpacing = 0;
|
||||
|
||||
if (secondBogeyPos != null) {
|
||||
|
|
|
@ -80,6 +80,7 @@ public class BuilderTransformers {
|
|||
.build();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static <B extends StandardBogeyBlock, P> NonNullUnaryOperator<BlockBuilder<B, P>> bogey() {
|
||||
return b -> b.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
|
||||
|
@ -88,7 +89,7 @@ public class BuilderTransformers {
|
|||
.blockstate((c, p) -> BlockStateGen.horizontalAxisBlock(c, p, s -> p.models()
|
||||
.getExistingFile(p.modLoc("block/track/bogey/top"))))
|
||||
.loot((p, l) -> p.dropOther(l, AllBlocks.RAILWAY_CASING.get()))
|
||||
.onRegister(block -> AbstractBogeyBlock.register(RegisteredObjects.getKeyOrThrow(block)));
|
||||
.onRegister(block -> AbstractBogeyBlock.registerStandardBogey(RegisteredObjects.getKeyOrThrow(block)));
|
||||
}
|
||||
|
||||
public static <B extends TrapDoorBlock, P> NonNullUnaryOperator<BlockBuilder<B, P>> trapdoor(boolean orientable) {
|
||||
|
|
|
@ -920,8 +920,14 @@
|
|||
|
||||
"create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up",
|
||||
"create.contraption.minecart_contraption_illegal_pickup": "A mystical force is binding this Cart Contraption to the world",
|
||||
|
||||
|
||||
"enchantment.create.capacity.desc": "Increases Backtank air capacity.",
|
||||
"enchantment.create.potato_recovery.desc": "Potato Cannon projectiles have a chance to be reused."
|
||||
"enchantment.create.potato_recovery.desc": "Potato Cannon projectiles have a chance to be reused.",
|
||||
|
||||
"create.bogey.style.updated_style": "Updated style",
|
||||
"create.bogey.style.updated_style_and_size": "Updated style and size",
|
||||
"create.bogey.style.no_other_sizes": "No other sizes",
|
||||
"create.bogey.style.invalid": "Unnamed style",
|
||||
"create.bogey.style.standard": "Standard"
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue