mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-05 03:42:36 +01:00
Merge remote-tracking branch 'origin/1.18/api' into 1.18/api
This commit is contained in:
commit
457d5f33ed
6 changed files with 21 additions and 39 deletions
|
@ -66,7 +66,7 @@ public class AllBogeyStyles {
|
|||
protected CompoundTag defaultData = new CompoundTag();
|
||||
protected ParticleOptions contactParticle = ParticleTypes.CRIT;
|
||||
protected ParticleOptions smokeParticle = ParticleTypes.POOF;
|
||||
protected Optional<CommonRenderer> commonRenderer = Optional.empty();
|
||||
protected Optional<Supplier<? extends CommonRenderer>> commonRenderer = Optional.empty();
|
||||
|
||||
public BogeyStyleBuilder(ResourceLocation name, ResourceLocation cycleGroup) {
|
||||
this.name = name;
|
||||
|
@ -96,7 +96,7 @@ public class AllBogeyStyles {
|
|||
|
||||
public BogeyStyleBuilder size(BogeySizes.BogeySize size, Supplier<? extends BogeyRenderer> renderer,
|
||||
ResourceLocation location) {
|
||||
this.sizes.put(size, new BogeyStyle.SizeData(location, renderer.get()));
|
||||
this.sizes.put(size, new BogeyStyle.SizeData(location, renderer, renderer.get()));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class AllBogeyStyles {
|
|||
}
|
||||
|
||||
public BogeyStyleBuilder commonRenderer(Supplier<? extends CommonRenderer> commonRenderer) {
|
||||
this.commonRenderer = Optional.of(commonRenderer.get());
|
||||
this.commonRenderer = Optional.of(commonRenderer);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyTileEntity> exte
|
|||
style = getDefaultStyle();
|
||||
|
||||
final Optional<BogeyRenderer.CommonRenderer> commonRenderer
|
||||
= style.getNewCommonRenderInstance();
|
||||
= style.getInWorldCommonRenderInstance();
|
||||
final BogeyRenderer renderer = style.getInWorldRenderInstance(this.getSize());
|
||||
if (state != null) {
|
||||
ms.translate(.5f, .5f, .5f);
|
||||
|
|
|
@ -278,21 +278,10 @@ public abstract class BogeyRenderer {
|
|||
return state.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for rendering in contraptions allowing for individual instances of models for each component
|
||||
*
|
||||
* @return new Instance of renderer
|
||||
*/
|
||||
public abstract BogeyRenderer createNewInstance();
|
||||
|
||||
|
||||
public static abstract class CommonRenderer extends BogeyRenderer {
|
||||
@Override
|
||||
public BogeySizes.BogeySize getSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract CommonRenderer createNewInstance();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,11 +30,6 @@ public class StandardBogeyRenderer {
|
|||
.setValue(ShaftBlock.AXIS, Direction.Axis.Z), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonStandardBogeyRenderer createNewInstance() {
|
||||
return new CommonStandardBogeyRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(boolean upsideDown, CompoundTag bogeyData, float wheelAngle, PoseStack ms, int light, VertexConsumer vb, boolean inContraption) {
|
||||
boolean inInstancedContraption = vb == null;
|
||||
|
@ -58,10 +53,6 @@ public class StandardBogeyRenderer {
|
|||
createModelInstances(materialManager, BOGEY_FRAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BogeyRenderer createNewInstance() {
|
||||
return new SmallStandardBogeyRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BogeySizes.BogeySize getSize() {
|
||||
|
@ -96,11 +87,6 @@ public class StandardBogeyRenderer {
|
|||
.setValue(ShaftBlock.AXIS, Direction.Axis.X), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BogeyRenderer createNewInstance() {
|
||||
return new LargeStandardBogeyRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BogeySizes.BogeySize getSize() {
|
||||
return BogeySizes.LARGE;
|
||||
|
|
|
@ -19,9 +19,4 @@ public class BackupBogeyRenderer extends BogeyRenderer.CommonRenderer {
|
|||
public void initialiseContraptionModelData(MaterialManager materialManager) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonRenderer createNewInstance() {
|
||||
return new BackupBogeyRenderer();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,13 @@ import org.jetbrains.annotations.NotNull;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public class BogeyStyle {
|
||||
private final Optional<Supplier<? extends CommonRenderer>> commonRendererFactory;
|
||||
|
||||
public final ResourceLocation name;
|
||||
public final ResourceLocation cycleGroup;
|
||||
private final Optional<CommonRenderer> commonRenderer;
|
||||
|
@ -46,7 +49,9 @@ public class BogeyStyle {
|
|||
this.defaultData = defaultData;
|
||||
|
||||
this.sizes = sizes;
|
||||
this.commonRenderer = commonRenderer;
|
||||
|
||||
this.commonRendererFactory = commonRenderer;
|
||||
this.commonRenderer = commonRenderer.map(Supplier::get);
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, BogeyStyle> getCycleGroup() {
|
||||
|
@ -77,12 +82,12 @@ public class BogeyStyle {
|
|||
}
|
||||
|
||||
public BogeyRenderer createRendererInstance(BogeySizes.BogeySize size) {
|
||||
return this.getInWorldRenderInstance(size).createNewInstance();
|
||||
return this.sizes.get(size).createRenderInstance();
|
||||
}
|
||||
|
||||
public BogeyRenderer getInWorldRenderInstance(BogeySizes.BogeySize size) {
|
||||
SizeData sizeData = this.sizes.get(size);
|
||||
return sizeData != null ? sizeData.renderer() : BackupBogeyRenderer.INSTANCE;
|
||||
return sizeData != null ? sizeData.getInWorldInstance() : BackupBogeyRenderer.INSTANCE;
|
||||
}
|
||||
|
||||
public Optional<CommonRenderer> getInWorldCommonRenderInstance() {
|
||||
|
@ -90,13 +95,20 @@ public class BogeyStyle {
|
|||
}
|
||||
|
||||
public Optional<CommonRenderer> getNewCommonRenderInstance() {
|
||||
return this.getInWorldCommonRenderInstance().map(CommonRenderer::createNewInstance);
|
||||
return this.commonRendererFactory.map(Supplier::get);
|
||||
}
|
||||
|
||||
public BogeyInstance createInstance(CarriageBogey bogey, BogeySizes.BogeySize size, MaterialManager materialManager) {
|
||||
return new BogeyInstance(bogey, this, size, materialManager);
|
||||
}
|
||||
|
||||
public record SizeData(ResourceLocation block, BogeyRenderer renderer) {
|
||||
public record SizeData(ResourceLocation block, Supplier<? extends BogeyRenderer> rendererFactory, BogeyRenderer instance) {
|
||||
public BogeyRenderer createRenderInstance() {
|
||||
return rendererFactory.get();
|
||||
}
|
||||
|
||||
public BogeyRenderer getInWorldInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue