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