mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-05 03:12:38 +01:00
Refactored Bogey Sizes To Seperate Class
This commit is contained in:
parent
129be61fee
commit
1e80af3303
11 changed files with 122 additions and 95 deletions
|
@ -208,6 +208,7 @@ import com.simibubi.create.content.logistics.block.vault.ItemVaultCTBehaviour;
|
|||
import com.simibubi.create.content.logistics.block.vault.ItemVaultItem;
|
||||
import com.simibubi.create.content.logistics.item.LecternControllerBlock;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.BogeySizes;
|
||||
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayBlock;
|
||||
import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgePointType;
|
||||
import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBlockItem;
|
||||
|
@ -668,7 +669,7 @@ public class AllBlocks {
|
|||
.onRegister(movementBehaviour(new BlazeBurnerMovementBehaviour()))
|
||||
.onRegister(interactionBehaviour(new BlazeBurnerInteractionBehaviour()))
|
||||
.item(BlazeBurnerBlockItem::withBlaze)
|
||||
.model(AssetLookup.<BlazeBurnerBlockItem>customBlockItemModel("blaze_burner", "block_with_blaze"))
|
||||
.model(AssetLookup.customBlockItemModel("blaze_burner", "block_with_blaze"))
|
||||
.build()
|
||||
.register();
|
||||
|
||||
|
@ -927,7 +928,7 @@ public class AllBlocks {
|
|||
.onRegister(assignDataBehaviour(new BoilerDisplaySource(), "boiler_status"))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.item(FluidTankItem::new)
|
||||
.model(AssetLookup.<FluidTankItem>customBlockItemModel("_", "block_single_window"))
|
||||
.model(AssetLookup.customBlockItemModel("_", "block_single_window"))
|
||||
.build()
|
||||
.register();
|
||||
|
||||
|
@ -1579,13 +1580,13 @@ public class AllBlocks {
|
|||
.register();
|
||||
|
||||
public static final BlockEntry<StandardBogeyBlock> SMALL_BOGEY =
|
||||
REGISTRATE.block("small_bogey", p -> new StandardBogeyBlock(p, BogeyRenderer.BogeySize.SMALL))
|
||||
REGISTRATE.block("small_bogey", p -> new StandardBogeyBlock(p, BogeySizes.SMALL))
|
||||
.properties(p -> p.color(MaterialColor.PODZOL))
|
||||
.transform(BuilderTransformers.bogey())
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<StandardBogeyBlock> LARGE_BOGEY =
|
||||
REGISTRATE.block("large_bogey", p -> new StandardBogeyBlock(p, BogeyRenderer.BogeySize.LARGE))
|
||||
REGISTRATE.block("large_bogey", p -> new StandardBogeyBlock(p, BogeySizes.LARGE))
|
||||
.properties(p -> p.color(MaterialColor.PODZOL))
|
||||
.transform(BuilderTransformers.bogey())
|
||||
.register();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.BogeySizes;
|
||||
import com.simibubi.create.content.logistics.trains.StandardBogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.TestBogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.entity.BogeyStyle;
|
||||
|
@ -14,25 +15,11 @@ import static com.simibubi.create.Create.REGISTRATE;
|
|||
public class AllBogeyStyles {
|
||||
public static final RegistryEntry<BogeyStyle> STANDARD = REGISTRATE
|
||||
.bogeyStyle("standard", new BogeyStyle())
|
||||
.block(BogeyRenderer.BogeySize.SMALL, AllBlocks.SMALL_BOGEY)
|
||||
.block(BogeyRenderer.BogeySize.LARGE, AllBlocks.LARGE_BOGEY)
|
||||
.block(BogeySizes.SMALL, AllBlocks.SMALL_BOGEY)
|
||||
.block(BogeySizes.LARGE, AllBlocks.LARGE_BOGEY)
|
||||
.renderer(new StandardBogeyRenderer())
|
||||
.register();
|
||||
|
||||
public static final RegistryEntry<BogeyStyle> TEST = REGISTRATE
|
||||
.bogeyStyle("test", new BogeyStyle())
|
||||
.block(BogeyRenderer.BogeySize.SMALL, AllBlocks.SMALL_BOGEY)
|
||||
.block(BogeyRenderer.BogeySize.LARGE, AllBlocks.LARGE_BOGEY)
|
||||
.renderer(new TestBogeyRenderer())
|
||||
.register();
|
||||
|
||||
public static final RegistryEntry<BogeyStyle> TEST_TWO = REGISTRATE
|
||||
.bogeyStyle("test_two", new BogeyStyle())
|
||||
.block(BogeyRenderer.BogeySize.SMALL, AllBlocks.SMALL_BOGEY)
|
||||
.block(BogeyRenderer.BogeySize.LARGE, AllBlocks.LARGE_BOGEY)
|
||||
.renderer(new TestBogeyRenderer())
|
||||
.register();
|
||||
|
||||
public static void register() {
|
||||
LOGGER.info("Registered bogey styles from " + Create.ID);
|
||||
AllRegistries.DEFERRED_BOGEY_REGISTRY.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.simibubi.create;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.simibubi.create.content.logistics.trains.BogeySizes;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
@ -121,6 +123,7 @@ public class Create {
|
|||
AllFeatures.register(modEventBus);
|
||||
AllPlacementModifiers.register(modEventBus);
|
||||
BuiltinRegistration.register(modEventBus);
|
||||
BogeySizes.init();
|
||||
AllBogeyStyles.register();
|
||||
|
||||
AllConfigs.register(modLoadingContext);
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Collection;
|
|||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -19,7 +18,6 @@ import com.simibubi.create.AllItems;
|
|||
import com.simibubi.create.AllRegistries;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.content.logistics.trains.entity.BogeyStyle;
|
||||
import com.simibubi.create.content.logistics.trains.track.StandardBogeyBlock;
|
||||
import com.simibubi.create.content.logistics.trains.track.StandardBogeyTileEntity;
|
||||
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
|
||||
import com.simibubi.create.content.schematics.ItemRequirement;
|
||||
|
@ -120,7 +118,7 @@ public abstract class AbstractBogeyBlock extends Block implements ITE<StandardBo
|
|||
renderer.render(sbte.getBogeyData(), wheelAngle, ms, light, vb, getSize());
|
||||
}
|
||||
|
||||
public abstract BogeyRenderer.BogeySize getSize();
|
||||
public abstract BogeySizes.BogeySize getSize();
|
||||
|
||||
public Direction getBogeyUpDirection() {
|
||||
return Direction.UP;
|
||||
|
@ -158,12 +156,12 @@ public abstract class AbstractBogeyBlock extends Block implements ITE<StandardBo
|
|||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 20);
|
||||
BogeyStyle currentStyle = sbte.getStyle();
|
||||
BogeyRenderer.BogeySize size = getSize();
|
||||
BogeySizes.BogeySize size = getSize();
|
||||
|
||||
BogeyStyle style = this.getNextStyle(currentStyle);
|
||||
Set<BogeyRenderer.BogeySize> validSizes = style.validSizes();
|
||||
Set<BogeySizes.BogeySize> validSizes = style.validSizes();
|
||||
|
||||
for (int i = 0; i < BogeyRenderer.BogeySize.values().length; i++) {
|
||||
for (int i = 0; i < BogeySizes.count(); i++) {
|
||||
if (validSizes.contains(size)) break;
|
||||
size = size.increment();
|
||||
}
|
||||
|
@ -222,7 +220,7 @@ public abstract class AbstractBogeyBlock extends Block implements ITE<StandardBo
|
|||
}
|
||||
|
||||
public BlockState getNextSize(StandardBogeyTileEntity sbte) {
|
||||
BogeyRenderer.BogeySize size = this.getSize();
|
||||
BogeySizes.BogeySize size = this.getSize();
|
||||
BogeyStyle style = sbte.getStyle();
|
||||
BlockState nextBlock = style.getNextBlock(size).defaultBlockState();
|
||||
return nextBlock.hasProperty(WATERLOGGED)
|
||||
|
@ -230,7 +228,7 @@ public abstract class AbstractBogeyBlock extends Block implements ITE<StandardBo
|
|||
: nextBlock;
|
||||
}
|
||||
|
||||
public BlockState getStateOfSize(StandardBogeyTileEntity sbte, BogeyRenderer.BogeySize size) {
|
||||
public BlockState getStateOfSize(StandardBogeyTileEntity sbte, BogeySizes.BogeySize size) {
|
||||
BogeyStyle style = sbte.getStyle();
|
||||
BlockState state = style.getBlockOfSize(size).defaultBlockState();
|
||||
return state.hasProperty(WATERLOGGED)
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.util.Set;
|
|||
// Seperate From BogeyInstance So It Can Be Used Inworld
|
||||
|
||||
public abstract class BogeyRenderer {
|
||||
Map<BogeySize, Renderer> renderers = new EnumMap<>(BogeySize.class);
|
||||
Map<BogeySizes.BogeySize, Renderer> renderers = new HashMap<>();
|
||||
Map<String, ModelData[]> contraptionModelData = new HashMap<>();
|
||||
|
||||
public Transform<?>[] getTransformsFromPartial(PartialModel model, PoseStack ms, boolean inContraption, int size) {
|
||||
|
@ -85,7 +85,7 @@ public abstract class BogeyRenderer {
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract void initialiseContraptionModelData(MaterialManager materialManager, BogeySize size);
|
||||
public abstract void initialiseContraptionModelData(MaterialManager materialManager, BogeySizes.BogeySize size);
|
||||
|
||||
public void createModelInstances(MaterialManager materialManager, PartialModel model, int count) {
|
||||
ModelData[] modelData = new ModelData[count];
|
||||
|
@ -108,13 +108,13 @@ public abstract class BogeyRenderer {
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(CompoundTag bogeyData, float wheelAngle, PoseStack ms, int light, @Nullable VertexConsumer vb,
|
||||
BogeySize size) {
|
||||
BogeySizes.BogeySize size) {
|
||||
renderCommon(bogeyData, wheelAngle, ms, light, vb);
|
||||
renderers.get(size).render(bogeyData, wheelAngle, ms, light, vb);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(CompoundTag bogeyData, float wheelAngle, PoseStack ms, BogeySize size) {
|
||||
public void render(CompoundTag bogeyData, float wheelAngle, PoseStack ms, BogeySizes.BogeySize size) {
|
||||
this.render(bogeyData, wheelAngle, ms, 0, null, size);
|
||||
}
|
||||
|
||||
|
@ -128,11 +128,11 @@ public abstract class BogeyRenderer {
|
|||
byteBuf.light(light).renderInto(ms, vb);
|
||||
}
|
||||
|
||||
public boolean styleImplementsSize(BogeySize size) {
|
||||
public boolean styleImplementsSize(BogeySizes.BogeySize size) {
|
||||
return this.renderers.containsKey(size);
|
||||
}
|
||||
|
||||
public Set<BogeySize> implementedSizes() {
|
||||
public Set<BogeySizes.BogeySize> implementedSizes() {
|
||||
return renderers.keySet();
|
||||
}
|
||||
|
||||
|
@ -169,13 +169,4 @@ public abstract class BogeyRenderer {
|
|||
interface Renderer {
|
||||
void render(CompoundTag bogeyData, float wheelAngle, PoseStack ms, int light, VertexConsumer vb);
|
||||
}
|
||||
|
||||
// TODO: REPLACE THIS SO THAT IT CAN BE ADDED TO
|
||||
public enum BogeySize {
|
||||
SMALL, LARGE;
|
||||
|
||||
public BogeySize increment() {
|
||||
return values()[(ordinal() + 1) % values().length];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package com.simibubi.create.content.logistics.trains;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BogeySizes {
|
||||
private static final Collection<BogeySize> BOGEY_SIZES = new HashSet<>();
|
||||
public static final BogeySize SMALL = new BogeySize(Create.ID, "small", 6.5f / 16f);
|
||||
public static final BogeySize LARGE = new BogeySize(Create.ID, "large", 12.5f / 16f);
|
||||
|
||||
static {
|
||||
BOGEY_SIZES.add(SMALL);
|
||||
BOGEY_SIZES.add(LARGE);
|
||||
}
|
||||
|
||||
public static void addSize(String modId, String name, float size) {
|
||||
ResourceLocation location = new ResourceLocation(modId, name);
|
||||
addSize(location, size);
|
||||
}
|
||||
|
||||
public static void addSize(ResourceLocation location, float size) {
|
||||
BogeySize customSize = new BogeySize(location, size);
|
||||
BOGEY_SIZES.add(customSize);
|
||||
}
|
||||
|
||||
public static List<BogeySize> getAllSizesSmallToLarge() {
|
||||
return BOGEY_SIZES.stream()
|
||||
.sorted(Comparator.comparing(BogeySize::wheelRadius))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<BogeySize> getAllSizesLargeToSmall() {
|
||||
List<BogeySize> sizes = getAllSizesSmallToLarge();
|
||||
Collections.reverse(sizes);
|
||||
return sizes;
|
||||
}
|
||||
|
||||
public static int count() {
|
||||
return BOGEY_SIZES.size();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
||||
}
|
||||
|
||||
public record BogeySize(ResourceLocation location, Float wheelRadius) {
|
||||
public BogeySize(String modId, String name, float wheelRadius) {
|
||||
this(new ResourceLocation(modId, name), wheelRadius);
|
||||
}
|
||||
|
||||
public BogeySize increment() {
|
||||
List<BogeySize> values = getAllSizesSmallToLarge();
|
||||
int ordinal = values.indexOf(this);
|
||||
return values.get((ordinal + 1) % values.size());
|
||||
}
|
||||
|
||||
public boolean is(BogeySize size) {
|
||||
return size.location == this.location;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,12 @@
|
|||
package com.simibubi.create.content.logistics.trains;
|
||||
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.Transform;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
||||
import com.simibubi.create.content.logistics.trains.entity.BogeyInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
|
@ -18,24 +15,22 @@ import net.minecraft.nbt.CompoundTag;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.simibubi.create.AllBlockPartials.COGWHEEL_SHAFT;
|
||||
import static com.simibubi.create.AllBlockPartials.LARGE_BOGEY_WHEELS;
|
||||
import static com.simibubi.create.AllBlockPartials.BOGEY_PIN;
|
||||
import static com.simibubi.create.AllBlockPartials.BOGEY_DRIVE;
|
||||
import static com.simibubi.create.AllBlockPartials.BOGEY_PISTON;
|
||||
import static com.simibubi.create.AllBlockPartials.SHAFT_HALF;
|
||||
import static com.simibubi.create.AllBlockPartials.SMALL_BOGEY_WHEELS;
|
||||
import static com.simibubi.create.AllBlockPartials.BOGEY_FRAME;
|
||||
|
||||
public class StandardBogeyRenderer extends BogeyRenderer {
|
||||
|
||||
public StandardBogeyRenderer() {
|
||||
renderers.put(BogeySize.SMALL, this::renderSmall);
|
||||
renderers.put(BogeySize.LARGE, this::renderLarge);
|
||||
renderers.put(BogeySizes.SMALL, this::renderSmall);
|
||||
renderers.put(BogeySizes.LARGE, this::renderLarge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseContraptionModelData(MaterialManager materialManager, BogeySize size) {
|
||||
public void initialiseContraptionModelData(MaterialManager materialManager, BogeySizes.BogeySize size) {
|
||||
// Large
|
||||
createModelInstances(materialManager, LARGE_BOGEY_WHEELS, BOGEY_DRIVE, BOGEY_PISTON, BOGEY_PIN);
|
||||
createModelInstances(materialManager, AllBlocks.SHAFT.getDefaultState()
|
||||
|
|
|
@ -1,36 +1,25 @@
|
|||
package com.simibubi.create.content.logistics.trains.entity;
|
||||
|
||||
import com.jozufozu.flywheel.api.Material;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.AnimationTickHolder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import com.simibubi.create.content.logistics.trains.BogeySizes;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class BogeyInstance {
|
||||
|
||||
public final CarriageBogey bogey;
|
||||
public final BogeyRenderer renderer;
|
||||
private final BogeyRenderer.BogeySize size;
|
||||
private final BogeySizes.BogeySize size;
|
||||
|
||||
public BogeyInstance(CarriageBogey bogey, BogeyRenderer renderer, BogeyRenderer.BogeySize size,
|
||||
public BogeyInstance(CarriageBogey bogey, BogeyRenderer renderer, BogeySizes.BogeySize size,
|
||||
MaterialManager materialManager) {
|
||||
this.bogey = bogey;
|
||||
this.renderer = renderer;
|
||||
|
@ -39,7 +28,7 @@ public final class BogeyInstance {
|
|||
renderer.initialiseContraptionModelData(materialManager, size);
|
||||
}
|
||||
|
||||
protected void hiddenFrame() {
|
||||
void hiddenFrame() {
|
||||
beginFrame(0, null);
|
||||
}
|
||||
|
||||
|
@ -50,7 +39,7 @@ public final class BogeyInstance {
|
|||
}
|
||||
|
||||
renderer.render(new CompoundTag(), wheelAngle, ms, this.size);
|
||||
};
|
||||
}
|
||||
|
||||
public void updateLight(BlockAndTintGetter world, CarriageContraptionEntity entity) {
|
||||
var lightPos = new BlockPos(getLightPos(entity));
|
||||
|
@ -65,7 +54,7 @@ public final class BogeyInstance {
|
|||
|
||||
@FunctionalInterface
|
||||
interface BogeyInstanceFactory {
|
||||
BogeyInstance create(CarriageBogey bogey, BogeyRenderer.BogeySize size,
|
||||
BogeyInstance create(CarriageBogey bogey, BogeySizes.BogeySize size,
|
||||
MaterialManager materialManager);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,15 @@ package com.simibubi.create.content.logistics.trains.entity;
|
|||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer.BogeySize;
|
||||
import com.simibubi.create.content.logistics.trains.AbstractBogeyBlock;
|
||||
|
||||
import com.simibubi.create.content.logistics.trains.BogeySizes;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
@ -19,56 +19,51 @@ import net.minecraftforge.registries.IForgeRegistryEntry;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public final class BogeyStyle extends ForgeRegistryEntry<BogeyStyle> implements IForgeRegistryEntry<BogeyStyle> {
|
||||
public Map<BogeySize, ResourceLocation> blocks = new EnumMap<>(BogeySize.class);
|
||||
public Map<BogeySizes.BogeySize, ResourceLocation> blocks = new HashMap<>();
|
||||
public Component displayName;
|
||||
public ResourceLocation soundType;
|
||||
public CompoundTag defaultData;
|
||||
public BogeyRenderer renderer;
|
||||
|
||||
public <T extends AbstractBogeyBlock> void addBlockForSize(BogeySize size, T block) {
|
||||
public <T extends AbstractBogeyBlock> void addBlockForSize(BogeySizes.BogeySize size, T block) {
|
||||
this.addBlockForSize(size, block.getRegistryName());
|
||||
}
|
||||
|
||||
public void addBlockForSize(BogeySize size, ResourceLocation location) {
|
||||
public void addBlockForSize(BogeySizes.BogeySize size, ResourceLocation location) {
|
||||
blocks.put(size, location);
|
||||
}
|
||||
|
||||
public Block getNextBlock(BogeySize currentSize) {
|
||||
return Stream.iterate(getNextSize(currentSize), this::getNextSize)
|
||||
public Block getNextBlock(BogeySizes.BogeySize currentSize) {
|
||||
return Stream.iterate(currentSize.increment(), BogeySizes.BogeySize::increment)
|
||||
.filter(size -> blocks.containsKey(size))
|
||||
.findFirst()
|
||||
.map(size -> ForgeRegistries.BLOCKS.getValue(blocks.get(size)))
|
||||
.orElse(ForgeRegistries.BLOCKS.getValue(blocks.get(currentSize)));
|
||||
}
|
||||
|
||||
public Block getBlockOfSize(BogeySize size) {
|
||||
public Block getBlockOfSize(BogeySizes.BogeySize size) {
|
||||
return ForgeRegistries.BLOCKS.getValue(blocks.get(size));
|
||||
}
|
||||
|
||||
public Set<BogeySize> validSizes() {
|
||||
public Set<BogeySizes.BogeySize> validSizes() {
|
||||
return blocks.keySet();
|
||||
}
|
||||
|
||||
private BogeySize getNextSize(BogeySize size) {
|
||||
BogeySize[] sizes = BogeySize.values();
|
||||
int nextOrdinal = (size.ordinal() + 1) % sizes.length;
|
||||
return sizes[nextOrdinal];
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SoundEvent getSoundType() {
|
||||
AllSoundEvents.SoundEntry entry = AllSoundEvents.ALL.get(this.soundType);
|
||||
if (entry == null) entry = AllSoundEvents.TRAIN2;
|
||||
if (entry == null || entry.getMainEvent() == null) entry = AllSoundEvents.TRAIN2;
|
||||
return entry.getMainEvent();
|
||||
}
|
||||
|
||||
public BogeyInstance createInstance(CarriageBogey bogey, BogeySize size, MaterialManager materialManager) {
|
||||
public BogeyInstance createInstance(CarriageBogey bogey, BogeySizes.BogeySize size, MaterialManager materialManager) {
|
||||
return new BogeyInstance(bogey, this.renderer.newInstance(), size, materialManager);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.AbstractBogeyBlock;
|
||||
import com.simibubi.create.content.logistics.trains.BogeySizes;
|
||||
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.block.ProperWaterloggedBlock;
|
||||
|
@ -18,9 +19,9 @@ import net.minecraft.world.phys.HitResult;
|
|||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class StandardBogeyBlock extends AbstractBogeyBlock implements ITE<StandardBogeyTileEntity>, ProperWaterloggedBlock, ISpecialBlockItemRequirement {
|
||||
private final BogeyRenderer.BogeySize size;
|
||||
private final BogeySizes.BogeySize size;
|
||||
|
||||
public StandardBogeyBlock(Properties props, BogeyRenderer.BogeySize size) {
|
||||
public StandardBogeyBlock(Properties props, BogeySizes.BogeySize size) {
|
||||
super(props);
|
||||
this.size = size;
|
||||
registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false));
|
||||
|
@ -33,7 +34,7 @@ public class StandardBogeyBlock extends AbstractBogeyBlock implements ITE<Standa
|
|||
|
||||
@Override
|
||||
public double getWheelRadius() {
|
||||
return (size == BogeyRenderer.BogeySize.LARGE ? 12.5 : 6.5) / 16d;
|
||||
return (size == BogeySizes.LARGE ? 12.5 : 6.5) / 16d;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +43,7 @@ public class StandardBogeyBlock extends AbstractBogeyBlock implements ITE<Standa
|
|||
}
|
||||
|
||||
@Override
|
||||
public BogeyRenderer.BogeySize getSize() {
|
||||
public BogeySizes.BogeySize getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.simibubi.create.foundation.data;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllParticleTypes;
|
||||
import com.simibubi.create.AllRegistries;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer;
|
||||
import com.simibubi.create.content.logistics.trains.AbstractBogeyBlock;
|
||||
import com.simibubi.create.content.logistics.trains.BogeySizes;
|
||||
import com.simibubi.create.content.logistics.trains.entity.BogeyStyle;
|
||||
|
||||
import com.tterrag.registrate.AbstractRegistrate;
|
||||
|
@ -23,8 +23,6 @@ import net.minecraft.core.particles.ParticleType;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -67,11 +65,11 @@ public class BogeyStyleBuilder<T extends BogeyStyle, P> extends AbstractBuilder<
|
|||
return this;
|
||||
}
|
||||
|
||||
public BogeyStyleBuilder<T, P> block(BogeyRenderer.BogeySize size, BlockEntry<? extends AbstractBogeyBlock> block) {
|
||||
public BogeyStyleBuilder<T, P> block(BogeySizes.BogeySize size, BlockEntry<? extends AbstractBogeyBlock> block) {
|
||||
return this.block(size, block.getId());
|
||||
}
|
||||
|
||||
public BogeyStyleBuilder<T, P> block(BogeyRenderer.BogeySize size, ResourceLocation location) {
|
||||
public BogeyStyleBuilder<T, P> block(BogeySizes.BogeySize size, ResourceLocation location) {
|
||||
this.style.addBlockForSize(size, location);
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue