Merge pull request #1118 from Jozufozu/mc1.15/experimental-rendering

Experimental Rendering
This commit is contained in:
simibubi 2021-02-18 17:59:52 +01:00 committed by GitHub
commit 3ff3992f97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
315 changed files with 8021 additions and 1079 deletions

View file

@ -3,9 +3,11 @@ buildscript {
maven { url = 'https://files.minecraftforge.net/maven' } maven { url = 'https://files.minecraftforge.net/maven' }
jcenter() jcenter()
mavenCentral() mavenCentral()
maven { url='https://dist.creeper.host/Sponge/maven' }
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
} }
} }
plugins { plugins {
@ -35,6 +37,9 @@ minecraft {
runs { runs {
client { client {
workingDirectory project.file('run') workingDirectory project.file('run')
// property 'mixin.env.disableRefMap', 'true'
arg '-mixin.config=create.mixins.json'
// jvmArgs '-XX:+UnlockCommercialFeatures'
property 'forge.logging.console.level', 'info' property 'forge.logging.console.level', 'info'
property 'fml.earlyprogresswindow', 'false' property 'fml.earlyprogresswindow', 'false'
mods { mods {
@ -46,6 +51,8 @@ minecraft {
server { server {
workingDirectory project.file('run/server') workingDirectory project.file('run/server')
// property 'mixin.env.disableRefMap', 'true'
arg '-mixin.config=create.mixins.json'
property 'forge.logging.console.level', 'info' property 'forge.logging.console.level', 'info'
mods { mods {
create { create {
@ -119,6 +126,8 @@ dependencies {
// i'll leave this here commented for easier testing // i'll leave this here commented for easier testing
//runtimeOnly fg.deobf("vazkii.arl:AutoRegLib:1.4-35.69") //runtimeOnly fg.deobf("vazkii.arl:AutoRegLib:1.4-35.69")
//runtimeOnly fg.deobf("vazkii.quark:Quark:r2.0-212.984") //runtimeOnly fg.deobf("vazkii.quark:Quark:r2.0-212.984")
annotationProcessor 'org.spongepowered:mixin:0.8:processor'
} }
jar { jar {
@ -131,7 +140,8 @@ jar {
"Implementation-Title": project.name, "Implementation-Title": project.name,
"Implementation-Version": "${version}", "Implementation-Version": "${version}",
"Implementation-Vendor" :"simibubi", "Implementation-Vendor" :"simibubi",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "create.mixins.json"
]) ])
} }
} }
@ -200,3 +210,9 @@ curseforge {
} }
} }
} }
apply plugin: 'org.spongepowered.mixin'
mixin {
add sourceSets.main, "create.refmap.json"
}

View file

@ -6,7 +6,7 @@ org.gradle.daemon=false
# mod version info # mod version info
mod_version=0.3.1 mod_version=0.3.1
minecraft_version=1.15.2 minecraft_version=1.15.2
forge_version=31.2.31 forge_version=31.2.47
# dependency versions # dependency versions
registrate_version=1.0.0-rc.17 registrate_version=1.0.0-rc.17

View file

@ -1,22 +1,18 @@
package com.simibubi.create; package com.simibubi.create;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.base.KineticRenderMaterials;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes; import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes;
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
import com.simibubi.create.content.contraptions.relays.belt.BeltData;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.instancing.*;
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;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -25,6 +21,15 @@ import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
public class AllBlockPartials { public class AllBlockPartials {
private static final List<AllBlockPartials> all = new ArrayList<>(); private static final List<AllBlockPartials> all = new ArrayList<>();
@ -223,4 +228,30 @@ public class AllBlockPartials {
return CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms); return CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
} }
public InstancedModel<RotatingData> renderOnRotating(InstancedTileRenderer<?> ctx, BlockState referenceState) {
return ctx.getMaterial(KineticRenderMaterials.ROTATING).getModel(this, referenceState);
}
public InstancedModel<BeltData> renderOnBelt(InstancedTileRenderer<?> ctx, BlockState referenceState) {
return ctx.getMaterial(KineticRenderMaterials.BELTS).getModel(this, referenceState);
}
public InstancedModel<RotatingData> renderOnDirectionalSouthRotating(InstancedTileRenderer<?> dispatcher, BlockState referenceState) {
Direction facing = referenceState.get(FACING);
return renderOnDirectionalSouthRotating(dispatcher, referenceState, facing);
}
public InstancedModel<RotatingData> renderOnDirectionalSouthRotating(InstancedTileRenderer<?> dispatcher, BlockState referenceState, Direction facing) {
Supplier<MatrixStack> ms = () -> {
MatrixStack stack = new MatrixStack();
MatrixStacker.of(stack)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing))
.unCentre();
return stack;
};
return dispatcher.getMaterial(KineticRenderMaterials.ROTATING).getModel(this, referenceState, facing, ms);
}
} }

View file

@ -1,13 +1,8 @@
package com.simibubi.create; package com.simibubi.create;
import com.simibubi.create.content.contraptions.components.actors.SeatEntity; import com.simibubi.create.content.contraptions.components.actors.SeatEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.*;
import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryContraptionEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity; import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueRenderer;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
@ -62,11 +57,11 @@ public class AllEntityTypes {
@OnlyIn(value = Dist.CLIENT) @OnlyIn(value = Dist.CLIENT)
public static void registerRenderers() { public static void registerRenderers() {
RenderingRegistry.registerEntityRenderingHandler(CONTROLLED_CONTRAPTION.get(), RenderingRegistry.registerEntityRenderingHandler(CONTROLLED_CONTRAPTION.get(),
ControlledContraptionEntityRenderer::new); ContraptionEntityRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(ORIENTED_CONTRAPTION.get(), RenderingRegistry.registerEntityRenderingHandler(ORIENTED_CONTRAPTION.get(),
OrientedContraptionEntityRenderer::new); OrientedContraptionEntityRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(GANTRY_CONTRAPTION.get(), RenderingRegistry.registerEntityRenderingHandler(GANTRY_CONTRAPTION.get(),
GantryContraptionEntityRenderer::new); ContraptionEntityRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(SUPER_GLUE.get(), SuperGlueRenderer::new); RenderingRegistry.registerEntityRenderingHandler(SUPER_GLUE.get(), SuperGlueRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(SEAT.get(), SeatEntity.Render::new); RenderingRegistry.registerEntityRenderingHandler(SEAT.get(), SeatEntity.Render::new);
} }

View file

@ -51,9 +51,9 @@ public class AllSpriteShifts {
FLUID_TANK = getCT(CTType.CROSS, "fluid_tank"), FLUID_TANK = getCT(CTType.CROSS, "fluid_tank"),
CREATIVE_FLUID_TANK = getCT(CTType.CROSS, "creative_fluid_tank"); CREATIVE_FLUID_TANK = getCT(CTType.CROSS, "creative_fluid_tank");
public static final SpriteShiftEntry BELT = SpriteShifter.get("block/belt", "block/belt_animated"), public static final SpriteShiftEntry BELT = SpriteShifter.get("block/belt", "block/belt_scroll"),
BELT_OFFSET = SpriteShifter.get("block/belt_offset", "block/belt_animated"), BELT_OFFSET = SpriteShifter.get("block/belt_offset", "block/belt_scroll"),
BELT_DIAGONAL = SpriteShifter.get("block/belt_diagonal", "block/belt_diagonal_animated"), BELT_DIAGONAL = SpriteShifter.get("block/belt_diagonal", "block/belt_diagonal_scroll"),
ANDESIDE_BELT_CASING = SpriteShifter.get("block/brass_casing_belt", "block/andesite_casing_belt"), ANDESIDE_BELT_CASING = SpriteShifter.get("block/brass_casing_belt", "block/andesite_casing_belt"),
CRAFTER_THINGIES = SpriteShifter.get("block/crafter_thingies", "block/crafter_thingies"); CRAFTER_THINGIES = SpriteShifter.get("block/crafter_thingies", "block/crafter_thingies");
@ -92,9 +92,9 @@ public class AllSpriteShifts {
for (DyeColor color : DyeColor.values()) { for (DyeColor color : DyeColor.values()) {
String id = color.getName(); String id = color.getName();
DYED_BELTS.put(color, SpriteShifter.get("block/belt", "block/belt/" + id)); DYED_BELTS.put(color, SpriteShifter.get("block/belt", "block/belt/" + id + "_scroll"));
DYED_OFFSET_BELTS.put(color, SpriteShifter.get("block/belt_offset", "block/belt/" + id)); DYED_OFFSET_BELTS.put(color, SpriteShifter.get("block/belt_offset", "block/belt/" + id + "_scroll"));
DYED_DIAGONAL_BELTS.put(color, SpriteShifter.get("block/belt_diagonal", "block/belt/" + id + "_diagonal")); DYED_DIAGONAL_BELTS.put(color, SpriteShifter.get("block/belt_diagonal", "block/belt/" + id + "_diagonal_scroll"));
} }
} }

View file

@ -1,15 +1,10 @@
package com.simibubi.create; package com.simibubi.create;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.*;
import com.simibubi.create.content.contraptions.components.actors.DrillRenderer; import com.simibubi.create.content.contraptions.components.actors.*;
import com.simibubi.create.content.contraptions.components.actors.DrillTileEntity;
import com.simibubi.create.content.contraptions.components.actors.HarvesterRenderer;
import com.simibubi.create.content.contraptions.components.actors.HarvesterTileEntity;
import com.simibubi.create.content.contraptions.components.actors.PortableFluidInterfaceTileEntity;
import com.simibubi.create.content.contraptions.components.actors.PortableItemInterfaceTileEntity;
import com.simibubi.create.content.contraptions.components.actors.PortableStorageInterfaceRenderer;
import com.simibubi.create.content.contraptions.components.clock.CuckooClockRenderer; import com.simibubi.create.content.contraptions.components.clock.CuckooClockRenderer;
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity; import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterInstance;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterRenderer; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterRenderer;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity;
import com.simibubi.create.content.contraptions.components.crank.HandCrankRenderer; import com.simibubi.create.content.contraptions.components.crank.HandCrankRenderer;
@ -20,11 +15,14 @@ import com.simibubi.create.content.contraptions.components.deployer.DeployerRend
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity; import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity;
import com.simibubi.create.content.contraptions.components.fan.EncasedFanRenderer; import com.simibubi.create.content.contraptions.components.fan.EncasedFanRenderer;
import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity; import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity;
import com.simibubi.create.content.contraptions.components.fan.FanInstance;
import com.simibubi.create.content.contraptions.components.fan.NozzleTileEntity; import com.simibubi.create.content.contraptions.components.fan.NozzleTileEntity;
import com.simibubi.create.content.contraptions.components.flywheel.FlyWheelInstance;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineRenderer; import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineTileEntity; import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineTileEntity;
import com.simibubi.create.content.contraptions.components.millstone.MillStoneCogInstance;
import com.simibubi.create.content.contraptions.components.millstone.MillstoneRenderer; import com.simibubi.create.content.contraptions.components.millstone.MillstoneRenderer;
import com.simibubi.create.content.contraptions.components.millstone.MillstoneTileEntity; import com.simibubi.create.content.contraptions.components.millstone.MillstoneTileEntity;
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerRenderer; import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerRenderer;
@ -33,6 +31,7 @@ import com.simibubi.create.content.contraptions.components.motor.CreativeMotorRe
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity; import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity;
import com.simibubi.create.content.contraptions.components.press.MechanicalPressRenderer; import com.simibubi.create.content.contraptions.components.press.MechanicalPressRenderer;
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity; import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity;
import com.simibubi.create.content.contraptions.components.saw.SawInstance;
import com.simibubi.create.content.contraptions.components.saw.SawRenderer; import com.simibubi.create.content.contraptions.components.saw.SawRenderer;
import com.simibubi.create.content.contraptions.components.saw.SawTileEntity; import com.simibubi.create.content.contraptions.components.saw.SawTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingRenderer;
@ -49,20 +48,11 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pul
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity;
import com.simibubi.create.content.contraptions.components.turntable.TurntableTileEntity; import com.simibubi.create.content.contraptions.components.turntable.TurntableTileEntity;
import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelTileEntity; import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelTileEntity;
import com.simibubi.create.content.contraptions.fluids.PumpCogInstance;
import com.simibubi.create.content.contraptions.fluids.PumpRenderer; import com.simibubi.create.content.contraptions.fluids.PumpRenderer;
import com.simibubi.create.content.contraptions.fluids.PumpTileEntity; import com.simibubi.create.content.contraptions.fluids.PumpTileEntity;
import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyRenderer; import com.simibubi.create.content.contraptions.fluids.actors.*;
import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyTileEntity; import com.simibubi.create.content.contraptions.fluids.pipes.*;
import com.simibubi.create.content.contraptions.fluids.actors.ItemDrainRenderer;
import com.simibubi.create.content.contraptions.fluids.actors.ItemDrainTileEntity;
import com.simibubi.create.content.contraptions.fluids.actors.SpoutRenderer;
import com.simibubi.create.content.contraptions.fluids.actors.SpoutTileEntity;
import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeTileEntity;
import com.simibubi.create.content.contraptions.fluids.pipes.FluidValveRenderer;
import com.simibubi.create.content.contraptions.fluids.pipes.FluidValveTileEntity;
import com.simibubi.create.content.contraptions.fluids.pipes.SmartFluidPipeTileEntity;
import com.simibubi.create.content.contraptions.fluids.pipes.StraightPipeTileEntity;
import com.simibubi.create.content.contraptions.fluids.pipes.TransparentStraightPipeRenderer;
import com.simibubi.create.content.contraptions.fluids.tank.CreativeFluidTankTileEntity; import com.simibubi.create.content.contraptions.fluids.tank.CreativeFluidTankTileEntity;
import com.simibubi.create.content.contraptions.fluids.tank.FluidTankRenderer; import com.simibubi.create.content.contraptions.fluids.tank.FluidTankRenderer;
import com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity; import com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity;
@ -74,17 +64,15 @@ import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileE
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerRenderer; import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerRenderer;
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity; import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity;
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.SequencedGearshiftTileEntity; import com.simibubi.create.content.contraptions.relays.advanced.sequencer.SequencedGearshiftTileEntity;
import com.simibubi.create.content.contraptions.relays.belt.BeltInstance;
import com.simibubi.create.content.contraptions.relays.belt.BeltRenderer; import com.simibubi.create.content.contraptions.relays.belt.BeltRenderer;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
import com.simibubi.create.content.contraptions.relays.elementary.SimpleKineticTileEntity; import com.simibubi.create.content.contraptions.relays.elementary.SimpleKineticTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.AdjustablePulleyTileEntity; import com.simibubi.create.content.contraptions.relays.encased.*;
import com.simibubi.create.content.contraptions.relays.encased.ClutchTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftRenderer;
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.SplitShaftRenderer;
import com.simibubi.create.content.contraptions.relays.gauge.GaugeRenderer; import com.simibubi.create.content.contraptions.relays.gauge.GaugeRenderer;
import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity; import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity;
import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity; import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity;
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxInstance;
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxRenderer; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxRenderer;
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity;
import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity;
@ -104,15 +92,10 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelRenderer;
import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity;
import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateTileEntity; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateTileEntity;
import com.simibubi.create.content.logistics.block.inventories.CreativeCrateTileEntity; import com.simibubi.create.content.logistics.block.inventories.CreativeCrateTileEntity;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInstance;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmRenderer; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmRenderer;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity;
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverRenderer; import com.simibubi.create.content.logistics.block.redstone.*;
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverTileEntity;
import com.simibubi.create.content.logistics.block.redstone.ContentObserverTileEntity;
import com.simibubi.create.content.logistics.block.redstone.NixieTubeRenderer;
import com.simibubi.create.content.logistics.block.redstone.NixieTubeTileEntity;
import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkTileEntity;
import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchTileEntity;
import com.simibubi.create.content.schematics.block.SchematicTableTileEntity; import com.simibubi.create.content.schematics.block.SchematicTableTileEntity;
import com.simibubi.create.content.schematics.block.SchematicannonRenderer; import com.simibubi.create.content.schematics.block.SchematicannonRenderer;
import com.simibubi.create.content.schematics.block.SchematicannonTileEntity; import com.simibubi.create.content.schematics.block.SchematicannonTileEntity;
@ -138,36 +121,42 @@ public class AllTileEntities {
.tileEntity("simple_kinetic", SimpleKineticTileEntity::new) .tileEntity("simple_kinetic", SimpleKineticTileEntity::new)
.validBlocks(AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL) .validBlocks(AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL)
.renderer(() -> KineticTileEntityRenderer::new) .renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register(); .register();
public static final TileEntityEntry<CreativeMotorTileEntity> MOTOR = Create.registrate() public static final TileEntityEntry<CreativeMotorTileEntity> MOTOR = Create.registrate()
.tileEntity("motor", CreativeMotorTileEntity::new) .tileEntity("motor", CreativeMotorTileEntity::new)
.validBlocks(AllBlocks.CREATIVE_MOTOR) .validBlocks(AllBlocks.CREATIVE_MOTOR)
.renderer(() -> CreativeMotorRenderer::new) .renderer(() -> CreativeMotorRenderer::new)
.onRegister(HalfShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<GearboxTileEntity> GEARBOX = Create.registrate() public static final TileEntityEntry<GearboxTileEntity> GEARBOX = Create.registrate()
.tileEntity("gearbox", GearboxTileEntity::new) .tileEntity("gearbox", GearboxTileEntity::new)
.validBlocks(AllBlocks.GEARBOX) .validBlocks(AllBlocks.GEARBOX)
.renderer(() -> GearboxRenderer::new) .renderer(() -> GearboxRenderer::new)
.onRegister(GearboxInstance::register)
.register(); .register();
public static final TileEntityEntry<EncasedShaftTileEntity> ENCASED_SHAFT = Create.registrate() public static final TileEntityEntry<EncasedShaftTileEntity> ENCASED_SHAFT = Create.registrate()
.tileEntity("encased_shaft", EncasedShaftTileEntity::new) .tileEntity("encased_shaft", EncasedShaftTileEntity::new)
.validBlocks(AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT, AllBlocks.ENCASED_CHAIN_DRIVE) .validBlocks(AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT, AllBlocks.ENCASED_CHAIN_DRIVE)
.renderer(() -> EncasedShaftRenderer::new) .renderer(() -> EncasedShaftRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<AdjustablePulleyTileEntity> ADJUSTABLE_PULLEY = Create.registrate() public static final TileEntityEntry<AdjustablePulleyTileEntity> ADJUSTABLE_PULLEY = Create.registrate()
.tileEntity("adjustable_pulley", AdjustablePulleyTileEntity::new) .tileEntity("adjustable_pulley", AdjustablePulleyTileEntity::new)
.validBlocks(AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT) .validBlocks(AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT)
.renderer(() -> EncasedShaftRenderer::new) .renderer(() -> EncasedShaftRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<EncasedFanTileEntity> ENCASED_FAN = Create.registrate() public static final TileEntityEntry<EncasedFanTileEntity> ENCASED_FAN = Create.registrate()
.tileEntity("encased_fan", EncasedFanTileEntity::new) .tileEntity("encased_fan", EncasedFanTileEntity::new)
.validBlocks(AllBlocks.ENCASED_FAN) .validBlocks(AllBlocks.ENCASED_FAN)
.renderer(() -> EncasedFanRenderer::new) .renderer(() -> EncasedFanRenderer::new)
.onRegister(FanInstance::register)
.register(); .register();
public static final TileEntityEntry<NozzleTileEntity> NOZZLE = Create.registrate() public static final TileEntityEntry<NozzleTileEntity> NOZZLE = Create.registrate()
@ -180,18 +169,21 @@ public class AllTileEntities {
.tileEntity("clutch", ClutchTileEntity::new) .tileEntity("clutch", ClutchTileEntity::new)
.validBlocks(AllBlocks.CLUTCH) .validBlocks(AllBlocks.CLUTCH)
.renderer(() -> SplitShaftRenderer::new) .renderer(() -> SplitShaftRenderer::new)
.onRegister(SplitShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<GearshiftTileEntity> GEARSHIFT = Create.registrate() public static final TileEntityEntry<GearshiftTileEntity> GEARSHIFT = Create.registrate()
.tileEntity("gearshift", GearshiftTileEntity::new) .tileEntity("gearshift", GearshiftTileEntity::new)
.validBlocks(AllBlocks.GEARSHIFT) .validBlocks(AllBlocks.GEARSHIFT)
.renderer(() -> SplitShaftRenderer::new) .renderer(() -> SplitShaftRenderer::new)
.onRegister(SplitShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<TurntableTileEntity> TURNTABLE = Create.registrate() public static final TileEntityEntry<TurntableTileEntity> TURNTABLE = Create.registrate()
.tileEntity("turntable", TurntableTileEntity::new) .tileEntity("turntable", TurntableTileEntity::new)
.validBlocks(AllBlocks.TURNTABLE) .validBlocks(AllBlocks.TURNTABLE)
.renderer(() -> KineticTileEntityRenderer::new) .renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register(); .register();
public static final TileEntityEntry<HandCrankTileEntity> HAND_CRANK = Create.registrate() public static final TileEntityEntry<HandCrankTileEntity> HAND_CRANK = Create.registrate()
@ -199,30 +191,35 @@ public class AllTileEntities {
.validBlocks(AllBlocks.HAND_CRANK, AllBlocks.COPPER_VALVE_HANDLE) .validBlocks(AllBlocks.HAND_CRANK, AllBlocks.COPPER_VALVE_HANDLE)
.validBlocks(AllBlocks.DYED_VALVE_HANDLES) .validBlocks(AllBlocks.DYED_VALVE_HANDLES)
.renderer(() -> HandCrankRenderer::new) .renderer(() -> HandCrankRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register(); .register();
public static final TileEntityEntry<CuckooClockTileEntity> CUCKOO_CLOCK = Create.registrate() public static final TileEntityEntry<CuckooClockTileEntity> CUCKOO_CLOCK = Create.registrate()
.tileEntity("cuckoo_clock", CuckooClockTileEntity::new) .tileEntity("cuckoo_clock", CuckooClockTileEntity::new)
.validBlocks(AllBlocks.CUCKOO_CLOCK, AllBlocks.MYSTERIOUS_CUCKOO_CLOCK) .validBlocks(AllBlocks.CUCKOO_CLOCK, AllBlocks.MYSTERIOUS_CUCKOO_CLOCK)
.renderer(() -> CuckooClockRenderer::new) .renderer(() -> CuckooClockRenderer::new)
.onRegister(HorizontalHalfShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<GantryShaftTileEntity> GANTRY_SHAFT = Create.registrate() public static final TileEntityEntry<GantryShaftTileEntity> GANTRY_SHAFT = Create.registrate()
.tileEntity("gantry_shaft", GantryShaftTileEntity::new) .tileEntity("gantry_shaft", GantryShaftTileEntity::new)
.validBlocks(AllBlocks.GANTRY_SHAFT) .validBlocks(AllBlocks.GANTRY_SHAFT)
.renderer(() -> KineticTileEntityRenderer::new) .renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register(); .register();
public static final TileEntityEntry<GantryPinionTileEntity> GANTRY_PINION = Create.registrate() public static final TileEntityEntry<GantryPinionTileEntity> GANTRY_PINION = Create.registrate()
.tileEntity("gantry_pinion", GantryPinionTileEntity::new) .tileEntity("gantry_pinion", GantryPinionTileEntity::new)
.validBlocks(AllBlocks.GANTRY_PINION) .validBlocks(AllBlocks.GANTRY_PINION)
.renderer(() -> GantryPinionRenderer::new) .renderer(() -> GantryPinionRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<PumpTileEntity> MECHANICAL_PUMP = Create.registrate() public static final TileEntityEntry<PumpTileEntity> MECHANICAL_PUMP = Create.registrate()
.tileEntity("mechanical_pump", PumpTileEntity::new) .tileEntity("mechanical_pump", PumpTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_PUMP) .validBlocks(AllBlocks.MECHANICAL_PUMP)
.renderer(() -> PumpRenderer::new) .renderer(() -> PumpRenderer::new)
.onRegister(PumpCogInstance::register)
.register(); .register();
public static final TileEntityEntry<SmartFluidPipeTileEntity> SMART_FLUID_PIPE = Create.registrate() public static final TileEntityEntry<SmartFluidPipeTileEntity> SMART_FLUID_PIPE = Create.registrate()
@ -251,6 +248,7 @@ public class AllTileEntities {
.tileEntity("fluid_valve", FluidValveTileEntity::new) .tileEntity("fluid_valve", FluidValveTileEntity::new)
.validBlocks(AllBlocks.FLUID_VALVE) .validBlocks(AllBlocks.FLUID_VALVE)
.renderer(() -> FluidValveRenderer::new) .renderer(() -> FluidValveRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<FluidTankTileEntity> FLUID_TANK = Create.registrate() public static final TileEntityEntry<FluidTankTileEntity> FLUID_TANK = Create.registrate()
@ -269,6 +267,7 @@ public class AllTileEntities {
.tileEntity("hose_pulley", HosePulleyTileEntity::new) .tileEntity("hose_pulley", HosePulleyTileEntity::new)
.validBlocks(AllBlocks.HOSE_PULLEY) .validBlocks(AllBlocks.HOSE_PULLEY)
.renderer(() -> HosePulleyRenderer::new) .renderer(() -> HosePulleyRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<SpoutTileEntity> SPOUT = Create.registrate() public static final TileEntityEntry<SpoutTileEntity> SPOUT = Create.registrate()
@ -287,6 +286,7 @@ public class AllTileEntities {
.tileEntity("belt", BeltTileEntity::new) .tileEntity("belt", BeltTileEntity::new)
.validBlocks(AllBlocks.BELT) .validBlocks(AllBlocks.BELT)
.renderer(() -> BeltRenderer::new) .renderer(() -> BeltRenderer::new)
.onRegister(BeltInstance::register)
.register(); .register();
public static final TileEntityEntry<ChuteTileEntity> CHUTE = Create.registrate() public static final TileEntityEntry<ChuteTileEntity> CHUTE = Create.registrate()
@ -317,36 +317,42 @@ public class AllTileEntities {
.tileEntity("mechanical_arm", ArmTileEntity::new) .tileEntity("mechanical_arm", ArmTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_ARM) .validBlocks(AllBlocks.MECHANICAL_ARM)
.renderer(() -> ArmRenderer::new) .renderer(() -> ArmRenderer::new)
.onRegister(ArmInstance::register)
.register(); .register();
public static final TileEntityEntry<MechanicalPistonTileEntity> MECHANICAL_PISTON = Create.registrate() public static final TileEntityEntry<MechanicalPistonTileEntity> MECHANICAL_PISTON = Create.registrate()
.tileEntity("mechanical_piston", MechanicalPistonTileEntity::new) .tileEntity("mechanical_piston", MechanicalPistonTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON) .validBlocks(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON)
.renderer(() -> MechanicalPistonRenderer::new) .renderer(() -> MechanicalPistonRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<WindmillBearingTileEntity> WINDMILL_BEARING = Create.registrate() public static final TileEntityEntry<WindmillBearingTileEntity> WINDMILL_BEARING = Create.registrate()
.tileEntity("windmill_bearing", WindmillBearingTileEntity::new) .tileEntity("windmill_bearing", WindmillBearingTileEntity::new)
.validBlocks(AllBlocks.WINDMILL_BEARING) .validBlocks(AllBlocks.WINDMILL_BEARING)
.renderer(() -> BearingRenderer::new) .renderer(() -> BearingRenderer::new)
.onRegister(BackHalfShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<MechanicalBearingTileEntity> MECHANICAL_BEARING = Create.registrate() public static final TileEntityEntry<MechanicalBearingTileEntity> MECHANICAL_BEARING = Create.registrate()
.tileEntity("mechanical_bearing", MechanicalBearingTileEntity::new) .tileEntity("mechanical_bearing", MechanicalBearingTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_BEARING) .validBlocks(AllBlocks.MECHANICAL_BEARING)
.renderer(() -> BearingRenderer::new) .renderer(() -> BearingRenderer::new)
.onRegister(BackHalfShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<ClockworkBearingTileEntity> CLOCKWORK_BEARING = Create.registrate() public static final TileEntityEntry<ClockworkBearingTileEntity> CLOCKWORK_BEARING = Create.registrate()
.tileEntity("clockwork_bearing", ClockworkBearingTileEntity::new) .tileEntity("clockwork_bearing", ClockworkBearingTileEntity::new)
.validBlocks(AllBlocks.CLOCKWORK_BEARING) .validBlocks(AllBlocks.CLOCKWORK_BEARING)
.renderer(() -> BearingRenderer::new) .renderer(() -> BearingRenderer::new)
.onRegister(BackHalfShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<PulleyTileEntity> ROPE_PULLEY = Create.registrate() public static final TileEntityEntry<PulleyTileEntity> ROPE_PULLEY = Create.registrate()
.tileEntity("rope_pulley", PulleyTileEntity::new) .tileEntity("rope_pulley", PulleyTileEntity::new)
.validBlocks(AllBlocks.ROPE_PULLEY) .validBlocks(AllBlocks.ROPE_PULLEY)
.renderer(() -> PulleyRenderer::new) .renderer(() -> PulleyRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<ChassisTileEntity> CHASSIS = Create.registrate() public static final TileEntityEntry<ChassisTileEntity> CHASSIS = Create.registrate()
@ -359,12 +365,14 @@ public class AllTileEntities {
.tileEntity("drill", DrillTileEntity::new) .tileEntity("drill", DrillTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_DRILL) .validBlocks(AllBlocks.MECHANICAL_DRILL)
.renderer(() -> DrillRenderer::new) .renderer(() -> DrillRenderer::new)
.onRegister(DrillInstance::register)
.register(); .register();
public static final TileEntityEntry<SawTileEntity> SAW = Create.registrate() public static final TileEntityEntry<SawTileEntity> SAW = Create.registrate()
.tileEntity("saw", SawTileEntity::new) .tileEntity("saw", SawTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_SAW) .validBlocks(AllBlocks.MECHANICAL_SAW)
.renderer(() -> SawRenderer::new) .renderer(() -> SawRenderer::new)
.onRegister(SawInstance::register)
.register(); .register();
public static final TileEntityEntry<HarvesterTileEntity> HARVESTER = Create.registrate() public static final TileEntityEntry<HarvesterTileEntity> HARVESTER = Create.registrate()
@ -390,6 +398,7 @@ public class AllTileEntities {
.tileEntity("flywheel", FlywheelTileEntity::new) .tileEntity("flywheel", FlywheelTileEntity::new)
.validBlocks(AllBlocks.FLYWHEEL) .validBlocks(AllBlocks.FLYWHEEL)
.renderer(() -> FlywheelRenderer::new) .renderer(() -> FlywheelRenderer::new)
.onRegister(FlyWheelInstance::register)
.register(); .register();
public static final TileEntityEntry<FurnaceEngineTileEntity> FURNACE_ENGINE = Create.registrate() public static final TileEntityEntry<FurnaceEngineTileEntity> FURNACE_ENGINE = Create.registrate()
@ -402,12 +411,14 @@ public class AllTileEntities {
.tileEntity("millstone", MillstoneTileEntity::new) .tileEntity("millstone", MillstoneTileEntity::new)
.validBlocks(AllBlocks.MILLSTONE) .validBlocks(AllBlocks.MILLSTONE)
.renderer(() -> MillstoneRenderer::new) .renderer(() -> MillstoneRenderer::new)
.onRegister(MillStoneCogInstance::register)
.register(); .register();
public static final TileEntityEntry<CrushingWheelTileEntity> CRUSHING_WHEEL = Create.registrate() public static final TileEntityEntry<CrushingWheelTileEntity> CRUSHING_WHEEL = Create.registrate()
.tileEntity("crushing_wheel", CrushingWheelTileEntity::new) .tileEntity("crushing_wheel", CrushingWheelTileEntity::new)
.validBlocks(AllBlocks.CRUSHING_WHEEL) .validBlocks(AllBlocks.CRUSHING_WHEEL)
.renderer(() -> KineticTileEntityRenderer::new) .renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register(); .register();
public static final TileEntityEntry<CrushingWheelControllerTileEntity> CRUSHING_WHEEL_CONTROLLER = public static final TileEntityEntry<CrushingWheelControllerTileEntity> CRUSHING_WHEEL_CONTROLLER =
@ -421,24 +432,28 @@ public class AllTileEntities {
.tileEntity("water_wheel", WaterWheelTileEntity::new) .tileEntity("water_wheel", WaterWheelTileEntity::new)
.validBlocks(AllBlocks.WATER_WHEEL) .validBlocks(AllBlocks.WATER_WHEEL)
.renderer(() -> KineticTileEntityRenderer::new) .renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register(); .register();
public static final TileEntityEntry<MechanicalPressTileEntity> MECHANICAL_PRESS = Create.registrate() public static final TileEntityEntry<MechanicalPressTileEntity> MECHANICAL_PRESS = Create.registrate()
.tileEntity("mechanical_press", MechanicalPressTileEntity::new) .tileEntity("mechanical_press", MechanicalPressTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_PRESS) .validBlocks(AllBlocks.MECHANICAL_PRESS)
.renderer(() -> MechanicalPressRenderer::new) .renderer(() -> MechanicalPressRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<MechanicalMixerTileEntity> MECHANICAL_MIXER = Create.registrate() public static final TileEntityEntry<MechanicalMixerTileEntity> MECHANICAL_MIXER = Create.registrate()
.tileEntity("mechanical_mixer", MechanicalMixerTileEntity::new) .tileEntity("mechanical_mixer", MechanicalMixerTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_MIXER) .validBlocks(AllBlocks.MECHANICAL_MIXER)
.renderer(() -> MechanicalMixerRenderer::new) .renderer(() -> MechanicalMixerRenderer::new)
.onRegister(ShaftlessCogInstance::register)
.register(); .register();
public static final TileEntityEntry<DeployerTileEntity> DEPLOYER = Create.registrate() public static final TileEntityEntry<DeployerTileEntity> DEPLOYER = Create.registrate()
.tileEntity("deployer", DeployerTileEntity::new) .tileEntity("deployer", DeployerTileEntity::new)
.validBlocks(AllBlocks.DEPLOYER) .validBlocks(AllBlocks.DEPLOYER)
.renderer(() -> DeployerRenderer::new) .renderer(() -> DeployerRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<BasinTileEntity> BASIN = Create.registrate() public static final TileEntityEntry<BasinTileEntity> BASIN = Create.registrate()
@ -457,30 +472,35 @@ public class AllTileEntities {
.tileEntity("mechanical_crafter", MechanicalCrafterTileEntity::new) .tileEntity("mechanical_crafter", MechanicalCrafterTileEntity::new)
.validBlocks(AllBlocks.MECHANICAL_CRAFTER) .validBlocks(AllBlocks.MECHANICAL_CRAFTER)
.renderer(() -> MechanicalCrafterRenderer::new) .renderer(() -> MechanicalCrafterRenderer::new)
.onRegister(MechanicalCrafterInstance::register)
.register(); .register();
public static final TileEntityEntry<SequencedGearshiftTileEntity> SEQUENCED_GEARSHIFT = Create.registrate() public static final TileEntityEntry<SequencedGearshiftTileEntity> SEQUENCED_GEARSHIFT = Create.registrate()
.tileEntity("sequenced_gearshift", SequencedGearshiftTileEntity::new) .tileEntity("sequenced_gearshift", SequencedGearshiftTileEntity::new)
.validBlocks(AllBlocks.SEQUENCED_GEARSHIFT) .validBlocks(AllBlocks.SEQUENCED_GEARSHIFT)
.renderer(() -> SplitShaftRenderer::new) .renderer(() -> SplitShaftRenderer::new)
.onRegister(SplitShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<SpeedControllerTileEntity> ROTATION_SPEED_CONTROLLER = Create.registrate() public static final TileEntityEntry<SpeedControllerTileEntity> ROTATION_SPEED_CONTROLLER = Create.registrate()
.tileEntity("rotation_speed_controller", SpeedControllerTileEntity::new) .tileEntity("rotation_speed_controller", SpeedControllerTileEntity::new)
.validBlocks(AllBlocks.ROTATION_SPEED_CONTROLLER) .validBlocks(AllBlocks.ROTATION_SPEED_CONTROLLER)
.renderer(() -> SpeedControllerRenderer::new) .renderer(() -> SpeedControllerRenderer::new)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<SpeedGaugeTileEntity> SPEEDOMETER = Create.registrate() public static final TileEntityEntry<SpeedGaugeTileEntity> SPEEDOMETER = Create.registrate()
.tileEntity("speedometer", SpeedGaugeTileEntity::new) .tileEntity("speedometer", SpeedGaugeTileEntity::new)
.validBlocks(AllBlocks.SPEEDOMETER) .validBlocks(AllBlocks.SPEEDOMETER)
.renderer(() -> GaugeRenderer::speed) .renderer(() -> GaugeRenderer::speed)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<StressGaugeTileEntity> STRESSOMETER = Create.registrate() public static final TileEntityEntry<StressGaugeTileEntity> STRESSOMETER = Create.registrate()
.tileEntity("stressometer", StressGaugeTileEntity::new) .tileEntity("stressometer", StressGaugeTileEntity::new)
.validBlocks(AllBlocks.STRESSOMETER) .validBlocks(AllBlocks.STRESSOMETER)
.renderer(() -> GaugeRenderer::stress) .renderer(() -> GaugeRenderer::stress)
.onRegister(ShaftInstance::register)
.register(); .register();
public static final TileEntityEntry<AnalogLeverTileEntity> ANALOG_LEVER = Create.registrate() public static final TileEntityEntry<AnalogLeverTileEntity> ANALOG_LEVER = Create.registrate()

View file

@ -1,7 +1,11 @@
package com.simibubi.create; package com.simibubi.create;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionRenderer;
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity; import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
import com.simibubi.create.content.schematics.ClientSchematicLoader; import com.simibubi.create.content.schematics.ClientSchematicLoader;
import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler; import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler;
@ -11,9 +15,14 @@ import com.simibubi.create.foundation.block.render.CustomBlockModels;
import com.simibubi.create.foundation.block.render.SpriteShifter; import com.simibubi.create.foundation.block.render.SpriteShifter;
import com.simibubi.create.foundation.item.CustomItemModels; import com.simibubi.create.foundation.item.CustomItemModels;
import com.simibubi.create.foundation.item.CustomRenderedItems; import com.simibubi.create.foundation.item.CustomRenderedItems;
import com.simibubi.create.foundation.utility.SuperByteBufferCache; import com.simibubi.create.foundation.render.KineticRenderer;
import com.simibubi.create.foundation.render.backend.OptifineHandler;
import com.simibubi.create.foundation.render.SuperByteBufferCache;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.backend.Backend;
import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.ghost.GhostBlocks;
import com.simibubi.create.foundation.utility.outliner.Outliner; import com.simibubi.create.foundation.utility.outliner.Outliner;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BlockModelShapes;
@ -31,17 +40,13 @@ import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
public class CreateClient { public class CreateClient {
public static ClientSchematicLoader schematicSender; public static ClientSchematicLoader schematicSender;
public static SchematicHandler schematicHandler; public static SchematicHandler schematicHandler;
public static SchematicAndQuillHandler schematicAndQuillHandler; public static SchematicAndQuillHandler schematicAndQuillHandler;
public static SuperByteBufferCache bufferCache; public static SuperByteBufferCache bufferCache;
public static KineticRenderer kineticRenderer;
public static final Outliner outliner = new Outliner(); public static final Outliner outliner = new Outliner();
public static GhostBlocks ghostBlocks; public static GhostBlocks ghostBlocks;
@ -57,16 +62,21 @@ public class CreateClient {
modEventBus.addListener(CreateClient::onModelRegistry); modEventBus.addListener(CreateClient::onModelRegistry);
modEventBus.addListener(CreateClient::onTextureStitch); modEventBus.addListener(CreateClient::onTextureStitch);
modEventBus.addListener(AllParticleTypes::registerFactories); modEventBus.addListener(AllParticleTypes::registerFactories);
Backend.init();
OptifineHandler.init();
} }
public static void clientInit(FMLClientSetupEvent event) { public static void clientInit(FMLClientSetupEvent event) {
kineticRenderer = new KineticRenderer();
schematicSender = new ClientSchematicLoader(); schematicSender = new ClientSchematicLoader();
schematicHandler = new SchematicHandler(); schematicHandler = new SchematicHandler();
schematicAndQuillHandler = new SchematicAndQuillHandler(); schematicAndQuillHandler = new SchematicAndQuillHandler();
bufferCache = new SuperByteBufferCache(); bufferCache = new SuperByteBufferCache();
bufferCache.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); bufferCache.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE);
bufferCache.registerCompartment(ContraptionRenderer.CONTRAPTION, 20); bufferCache.registerCompartment(ContraptionRenderDispatcher.CONTRAPTION, 20);
ghostBlocks = new GhostBlocks(); ghostBlocks = new GhostBlocks();
@ -174,4 +184,9 @@ public class CreateClient {
return casingConnectivity; return casingConnectivity;
} }
public static void invalidateRenderers() {
CreateClient.bufferCache.invalidate();
CreateClient.kineticRenderer.invalidate();
ContraptionRenderDispatcher.invalidateAll();
}
} }

View file

@ -3,17 +3,15 @@ package com.simibubi.create.compat.jei.category.animations;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
public abstract class AnimatedKinetics implements IDrawable { public abstract class AnimatedKinetics implements IDrawable {
public static float getCurrentAngle() { public static float getCurrentAngle() {
return ((AnimationTickHolder.ticks + Minecraft.getInstance().getRenderPartialTicks()) * 4f) % 360; return ((AnimationTickHolder.getRenderTick()) * 4f) % 360;
} }
protected BlockState shaft(Axis axis) { protected BlockState shaft(Axis axis) {

View file

@ -1,13 +1,10 @@
package com.simibubi.create.compat.jei.category.animations; package com.simibubi.create.compat.jei.category.animations;
import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
public class AnimatedPress extends AnimatedKinetics { public class AnimatedPress extends AnimatedKinetics {
@ -50,8 +47,7 @@ public class AnimatedPress extends AnimatedKinetics {
} }
private float getAnimatedHeadOffset() { private float getAnimatedHeadOffset() {
float cycle = (ticks + Minecraft.getInstance() float cycle = (AnimationTickHolder.getRenderTick()) % 30;
.getRenderPartialTicks()) % 30;
if (cycle < 10) { if (cycle < 10) {
float progress = cycle / 10; float progress = cycle / 10;
return -(progress * progress * progress); return -(progress * progress * progress);

View file

@ -1,23 +1,20 @@
package com.simibubi.create.compat.jei.category.animations; package com.simibubi.create.compat.jei.category.animations;
import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List;
public class AnimatedSpout extends AnimatedKinetics { public class AnimatedSpout extends AnimatedKinetics {
private List<FluidStack> fluids; private List<FluidStack> fluids;
@ -39,8 +36,7 @@ public class AnimatedSpout extends AnimatedKinetics {
.scale(scale) .scale(scale)
.render(); .render();
float cycle = (ticks + Minecraft.getInstance() float cycle = AnimationTickHolder.getRenderTick() % 30;
.getRenderPartialTicks()) % 30;
float squeeze = cycle < 20 ? MathHelper.sin((float) (cycle / 20f * Math.PI)) : 0; float squeeze = cycle < 20 ? MathHelper.sin((float) (cycle / 20f * Math.PI)) : 0;
squeeze *= 20; squeeze *= 20;

View file

@ -1,13 +1,13 @@
package com.simibubi.create.content.contraptions; package com.simibubi.create.content.contraptions;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class KineticNetwork { public class KineticNetwork {
public Long id; public Long id;

View file

@ -0,0 +1,25 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class BackHalfShaftInstance extends HalfShaftInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, BackHalfShaftInstance::new));
}
public BackHalfShaftInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected Direction getShaftDirection() {
return tile.getBlockState().get(BlockStateProperties.FACING).getOpposite();
}
}

View file

@ -0,0 +1,32 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class HalfShaftInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, HalfShaftInstance::new));
}
public HalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected InstancedModel<RotatingData> getModel() {
Direction dir = getShaftDirection();
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState, dir);
}
protected Direction getShaftDirection() {
return lastState.get(BlockStateProperties.FACING);
}
}

View file

@ -0,0 +1,25 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class HorizontalHalfShaftInstance extends HalfShaftInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, HorizontalHalfShaftInstance::new));
}
public HorizontalHalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected Direction getShaftDirection() {
return lastState.get(BlockStateProperties.HORIZONTAL_FACING).getOpposite();
}
}

View file

@ -0,0 +1,115 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.instancing.InstanceData;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.utility.ColorHelper;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.util.math.BlockPos;
import java.nio.ByteBuffer;
public class KineticData<D extends KineticData<D>> extends InstanceData {
private float x;
private float y;
private float z;
private byte blockLight;
private byte skyLight;
private byte r;
private byte g;
private byte b;
private float rotationalSpeed;
private float rotationOffset;
protected KineticData(InstancedModel<?> owner) {
super(owner);
}
public D setTileEntity(KineticTileEntity te) {
setPosition(te.getPos());
if (te.hasSource()) {
setColor(te.network);
}else {
setColor(0xFF, 0xFF, 0x00);
}
return (D) this;
}
public D setPosition(BlockPos pos) {
return setPosition(pos.getX(), pos.getY(), pos.getZ());
}
public D setPosition(Vector3f pos) {
return setPosition(pos.getX(), pos.getY(), pos.getZ());
}
public D setPosition(int x, int y, int z) {
BlockPos origin = owner.renderer.getOriginCoordinate();
return setPosition((float) (x - origin.getX()),
(float) (y - origin.getY()),
(float) (z - origin.getZ()));
}
public D setPosition(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
return (D) this;
}
public D setBlockLight(int blockLight) {
this.blockLight = (byte) ((blockLight & 0xF) << 4);
return (D) this;
}
public D setSkyLight(int skyLight) {
this.skyLight = (byte) ((skyLight & 0xF) << 4);
return (D) this;
}
public D setColor(Long l) {
if (l != null)
return setColor(l.longValue());
else
return setColor(0xFF, 0xFF, 0xFF);
}
private D setColor(long l) {
int color = ColorHelper.colorFromLong(l);
byte r = (byte) ((color >> 16) & 0xFF);
byte g = (byte) ((color >> 8) & 0xFF);
byte b = (byte) (color & 0xFF);
return setColor(r, g, b);
}
public D setColor(int r, int g, int b) {
return setColor((byte) r, (byte) g, (byte) b);
}
public D setColor(byte r, byte g, byte b) {
this.r = r;
this.g = g;
this.b = b;
return (D) this;
}
public D setRotationalSpeed(float rotationalSpeed) {
this.rotationalSpeed = rotationalSpeed;
return (D) this;
}
public D setRotationOffset(float rotationOffset) {
this.rotationOffset = rotationOffset;
return (D) this;
}
@Override
public void write(ByteBuffer buf) {
putVec3(buf, x, y, z);
putVec2(buf, blockLight, skyLight);
putVec3(buf, r, g, b);
put(buf, rotationalSpeed);
put(buf, rotationOffset);
}
}

View file

@ -0,0 +1,13 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.content.contraptions.relays.belt.BeltData;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.MaterialType;
import com.simibubi.create.content.contraptions.components.actors.ContraptionActorData;
public class KineticRenderMaterials {
public static final MaterialType<InstancedModel<RotatingData>> ROTATING = new MaterialType<>();
public static final MaterialType<InstancedModel<BeltData>> BELTS = new MaterialType<>();
public static final MaterialType<InstancedModel<ContraptionActorData>> ACTORS = new MaterialType<>();
}

View file

@ -8,6 +8,7 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticNetwork; import com.simibubi.create.content.contraptions.KineticNetwork;
import com.simibubi.create.content.contraptions.RotationPropagator; import com.simibubi.create.content.contraptions.RotationPropagator;
import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel; import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel;
@ -17,6 +18,8 @@ import com.simibubi.create.content.contraptions.goggles.IHaveHoveringInformation
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
@ -32,12 +35,22 @@ import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
import javax.annotation.Nullable;
import java.util.List;
import static net.minecraft.util.text.TextFormatting.GOLD;
import static net.minecraft.util.text.TextFormatting.GRAY;
public abstract class KineticTileEntity extends SmartTileEntity public abstract class KineticTileEntity extends SmartTileEntity
implements ITickableTileEntity, IHaveGoggleInformation, IHaveHoveringInformation { implements ITickableTileEntity, IHaveGoggleInformation, IHaveHoveringInformation, IInstanceRendered {
public @Nullable Long network; public @Nullable Long network;
public @Nullable BlockPos source; public @Nullable BlockPos source;
@ -245,6 +258,9 @@ public abstract class KineticTileEntity extends SmartTileEntity
if (clientPacket && overStressedBefore != overStressed && speed != 0) if (clientPacket && overStressedBefore != overStressed && speed != 0)
effects.triggerOverStressedEffect(); effects.triggerOverStressedEffect();
if (clientPacket)
FastRenderDispatcher.enqueueUpdate(this);
} }
public float getGeneratedSpeed() { public float getGeneratedSpeed() {
@ -465,7 +481,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
/** /**
* Specify ratio of transferred rotation from this kinetic component to a * Specify ratio of transferred rotation from this kinetic component to a
* specific other. * specific other.
* *
* @param target other Kinetic TE to transfer to * @param target other Kinetic TE to transfer to
* @param stateFrom this TE's blockstate * @param stateFrom this TE's blockstate
* @param stateTo other TE's blockstate * @param stateTo other TE's blockstate
@ -486,7 +502,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
* Specify additional locations the rotation propagator should look for * Specify additional locations the rotation propagator should look for
* potentially connected components. Neighbour list contains offset positions in * potentially connected components. Neighbour list contains offset positions in
* all 6 directions by default. * all 6 directions by default.
* *
* @param block * @param block
* @param state * @param state
* @param neighbours * @param neighbours
@ -513,7 +529,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
* circumstance. Shaft and cogwheel connections are already handled by internal * circumstance. Shaft and cogwheel connections are already handled by internal
* logic. Does not have to be specified on both ends, it is assumed that this * logic. Does not have to be specified on both ends, it is assumed that this
* relation is symmetrical. * relation is symmetrical.
* *
* @param other * @param other
* @param state * @param state
* @param otherState * @param otherState
@ -528,4 +544,42 @@ public abstract class KineticTileEntity extends SmartTileEntity
return block.hasIntegratedCogwheel(world, pos, state); return block.hasIntegratedCogwheel(world, pos, state);
} }
@Override
public void onLoad() {
super.onLoad();
if (world != null && world.isRemote)
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> CreateClient.kineticRenderer.add(this));
}
@Override
public void onChunkUnloaded() {
if (world != null && world.isRemote)
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> CreateClient.kineticRenderer.remove(this));
}
@Override
public void requestModelDataUpdate() {
super.requestModelDataUpdate();
if (!this.removed) {
FastRenderDispatcher.enqueueUpdate(this);
}
}
@Override
public void onChunkLightUpdate() {
CreateClient.kineticRenderer.onLightUpdate(this);
}
protected AxisAlignedBB cachedBoundingBox;
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
if (cachedBoundingBox == null) {
cachedBoundingBox = makeRenderBoundingBox();
}
return cachedBoundingBox;
}
protected AxisAlignedBB makeRenderBoundingBox() {
return super.getRenderBoundingBox();
}
} }

View file

@ -6,11 +6,12 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock; import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.SuperByteBufferCache.Compartment; import com.simibubi.create.foundation.render.Compartment;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -38,6 +39,8 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {
if (FastRenderDispatcher.available(te.getWorld())) return;
for (RenderType type : RenderType.getBlockLayers()) for (RenderType type : RenderType.getBlockLayers())
if (RenderTypeLookup.canRenderInLayer(te.getBlockState(), type)) if (RenderTypeLookup.canRenderInLayer(te.getBlockState(), type))
renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(type), light); renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(type), light);

View file

@ -0,0 +1,67 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.*;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
import net.minecraft.world.LightType;
import java.util.function.Consumer;
public abstract class KineticTileInstance<T extends KineticTileEntity> extends TileEntityInstance<T> {
public KineticTileInstance(InstancedTileRenderer<?> modelManager, T tile) {
super(modelManager, tile);
}
protected final void updateRotation(InstanceKey<RotatingData> key, Direction.Axis axis) {
key.modifyInstance(data -> {
data.setColor(tile.network)
.setRotationalSpeed(tile.getSpeed())
.setRotationOffset(getRotationOffset(axis))
.setRotationAxis(axis);
});
}
protected final Consumer<RotatingData> setupFunc(float speed, Direction.Axis axis) {
return data -> {
data.setBlockLight(world.getLightLevel(LightType.BLOCK, pos))
.setSkyLight(world.getLightLevel(LightType.SKY, pos))
.setTileEntity(tile)
.setRotationalSpeed(speed)
.setRotationOffset(getRotationOffset(axis))
.setRotationAxis(axis);
};
}
protected final void relight(KineticData<?> data) {
data.setBlockLight(world.getLightLevel(LightType.BLOCK, pos))
.setSkyLight(world.getLightLevel(LightType.SKY, pos));
}
protected float getRotationOffset(final Direction.Axis axis) {
float offset = CogWheelBlock.isLargeCog(lastState) ? 11.25f : 0;
double d = (((axis == Direction.Axis.X) ? 0 : pos.getX()) + ((axis == Direction.Axis.Y) ? 0 : pos.getY())
+ ((axis == Direction.Axis.Z) ? 0 : pos.getZ())) % 2;
if (d == 0) {
offset = 22.5f;
}
return offset;
}
public static BlockState shaft(Direction.Axis axis) {
return AllBlocks.SHAFT.getDefaultState()
.with(ShaftBlock.AXIS, axis);
}
public Direction.Axis getRotationAxis() {
return ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
}
protected final RenderMaterial<?, InstancedModel<RotatingData>> rotatingMaterial() {
return modelManager.getMaterial(KineticRenderMaterials.ROTATING);
}
}

View file

@ -0,0 +1,42 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes;
import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec;
public enum KineticVertexAttributes implements IVertexAttrib {
INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3),
LIGHT("aLight", CommonAttributes.LIGHT),
NETWORK_COLOR("aNetworkTint", CommonAttributes.RGB),
SPEED("aSpeed", CommonAttributes.FLOAT),
OFFSET("aOffset", CommonAttributes.FLOAT),
;
private final String name;
private final VertexAttribSpec spec;
KineticVertexAttributes(String name, VertexAttribSpec spec) {
this.name = name;
this.spec = spec;
}
@Override
public String attribName() {
return name;
}
@Override
public VertexAttribSpec attribSpec() {
return spec;
}
@Override
public int getDivisor() {
return 1;
}
@Override
public int getBufferIndex() {
return 1;
}
}

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
@ -27,7 +26,7 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock {
switch (rot) { switch (rot) {
case COUNTERCLOCKWISE_90: case COUNTERCLOCKWISE_90:
case CLOCKWISE_90: case CLOCKWISE_90:
switch ((Direction.Axis) state.get(AXIS)) { switch (state.get(AXIS)) {
case X: case X:
return state.with(AXIS, Direction.Axis.Z); return state.with(AXIS, Direction.Axis.Z);
case Z: case Z:

View file

@ -0,0 +1,48 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.util.Direction;
import java.nio.ByteBuffer;
public class RotatingData extends KineticData<RotatingData> {
public static VertexFormat FORMAT = VertexFormat.builder()
.addAttributes(KineticVertexAttributes.class)
.addAttributes(RotatingVertexAttributes.class)
.build();
private byte rotationAxisX;
private byte rotationAxisY;
private byte rotationAxisZ;
protected RotatingData(InstancedModel<?> owner) {
super(owner);
}
public RotatingData setRotationAxis(Direction.Axis axis) {
Direction orientation = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis);
setRotationAxis(orientation.getUnitVector());
return this;
}
public RotatingData setRotationAxis(Vector3f axis) {
setRotationAxis(axis.getX(), axis.getY(), axis.getZ());
return this;
}
public RotatingData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) {
this.rotationAxisX = (byte) (rotationAxisX * 127);
this.rotationAxisY = (byte) (rotationAxisY * 127);
this.rotationAxisZ = (byte) (rotationAxisZ * 127);
return this;
}
@Override
public void write(ByteBuffer buf) {
super.write(buf);
putVec3(buf, rotationAxisX, rotationAxisY, rotationAxisZ);
}
}

View file

@ -0,0 +1,23 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import net.minecraft.client.renderer.BufferBuilder;
public class RotatingInstancedModel extends InstancedModel<RotatingData> {
public RotatingInstancedModel(InstancedTileRenderer<?> renderer, BufferBuilder buf) {
super(renderer, buf);
}
@Override
protected RotatingData newInstance() {
return new RotatingData(this);
}
@Override
protected VertexFormat getInstanceFormat() {
return RotatingData.FORMAT;
}
}

View file

@ -0,0 +1,38 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes;
import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec;
public enum RotatingVertexAttributes implements IVertexAttrib {
AXIS("aAxis", CommonAttributes.NORMAL),
;
private final String name;
private final VertexAttribSpec spec;
RotatingVertexAttributes(String name, VertexAttribSpec spec) {
this.name = name;
this.spec = spec;
}
@Override
public String attribName() {
return name;
}
@Override
public VertexAttribSpec attribSpec() {
return spec;
}
@Override
public int getDivisor() {
return 1;
}
@Override
public int getBufferIndex() {
return 1;
}
}

View file

@ -0,0 +1,25 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class ShaftlessCogInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, ShaftlessCogInstance::new));
}
public ShaftlessCogInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected InstancedModel<RotatingData> getModel() {
return AllBlockPartials.SHAFTLESS_COGWHEEL.renderOnRotating(modelManager, tile.getBlockState());
}
}

View file

@ -0,0 +1,56 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstanceKey;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.KINETIC_TILE;
public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntity> {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, SingleRotatingInstance::new));
}
protected InstanceKey<RotatingData> rotatingModelKey;
public SingleRotatingInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected void init() {
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
rotatingModelKey = getModel().setupInstance(setupFunc(tile.getSpeed(), axis));
}
@Override
public void onUpdate() {
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
updateRotation(rotatingModelKey, axis);
}
@Override
public void updateLight() {
rotatingModelKey.modifyInstance(this::relight);
}
@Override
public void remove() {
rotatingModelKey.delete();
}
protected BlockState getRenderedBlockState() {
return lastState;
}
protected InstancedModel<RotatingData> getModel() {
return rotatingMaterial().getModel(KINETIC_TILE, getRenderedBlockState());
}
}

View file

@ -0,0 +1,43 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes;
import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec;
public enum ActorVertexAttributes implements IVertexAttrib {
INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3),
LIGHT("aModelLight", CommonAttributes.LIGHT),
OFFSET("aOffset", CommonAttributes.FLOAT),
AXIS("aAxis", CommonAttributes.NORMAL),
INSTANCE_ROTATION("aInstanceRot", CommonAttributes.VEC3),
ROTATION_CENTER("aRotationCenter", CommonAttributes.NORMAL),
;
private final String name;
private final VertexAttribSpec spec;
ActorVertexAttributes(String name, VertexAttribSpec spec) {
this.name = name;
this.spec = spec;
}
@Override
public String attribName() {
return name;
}
@Override
public VertexAttribSpec attribSpec() {
return spec;
}
@Override
public int getDivisor() {
return 1;
}
@Override
public int getBufferIndex() {
return 1;
}
}

View file

@ -10,8 +10,8 @@ import net.minecraft.util.math.Vec3d;
public class BellMovementBehaviour extends MovementBehaviour { public class BellMovementBehaviour extends MovementBehaviour {
@Override @Override
public boolean hasSpecialMovementRenderer() { public boolean renderAsNormalTileEntity() {
return false; return true;
} }
@Override @Override

View file

@ -10,8 +10,8 @@ import net.minecraft.particles.ParticleTypes;
public class CampfireMovementBehaviour extends MovementBehaviour { public class CampfireMovementBehaviour extends MovementBehaviour {
@Override @Override
public boolean hasSpecialMovementRenderer() { public boolean renderAsNormalTileEntity() {
return false; return true;
} }
@Override @Override

View file

@ -0,0 +1,105 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat;
import com.simibubi.create.foundation.render.backend.instancing.InstanceData;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.util.math.BlockPos;
import java.nio.ByteBuffer;
public class ContraptionActorData extends InstanceData {
public static VertexFormat FORMAT = VertexFormat.builder()
.addAttributes(ActorVertexAttributes.class)
.build();
private float x;
private float y;
private float z;
private byte blockLight;
private byte skyLight;
private float rotationOffset;
private byte rotationAxisX;
private byte rotationAxisY;
private byte rotationAxisZ;
private float localRotationX;
private float localRotationY;
private float localRotationZ;
private byte rotationCenterX = 64;
private byte rotationCenterY = 64;
private byte rotationCenterZ = 64;
protected ContraptionActorData(InstancedModel<?> owner) {
super(owner);
}
public ContraptionActorData setPosition(BlockPos pos) {
this.x = pos.getX();
this.y = pos.getY();
this.z = pos.getZ();
return this;
}
public ContraptionActorData setBlockLight(int blockLight) {
this.blockLight = (byte) ((blockLight & 0xF) << 4);
return this;
}
public ContraptionActorData setSkyLight(int skyLight) {
this.skyLight = (byte) ((skyLight & 0xF) << 4);
return this;
}
public ContraptionActorData setRotationOffset(float rotationOffset) {
this.rotationOffset = rotationOffset;
return this;
}
public ContraptionActorData setRotationAxis(Vector3f axis) {
setRotationAxis(axis.getX(), axis.getY(), axis.getZ());
return this;
}
public ContraptionActorData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) {
this.rotationAxisX = (byte) (rotationAxisX * 127);
this.rotationAxisY = (byte) (rotationAxisY * 127);
this.rotationAxisZ = (byte) (rotationAxisZ * 127);
return this;
}
public ContraptionActorData setRotationCenter(Vector3f axis) {
setRotationCenter(axis.getX(), axis.getY(), axis.getZ());
return this;
}
public ContraptionActorData setRotationCenter(float rotationCenterX, float rotationCenterY, float rotationCenterZ) {
this.rotationCenterX = (byte) (rotationCenterX * 127);
this.rotationCenterY = (byte) (rotationCenterY * 127);
this.rotationCenterZ = (byte) (rotationCenterZ * 127);
return this;
}
public ContraptionActorData setLocalRotation(Vector3f axis) {
setLocalRotation(axis.getX(), axis.getY(), axis.getZ());
return this;
}
public ContraptionActorData setLocalRotation(float localRotationX, float localRotationY, float localRotationZ) {
this.localRotationX = localRotationX;
this.localRotationY = localRotationY;
this.localRotationZ = localRotationZ;
return this;
}
@Override
public void write(ByteBuffer buf) {
putVec3(buf, x, y, z);
putVec2(buf, blockLight, skyLight);
put(buf, rotationOffset);
putVec3(buf, rotationAxisX, rotationAxisY, rotationAxisZ);
putVec3(buf, localRotationX, localRotationY, localRotationZ);
putVec3(buf, rotationCenterX, rotationCenterY, rotationCenterZ);
}
}

View file

@ -0,0 +1,49 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
import com.simibubi.create.foundation.render.backend.instancing.*;
import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.world.LightType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class DrillInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, DrillInstance::new)); }
public DrillInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
public static void addInstanceForContraption(RenderedContraption contraption, MovementContext context) {
RenderMaterial<?, InstancedModel<ContraptionActorData>> renderMaterial = contraption.getActorMaterial();
BlockState state = context.state;
InstancedModel<ContraptionActorData> model = renderMaterial.getModel(AllBlockPartials.DRILL_HEAD, state);
model.setupInstance(data -> {
Direction facing = state.get(DrillBlock.FACING);
float eulerX = AngleHelper.verticalAngle(facing) + ((facing.getAxis() == Direction.Axis.Y) ? 180 : 0);
float eulerY = facing.getHorizontalAngle();
data.setPosition(context.localPos)
.setBlockLight(contraption.renderWorld.getLightLevel(LightType.BLOCK, context.localPos))
.setRotationOffset(0)
.setRotationAxis(0, 0, 1)
.setLocalRotation(eulerX, eulerY, 0);
});
}
@Override
protected InstancedModel<RotatingData> getModel() {
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouthRotating(modelManager, tile.getBlockState());
}
}

View file

@ -2,6 +2,8 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -31,7 +33,18 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
@OnlyIn(value = Dist.CLIENT) @OnlyIn(value = Dist.CLIENT)
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) { IRenderTypeBuffer buffer) {
DrillRenderer.renderInContraption(context, ms, msLocal, buffer); if (!FastRenderDispatcher.available())
DrillRenderer.renderInContraption(context, ms, msLocal, buffer);
}
@Override
public boolean hasSpecialInstancedRendering() {
return true;
}
@Override
public void addInstance(RenderedContraption contraption, MovementContext context) {
DrillInstance.addInstanceForContraption(contraption, context);
} }
@Override @Override

View file

@ -10,7 +10,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;

View file

@ -2,6 +2,8 @@ package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.block.HorizontalBlock.HORIZONTAL_FACING; import static net.minecraft.block.HorizontalBlock.HORIZONTAL_FACING;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableBoolean;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@ -35,10 +37,21 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
.getOpposite()); .getOpposite());
} }
@Override
public boolean hasSpecialInstancedRendering() {
return true;
}
@Override
public void addInstance(RenderedContraption contraption, MovementContext context) {
HarvesterRenderer.addInstanceForContraption(contraption, context);
}
@Override @Override
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffers) { IRenderTypeBuffer buffers) {
HarvesterRenderer.renderInContraption(context, ms, msLocal, buffers); if (!FastRenderDispatcher.available())
HarvesterRenderer.renderInContraption(context, ms, msLocal, buffers);
} }
@Override @Override

View file

@ -5,19 +5,25 @@ import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FAC
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.LightType;
public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntity> { public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntity> {
@ -34,6 +40,25 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
} }
public static void addInstanceForContraption(RenderedContraption contraption, MovementContext context) {
RenderMaterial<?, InstancedModel<ContraptionActorData>> renderMaterial = contraption.getActorMaterial();
BlockState state = context.state;
InstancedModel<ContraptionActorData> model = renderMaterial.getModel(AllBlockPartials.HARVESTER_BLADE, state);
model.setupInstance(data -> {
Direction facing = state.get(HORIZONTAL_FACING);
float originOffset = 1 / 16f;
Vector3f rotOffset = new Vector3f(0.5f, -2 * originOffset + 0.5f, originOffset + 0.5f);
data.setPosition(context.localPos)
.setBlockLight(contraption.renderWorld.getLightLevel(LightType.BLOCK, context.localPos))
.setRotationOffset(0)
.setRotationCenter(rotOffset)
.setRotationAxis(-1, 0, 0)
.setLocalRotation(0, facing.getHorizontalAngle(), 0);
});
}
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffers) { IRenderTypeBuffer buffers) {
BlockState blockState = context.state; BlockState blockState = context.state;
@ -55,7 +80,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
.rotate(Direction.WEST, AngleHelper.rad(angle)) .rotate(Direction.WEST, AngleHelper.rad(angle))
.translate(-rotOffset.x, -rotOffset.y, -rotOffset.z) .translate(-rotOffset.x, -rotOffset.y, -rotOffset.z)
.light(msLocal.peek() .light(msLocal.peek()
.getModel()) .getModel(), ContraptionRenderDispatcher.getLightOnContraption(context))
.renderInto(ms, buffers.getBuffer(RenderType.getCutoutMipped())); .renderInto(ms, buffers.getBuffer(RenderType.getCutoutMipped()));
} }

View file

@ -1,19 +1,17 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import java.util.function.Consumer;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
@ -22,6 +20,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.function.Consumer;
public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<PortableStorageInterfaceTileEntity> { public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<PortableStorageInterfaceTileEntity> {
public PortableStorageInterfaceRenderer(TileEntityRendererDispatcher dispatcher) { public PortableStorageInterfaceRenderer(TileEntityRendererDispatcher dispatcher) {
@ -43,8 +43,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
BlockState blockState = context.state; BlockState blockState = context.state;
PortableStorageInterfaceTileEntity te = getTargetPSI(context); PortableStorageInterfaceTileEntity te = getTargetPSI(context);
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
float renderPartialTicks = Minecraft.getInstance() float renderPartialTicks = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
float progress = 0; float progress = 0;
boolean lit = false; boolean lit = false;
@ -54,26 +53,10 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
} }
render(blockState, progress, lit, sbb -> sbb.light(msLocal.peek() render(blockState, progress, lit, sbb -> sbb.light(msLocal.peek()
.getModel()) .getModel(), ContraptionRenderDispatcher.getLightOnContraption(context))
.renderInto(ms, vb), ms, msLocal); .renderInto(ms, vb), ms, msLocal);
} }
protected static PortableStorageInterfaceTileEntity getTargetPSI(MovementContext context) {
String _workingPos_ = PortableStorageInterfaceMovement._workingPos_;
if (!context.contraption.stalled || !context.data.contains(_workingPos_))
return null;
BlockPos pos = NBTUtil.readBlockPos(context.data.getCompound(_workingPos_));
TileEntity tileEntity = context.world.getTileEntity(pos);
if (!(tileEntity instanceof PortableStorageInterfaceTileEntity))
return null;
PortableStorageInterfaceTileEntity psi = (PortableStorageInterfaceTileEntity) tileEntity;
if (!psi.isTransferring())
return null;
return psi;
}
private static void render(BlockState blockState, float progress, boolean lit, private static void render(BlockState blockState, float progress, boolean lit,
Consumer<SuperByteBuffer> drawCallback, MatrixStack... matrixStacks) { Consumer<SuperByteBuffer> drawCallback, MatrixStack... matrixStacks) {
for (MatrixStack ms : matrixStacks) for (MatrixStack ms : matrixStacks)
@ -109,6 +92,22 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
ms.pop(); ms.pop();
} }
protected static PortableStorageInterfaceTileEntity getTargetPSI(MovementContext context) {
String _workingPos_ = PortableStorageInterfaceMovement._workingPos_;
if (!context.contraption.stalled || !context.data.contains(_workingPos_))
return null;
BlockPos pos = NBTUtil.readBlockPos(context.data.getCompound(_workingPos_));
TileEntity tileEntity = context.world.getTileEntity(pos);
if (!(tileEntity instanceof PortableStorageInterfaceTileEntity))
return null;
PortableStorageInterfaceTileEntity psi = (PortableStorageInterfaceTileEntity) tileEntity;
if (!psi.isTransferring())
return null;
return psi;
}
static AllBlockPartials getMiddleForState(BlockState state, boolean lit) { static AllBlockPartials getMiddleForState(BlockState state, boolean lit) {
if (AllBlocks.PORTABLE_FLUID_INTERFACE.has(state)) if (AllBlocks.PORTABLE_FLUID_INTERFACE.has(state))
return lit ? AllBlockPartials.PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED return lit ? AllBlockPartials.PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED

View file

@ -100,10 +100,14 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity
return powered; return powered;
} }
protected AxisAlignedBB cachedBoundingBox;
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return super.getRenderBoundingBox().grow(2); if (cachedBoundingBox == null) {
cachedBoundingBox = super.getRenderBoundingBox().grow(2);
}
return cachedBoundingBox;
} }
public boolean isTransferring() { public boolean isTransferring() {

View file

@ -0,0 +1,22 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import net.minecraft.client.renderer.BufferBuilder;
public class RotatingActorModel extends InstancedModel<ContraptionActorData> {
public RotatingActorModel(InstancedTileRenderer<?> renderer, BufferBuilder buf) {
super(renderer, buf);
}
@Override
protected VertexFormat getInstanceFormat() {
return ContraptionActorData.FORMAT;
}
@Override
protected ContraptionActorData newInstance() {
return new ContraptionActorData(this);
}
}

View file

@ -7,7 +7,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity.Animation; import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity.Animation;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;

View file

@ -1,9 +1,5 @@
package com.simibubi.create.content.contraptions.components.clock; package com.simibubi.create.content.contraptions.components.clock;
import static com.simibubi.create.foundation.utility.AngleHelper.deg;
import static com.simibubi.create.foundation.utility.AngleHelper.getShortestAngleDiff;
import static com.simibubi.create.foundation.utility.AngleHelper.rad;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
@ -11,7 +7,6 @@ import com.simibubi.create.foundation.gui.widgets.InterpolatedValue;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ParticleTypes; import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
@ -22,6 +17,8 @@ import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import static com.simibubi.create.foundation.utility.AngleHelper.*;
public class CuckooClockTileEntity extends KineticTileEntity { public class CuckooClockTileEntity extends KineticTileEntity {
public static DamageSource CUCKOO_SURPRISE = new DamageSource("create.cuckoo_clock_explosion").setExplosion(); public static DamageSource CUCKOO_SURPRISE = new DamageSource("create.cuckoo_clock_explosion").setExplosion();
@ -95,9 +92,9 @@ public class CuckooClockTileEntity extends KineticTileEntity {
moveHands(hours, minutes); moveHands(hours, minutes);
if (animationType == Animation.NONE) { if (animationType == Animation.NONE) {
if (AnimationTickHolder.ticks % 32 == 0) if (AnimationTickHolder.getTicks() % 32 == 0)
playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 2f); playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 2f);
else if (AnimationTickHolder.ticks % 16 == 0) else if (AnimationTickHolder.getTicks() % 16 == 0)
playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 1.5f); playSound(SoundEvents.BLOCK_NOTE_BLOCK_HAT, 1 / 16f, 1.5f);
} else { } else {
@ -172,4 +169,8 @@ public class CuckooClockTileEntity extends KineticTileEntity {
world.playSound(vec.x, vec.y, vec.z, sound, SoundCategory.BLOCKS, volume, pitch, false); world.playSound(vec.x, vec.y, vec.z, sound, SoundCategory.BLOCKS, volume, pitch, false);
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -0,0 +1,48 @@
package com.simibubi.create.content.contraptions.components.crafter;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import java.util.function.Supplier;
public class MechanicalCrafterInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, MechanicalCrafterInstance::new));
}
public MechanicalCrafterInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected InstancedModel<RotatingData> getModel() {
Direction facing = lastState.get(MechanicalCrafterBlock.HORIZONTAL_FACING);
Supplier<MatrixStack> ms = () -> {
MatrixStack stack = new MatrixStack();
MatrixStacker stacker = MatrixStacker.of(stack).centre();
if (facing.getAxis() == Direction.Axis.X)
stacker.rotateZ(90);
else if (facing.getAxis() == Direction.Axis.Z)
stacker.rotateX(90);
stacker.unCentre();
return stack;
};
return rotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, lastState, facing, ms);
}
}

View file

@ -1,20 +1,17 @@
package com.simibubi.create.content.contraptions.components.crafter; package com.simibubi.create.content.contraptions.components.crafter;
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.standardKineticRotationTransform;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.AllSpriteShifts;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase;
import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems; import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -25,11 +22,13 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.standardKineticRotationTransform;
public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<MechanicalCrafterTileEntity> { public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<MechanicalCrafterTileEntity> {
public MechanicalCrafterRenderer(TileEntityRendererDispatcher dispatcher) { public MechanicalCrafterRenderer(TileEntityRendererDispatcher dispatcher) {
@ -154,12 +153,13 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState); if (!FastRenderDispatcher.available(te.getWorld())) {
standardKineticRotationTransform(superBuffer, te, light); SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING) standardKineticRotationTransform(superBuffer, te, light);
.getAxis() != Axis.X ? 0 : Math.PI / 2)); superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING).getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2)); superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
superBuffer.renderInto(ms, vb); superBuffer.renderInto(ms, vb);
}
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(blockState); Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(blockState);
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
@ -177,7 +177,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState, pos); renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState, pos);
if (te.phase == Phase.EXPORTING) { if (te.phase == Phase.EXPORTING) {
int textureIndex = (int) ((te.getCountDownSpeed() / 128f * AnimationTickHolder.ticks)); int textureIndex = (int) ((te.getCountDownSpeed() / 128f * AnimationTickHolder.getTicks()));
beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1); beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1);
} }

View file

@ -1,14 +1,5 @@
package com.simibubi.create.content.contraptions.components.crafter; package com.simibubi.create.content.contraptions.components.crafter;
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
@ -22,7 +13,6 @@ import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipula
import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.Pointing; import com.simibubi.create.foundation.utility.Pointing;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -39,6 +29,14 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
public class MechanicalCrafterTileEntity extends KineticTileEntity { public class MechanicalCrafterTileEntity extends KineticTileEntity {
@ -490,4 +488,9 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
return inventory; return inventory;
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -6,7 +6,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;

View file

@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.components.crank;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
@ -73,4 +72,8 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity {
return AllBlocks.HAND_CRANK.get(); return AllBlocks.HAND_CRANK.get();
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -36,7 +36,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity {
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB makeRenderBoundingBox() {
return new AxisAlignedBB(pos).grow(1); return new AxisAlignedBB(pos).grow(1);
} }

View file

@ -11,12 +11,14 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode; import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode;
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.State; import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.State;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -102,7 +104,9 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light); if (!FastRenderDispatcher.available(te.getWorld())) {
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light);
}
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
@ -178,8 +182,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
double distance = context.position.distanceTo(center); double distance = context.position.distanceTo(center);
double nextDistance = context.position.add(context.motion) double nextDistance = context.position.add(context.motion)
.distanceTo(center); .distanceTo(center);
factor = .5f - MathHelper.clamp(MathHelper.lerp(Minecraft.getInstance() factor = .5f - MathHelper.clamp(MathHelper.lerp(AnimationTickHolder.getPartialTicks(), distance, nextDistance), 0, 1);
.getRenderPartialTicks(), distance, nextDistance), 0, 1);
} }
Vec3d offset = new Vec3d(blockState.get(FACING) Vec3d offset = new Vec3d(blockState.get(FACING)
@ -189,9 +192,9 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
.getModel(); .getModel();
for (MatrixStack m : matrixStacks) for (MatrixStack m : matrixStacks)
m.translate(offset.x, offset.y, offset.z); m.translate(offset.x, offset.y, offset.z);
pole.light(lighting) pole.light(lighting, ContraptionRenderDispatcher.getLightOnContraption(context))
.renderInto(ms, builder); .renderInto(ms, builder);
hand.light(lighting) hand.light(lighting, ContraptionRenderDispatcher.getLightOnContraption(context))
.renderInto(ms, builder); .renderInto(ms, builder);
} }

View file

@ -1,10 +1,5 @@
package com.simibubi.create.content.contraptions.components.deployer; package com.simibubi.create.content.contraptions.components.deployer;
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
import java.util.ArrayList;
import java.util.List;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
@ -15,7 +10,6 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -24,20 +18,20 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceContext.BlockMode; import net.minecraft.util.math.RayTraceContext.BlockMode;
import net.minecraft.util.math.RayTraceContext.FluidMode; import net.minecraft.util.math.RayTraceContext.FluidMode;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import java.util.ArrayList;
import java.util.List;
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
public class DeployerTileEntity extends KineticTileEntity { public class DeployerTileEntity extends KineticTileEntity {
protected State state; protected State state;
@ -346,8 +340,8 @@ public class DeployerTileEntity extends KineticTileEntity {
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB makeRenderBoundingBox() {
return super.getRenderBoundingBox().grow(3); return super.makeRenderBoundingBox().grow(3);
} }
@Override @Override
@ -382,4 +376,8 @@ public class DeployerTileEntity extends KineticTileEntity {
return true; return true;
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -7,8 +7,9 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
@ -26,6 +27,8 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {
if (FastRenderDispatcher.available(te.getWorld())) return;
Direction direction = te.getBlockState() Direction direction = te.getBlockState()
.get(FACING); .get(FACING);
IVertexBuilder vb = buffer.getBuffer(RenderType.getCutoutMipped()); IVertexBuilder vb = buffer.getBuffer(RenderType.getCutoutMipped());

View file

@ -0,0 +1,117 @@
package com.simibubi.create.content.contraptions.components.fan;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstanceKey;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import com.simibubi.create.content.contraptions.base.RotatingData;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.LightType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
public static void register(TileEntityType<? extends EncasedFanTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, FanInstance::new));
}
protected InstanceKey<RotatingData> shaft;
protected InstanceKey<RotatingData> fan;
public FanInstance(InstancedTileRenderer modelManager, EncasedFanTileEntity tile) {
super(modelManager, tile);
}
@Override
protected void init() {
final Direction direction = lastState.get(FACING);
final Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
InstancedModel<RotatingData> shaftHalf =
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState, direction.getOpposite());
InstancedModel<RotatingData> fanInner =
AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouthRotating(modelManager, lastState, direction.getOpposite());
shaft = shaftHalf.setupInstance(data -> {
BlockPos behind = pos.offset(direction.getOpposite());
int blockLight = world.getLightLevel(LightType.BLOCK, behind);
int skyLight = world.getLightLevel(LightType.SKY, behind);
data.setRotationalSpeed(tile.getSpeed())
.setRotationOffset(getRotationOffset(axis))
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector())
.setTileEntity(tile)
.setBlockLight(blockLight)
.setSkyLight(skyLight);
});
fan = fanInner.setupInstance(data -> {
BlockPos inFront = pos.offset(direction);
int blockLight = world.getLightLevel(LightType.BLOCK, inFront);
int skyLight = world.getLightLevel(LightType.SKY, inFront);
data.setRotationalSpeed(getFanSpeed())
.setRotationOffset(getRotationOffset(axis))
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector())
.setTileEntity(tile)
.setBlockLight(blockLight)
.setSkyLight(skyLight);
});
}
private float getFanSpeed() {
float speed = tile.getSpeed() * 5;
if (speed > 0)
speed = MathHelper.clamp(speed, 80, 64 * 20);
if (speed < 0)
speed = MathHelper.clamp(speed, -64 * 20, -80);
return speed;
}
@Override
protected void onUpdate() {
Direction.Axis axis = lastState.get(FACING).getAxis();
updateRotation(shaft, axis);
fan.modifyInstance(data -> {
data.setColor(tile.network)
.setRotationalSpeed(getFanSpeed())
.setRotationOffset(getRotationOffset(axis))
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector());
});
}
@Override
public void updateLight() {
final Direction direction = lastState.get(FACING);
shaft.modifyInstance(data -> {
BlockPos behind = pos.offset(direction.getOpposite());
int blockLight = world.getLightLevel(LightType.BLOCK, behind);
int skyLight = world.getLightLevel(LightType.SKY, behind);
data.setBlockLight(blockLight)
.setSkyLight(skyLight);
});
fan.modifyInstance(data -> {
BlockPos inFront = pos.offset(direction);
int blockLight = world.getLightLevel(LightType.BLOCK, inFront);
int skyLight = world.getLightLevel(LightType.SKY, inFront);
data.setBlockLight(blockLight)
.setSkyLight(skyLight);
});
}
@Override
public void remove() {
shaft.delete();
fan.delete();
}
}

View file

@ -0,0 +1,72 @@
package com.simibubi.create.content.contraptions.components.flywheel;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.foundation.render.backend.instancing.*;
import net.minecraft.block.BlockState;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Rotation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import java.util.function.Consumer;
public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> {
public static void register(TileEntityType<? extends FlywheelTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, FlyWheelInstance::new));
}
protected Direction facing;
protected InstanceKey<RotatingData> shaft;
// protected InstanceKey<RotatingData> wheel;
public FlyWheelInstance(InstancedTileRenderer<?> modelManager, FlywheelTileEntity tile) {
super(modelManager, tile);
}
@Override
protected void init() {
facing = lastState.get(BlockStateProperties.HORIZONTAL_FACING);
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
Consumer<RotatingData> setup = setupFunc(tile.getSpeed(), axis);
shaft = shaftModel().setupInstance(setup);
// wheel = wheelModel().setupInstance(setup);
}
@Override
protected void onUpdate() {
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
updateRotation(shaft, axis);
// updateRotation(wheel, axis);
}
@Override
public void updateLight() {
shaft.modifyInstance(this::relight);
// wheel.modifyInstance(this::relight);
}
@Override
public void remove() {
shaft.delete();
shaft = null;
// wheel.delete();
// wheel = null;
}
protected InstancedModel<RotatingData> shaftModel() {
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState, facing.getOpposite());
}
protected InstancedModel<RotatingData> wheelModel() {
BlockState rotate = lastState.rotate(Rotation.CLOCKWISE_90);
return AllBlockPartials.FLYWHEEL.renderOnDirectionalSouthRotating(modelManager, rotate, rotate.get(BlockStateProperties.HORIZONTAL_FACING));
}
}

View file

@ -9,7 +9,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock.ConnectionState; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock.ConnectionState;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;

View file

@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.components.flywheel;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -48,8 +47,8 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB makeRenderBoundingBox() {
return super.getRenderBoundingBox().grow(2); return super.makeRenderBoundingBox().grow(2);
} }
@Override @Override
@ -101,4 +100,8 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
} }
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -14,6 +14,8 @@ import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class EngineTileEntity extends SmartTileEntity { public class EngineTileEntity extends SmartTileEntity {
@ -34,9 +36,14 @@ public class EngineTileEntity extends SmartTileEntity {
return true; return true;
} }
protected AxisAlignedBB cachedBoundingBox;
@Override @Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return super.getRenderBoundingBox().grow(1.5f); if (cachedBoundingBox == null) {
cachedBoundingBox = super.getRenderBoundingBox().grow(1.5f);
}
return cachedBoundingBox;
} }
@Override @Override

View file

@ -0,0 +1,27 @@
package com.simibubi.create.content.contraptions.components.millstone;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import com.simibubi.create.content.contraptions.base.RotatingData;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class MillStoneCogInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, MillStoneCogInstance::new)); }
public MillStoneCogInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected InstancedModel<RotatingData> getModel() {
return AllBlockPartials.MILLSTONE_COG.renderOnRotating(modelManager, tile.getBlockState());
}
}

View file

@ -4,7 +4,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;

View file

@ -5,8 +5,9 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -22,6 +23,11 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
super(dispatcher); super(dispatcher);
} }
@Override
public boolean isGlobalRenderer(KineticTileEntity te) {
return true;
}
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {
@ -31,8 +37,10 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState); if (!FastRenderDispatcher.available(te.getWorld())) {
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
}
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos); int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);

View file

@ -80,7 +80,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB makeRenderBoundingBox() {
return new AxisAlignedBB(pos).expand(0, -1.5, 0); return new AxisAlignedBB(pos).expand(0, -1.5, 0);
} }

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.motor;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;

View file

@ -4,7 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -19,6 +19,11 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
super(dispatcher); super(dispatcher);
} }
@Override
public boolean isGlobalRenderer(KineticTileEntity te) {
return true;
}
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {

View file

@ -102,7 +102,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB makeRenderBoundingBox() {
return new AxisAlignedBB(pos).expand(0, -1.5, 0) return new AxisAlignedBB(pos).expand(0, -1.5, 0)
.expand(0, 1, 0); .expand(0, 1, 0);
} }

View file

@ -0,0 +1,35 @@
package com.simibubi.create.content.contraptions.components.saw;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import com.simibubi.create.content.contraptions.base.RotatingData;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Rotation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
public class SawInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, SawInstance::new));
}
public SawInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected InstancedModel<RotatingData> getModel() {
if (lastState.get(FACING).getAxis().isHorizontal())
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState.rotate(tile.getWorld(), tile.getPos(), Rotation.CLOCKWISE_180));
else
return rotatingMaterial().getModel(KineticTileEntityRenderer.KINETIC_TILE, shaft(getRotationAxis()));
}
}

View file

@ -8,11 +8,13 @@ import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -42,6 +44,9 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
renderBlade(te, ms, buffer, light); renderBlade(te, ms, buffer, light);
renderItems(te, partialTicks, ms, buffer, light, overlay); renderItems(te, partialTicks, ms, buffer, light, overlay);
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
if (FastRenderDispatcher.available(te.getWorld())) return;
renderShaft(te, ms, buffer, light, overlay); renderShaft(te, ms, buffer, light, overlay);
} }
@ -179,7 +184,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
superBuffer superBuffer
.light(msLocal.peek() .light(msLocal.peek()
.getModel()) .getModel(), ContraptionRenderDispatcher.getLightOnContraption(context))
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
} }

View file

@ -1,11 +1,5 @@
package com.simibubi.create.content.contraptions.components.saw; package com.simibubi.create.content.contraptions.components.saw;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.content.contraptions.components.actors.BlockBreakingKineticTileEntity; import com.simibubi.create.content.contraptions.components.actors.BlockBreakingKineticTileEntity;
@ -21,16 +15,7 @@ import com.simibubi.create.foundation.utility.TreeCutter.Tree;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.recipe.RecipeConditions; import com.simibubi.create.foundation.utility.recipe.RecipeConditions;
import com.simibubi.create.foundation.utility.recipe.RecipeFinder; import com.simibubi.create.foundation.utility.recipe.RecipeFinder;
import net.minecraft.block.*;
import net.minecraft.block.BambooBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CactusBlock;
import net.minecraft.block.ChorusPlantBlock;
import net.minecraft.block.KelpBlock;
import net.minecraft.block.KelpTopBlock;
import net.minecraft.block.StemGrownBlock;
import net.minecraft.block.SugarCaneBlock;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -53,6 +38,12 @@ import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
public class SawTileEntity extends BlockBreakingKineticTileEntity { public class SawTileEntity extends BlockBreakingKineticTileEntity {
private static final Object cuttingRecipesKey = new Object(); private static final Object cuttingRecipesKey = new Object();
@ -393,4 +384,9 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
return false; return false;
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import com.mojang.blaze3d.matrix.MatrixStack;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.MutablePair;
@ -597,6 +598,9 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
return false; return false;
} }
@OnlyIn(Dist.CLIENT)
public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks);
public static class ContraptionRotationState { public static class ContraptionRotationState {
public static final ContraptionRotationState NONE = new ContraptionRotationState(); public static final ContraptionRotationState NONE = new ContraptionRotationState();

View file

@ -28,6 +28,7 @@ import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateBl
import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock; import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.fluid.CombinedTankWrapper; import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
import com.simibubi.create.foundation.render.backend.light.EmptyLighter;
import com.simibubi.create.foundation.utility.*; import com.simibubi.create.foundation.utility.*;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.block.*; import net.minecraft.block.*;
@ -56,6 +57,8 @@ import net.minecraft.util.palette.PaletteHashMap;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.Constants.BlockFlags; import net.minecraftforge.common.util.Constants.BlockFlags;
import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -101,7 +104,8 @@ public abstract class Contraption {
// Client // Client
public Map<BlockPos, TileEntity> presentTileEntities; public Map<BlockPos, TileEntity> presentTileEntities;
public List<TileEntity> renderedTileEntities; public List<TileEntity> maybeInstancedTileEntities;
public List<TileEntity> specialRenderedTileEntities;
public Contraption() { public Contraption() {
blocks = new HashMap<>(); blocks = new HashMap<>();
@ -114,7 +118,8 @@ public abstract class Contraption {
glueToRemove = new ArrayList<>(); glueToRemove = new ArrayList<>();
initialPassengers = new HashMap<>(); initialPassengers = new HashMap<>();
presentTileEntities = new HashMap<>(); presentTileEntities = new HashMap<>();
renderedTileEntities = new ArrayList<>(); maybeInstancedTileEntities = new ArrayList<>();
specialRenderedTileEntities = new ArrayList<>();
pendingSubContraptions = new ArrayList<>(); pendingSubContraptions = new ArrayList<>();
stabilizedSubContraptions = new HashMap<>(); stabilizedSubContraptions = new HashMap<>();
} }
@ -592,7 +597,7 @@ public abstract class Contraption {
public void readNBT(World world, CompoundNBT nbt, boolean spawnData) { public void readNBT(World world, CompoundNBT nbt, boolean spawnData) {
blocks.clear(); blocks.clear();
presentTileEntities.clear(); presentTileEntities.clear();
renderedTileEntities.clear(); specialRenderedTileEntities.clear();
INBT blocks = nbt.get("Blocks"); INBT blocks = nbt.get("Blocks");
//used to differentiate between the 'old' and the paletted serialization //used to differentiate between the 'old' and the paletted serialization
@ -794,7 +799,7 @@ public abstract class Contraption {
Block block = info.state.getBlock(); Block block = info.state.getBlock();
CompoundNBT tag = info.nbt; CompoundNBT tag = info.nbt;
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(block); MovementBehaviour movementBehaviour = AllMovementBehaviours.of(block);
if (tag == null || (movementBehaviour != null && movementBehaviour.hasSpecialMovementRenderer())) if (tag == null)
return; return;
tag.putInt("x", info.pos.getX()); tag.putInt("x", info.pos.getX());
@ -817,8 +822,15 @@ public abstract class Contraption {
if (te instanceof KineticTileEntity) if (te instanceof KineticTileEntity)
((KineticTileEntity) te).setSpeed(0); ((KineticTileEntity) te).setSpeed(0);
te.getBlockState(); te.getBlockState();
if (movementBehaviour == null || !movementBehaviour.hasSpecialInstancedRendering())
maybeInstancedTileEntities.add(te);
if (movementBehaviour != null && !movementBehaviour.renderAsNormalTileEntity())
return;
presentTileEntities.put(info.pos, te); presentTileEntities.put(info.pos, te);
renderedTileEntities.add(te); specialRenderedTileEntities.add(te);
} }
}); });
@ -1100,4 +1112,9 @@ public abstract class Contraption {
mountedFluidStorage.updateFluid(containedFluid); mountedFluidStorage.updateFluid(containedFluid);
} }
@OnlyIn(Dist.CLIENT)
public ContraptionLighter<?> makeLighter() {
return new EmptyLighter(this);
}
} }

View file

@ -1,8 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import net.minecraft.client.Minecraft; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.culling.ClippingHelperImpl; import net.minecraft.client.renderer.culling.ClippingHelperImpl;
import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRenderer;
@ -10,29 +10,26 @@ import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public abstract class AbstractContraptionEntityRenderer<C extends AbstractContraptionEntity> extends EntityRenderer<C> { public class ContraptionEntityRenderer<C extends AbstractContraptionEntity> extends EntityRenderer<C> {
protected AbstractContraptionEntityRenderer(EntityRendererManager p_i46179_1_) { public ContraptionEntityRenderer(EntityRendererManager p_i46179_1_) {
super(p_i46179_1_); super(p_i46179_1_);
} }
@Override @Override
public ResourceLocation getEntityTexture(C p_110775_1_) { public ResourceLocation getEntityTexture(C entity) {
return null; return null;
} }
protected abstract void transform(C contraptionEntity, float partialTicks, MatrixStack[] matrixStacks);
@Override @Override
public boolean shouldRender(C entity, ClippingHelperImpl p_225626_2_, double p_225626_3_, double p_225626_5_, public boolean shouldRender(C entity, ClippingHelperImpl clippingHelper, double p_225626_3_, double p_225626_5_,
double p_225626_7_) { double p_225626_7_) {
if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_)) if (entity.getContraption() == null)
return false; return false;
if (!entity.isAlive()) if (!entity.isAlive())
return false; return false;
if (entity.getContraption() == null)
return false; return super.shouldRender(entity, clippingHelper, p_225626_3_, p_225626_5_, p_225626_7_);
return true;
} }
@Override @Override
@ -41,21 +38,20 @@ public abstract class AbstractContraptionEntityRenderer<C extends AbstractContra
super.render(entity, yaw, partialTicks, ms, buffers, overlay); super.render(entity, yaw, partialTicks, ms, buffers, overlay);
// Keep a copy of the transforms in order to determine correct lighting // Keep a copy of the transforms in order to determine correct lighting
MatrixStack msLocal = getLocalTransform(entity); MatrixStack msLocal = translateTo(entity, AnimationTickHolder.getRenderTick());
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal }; MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
ms.push(); ms.push();
transform(entity, partialTicks, matrixStacks); entity.doLocalTransforms(partialTicks, matrixStacks);
Contraption contraption = entity.getContraption(); Contraption contraption = entity.getContraption();
if (contraption != null) if (contraption != null) {
ContraptionRenderer.render(entity.world, contraption, ms, msLocal, buffers); ContraptionRenderDispatcher.render(entity, ms, buffers, msLocal, contraption);
}
ms.pop(); ms.pop();
} }
protected MatrixStack getLocalTransform(AbstractContraptionEntity entity) { protected MatrixStack translateTo(AbstractContraptionEntity entity, float pt) {
double pt = Minecraft.getInstance()
.getRenderPartialTicks();
MatrixStack matrixStack = new MatrixStack(); MatrixStack matrixStack = new MatrixStack();
double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()); double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX());
double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()); double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY());

View file

@ -7,6 +7,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.WorldAttached; import com.simibubi.create.foundation.utility.WorldAttached;
@ -17,7 +18,9 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.fml.DistExecutor;
public class ContraptionHandler { public class ContraptionHandler {

View file

@ -0,0 +1,42 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
import com.simibubi.create.foundation.render.backend.light.GridAlignedBB;
import com.simibubi.create.foundation.render.backend.light.LightVolume;
public abstract class ContraptionLighter<C extends Contraption> {
protected final C contraption;
public final LightVolume lightVolume;
protected GridAlignedBB bounds;
protected boolean scheduleRebuild;
protected ContraptionLighter(C contraption) {
this.contraption = contraption;
bounds = getContraptionBounds();
lightVolume = new LightVolume(contraptionBoundsToVolume(bounds.copy()));
lightVolume.initialize(contraption.entity.world);
scheduleRebuild = true;
}
protected GridAlignedBB contraptionBoundsToVolume(GridAlignedBB bounds) {
bounds.grow(1); // so we have at least enough data on the edges to avoid artifacts and have smooth lighting
bounds.minY = Math.max(bounds.minY, 0);
bounds.maxY = Math.min(bounds.maxY, 255);
return bounds;
}
public void tick(RenderedContraption owner) {
if (scheduleRebuild) {
lightVolume.initialize(owner.contraption.entity.world);
scheduleRebuild = false;
}
}
public abstract GridAlignedBB getContraptionBounds();
}

View file

@ -1,157 +0,0 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.SuperByteBufferCache;
import com.simibubi.create.foundation.utility.SuperByteBufferCache.Compartment;
import com.simibubi.create.foundation.utility.TileEntityRenderHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockModelRenderer;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.model.data.EmptyModelData;
public class ContraptionRenderer {
public static final Compartment<Pair<Contraption, Integer>> CONTRAPTION = new Compartment<>();
protected static PlacementSimulationWorld renderWorld;
public static void render(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) {
renderTileEntities(world, c, ms, msLocal, buffer);
if (buffer instanceof IRenderTypeBuffer.Impl)
((IRenderTypeBuffer.Impl) buffer).draw();
renderStructure(world, c, ms, msLocal, buffer);
renderActors(world, c, ms, msLocal, buffer);
}
protected static void renderStructure(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) {
SuperByteBufferCache bufferCache = CreateClient.bufferCache;
List<RenderType> blockLayers = RenderType.getBlockLayers();
buffer.getBuffer(RenderType.getSolid());
for (int i = 0; i < blockLayers.size(); i++) {
RenderType layer = blockLayers.get(i);
Pair<Contraption, Integer> key = Pair.of(c, i);
SuperByteBuffer contraptionBuffer = bufferCache.get(CONTRAPTION, key, () -> buildStructureBuffer(c, layer));
if (contraptionBuffer.isEmpty())
continue;
Matrix4f model = msLocal.peek()
.getModel();
contraptionBuffer.light(model)
.renderInto(ms, buffer.getBuffer(layer));
}
}
private static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) {
TileEntityRenderHelper.renderTileEntities(world, c.renderedTileEntities, ms, msLocal, buffer);
}
private static SuperByteBuffer buildStructureBuffer(Contraption c, RenderType layer) {
if (renderWorld == null || renderWorld.getWorld() != Minecraft.getInstance().world)
renderWorld = new PlacementSimulationWorld(Minecraft.getInstance().world);
ForgeHooksClient.setRenderLayer(layer);
MatrixStack ms = new MatrixStack();
BlockRendererDispatcher dispatcher = Minecraft.getInstance()
.getBlockRendererDispatcher();
BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer();
Random random = new Random();
BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize());
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
renderWorld.setTileEntities(c.presentTileEntities.values());
for (BlockInfo info : c.getBlocks()
.values())
renderWorld.setBlockState(info.pos, info.state);
for (BlockInfo info : c.getBlocks()
.values()) {
BlockState state = info.state;
if (state.getRenderType() == BlockRenderType.ENTITYBLOCK_ANIMATED)
continue;
if (!RenderTypeLookup.canRenderInLayer(state, layer))
continue;
IBakedModel originalModel = dispatcher.getModelForState(state);
ms.push();
ms.translate(info.pos.getX(), info.pos.getY(), info.pos.getZ());
blockRenderer.renderModel(renderWorld, originalModel, state, info.pos, ms, builder, true, random, 42,
OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE);
ms.pop();
}
builder.finishDrawing();
renderWorld.clear();
return new SuperByteBuffer(builder);
}
private static void renderActors(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) {
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
for (Pair<BlockInfo, MovementContext> actor : c.getActors()) {
MovementContext context = actor.getRight();
if (context == null)
continue;
if (context.world == null)
context.world = world;
BlockInfo blockInfo = actor.getLeft();
for (MatrixStack m : matrixStacks) {
m.push();
MatrixStacker.of(m)
.translate(blockInfo.pos);
}
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
if (movementBehaviour != null)
movementBehaviour.renderInContraption(context, ms, msLocal, buffer);
for (MatrixStack m : matrixStacks)
m.pop();
}
}
public static int getLight(World world, float lx, float ly, float lz) {
BlockPos.Mutable pos = new BlockPos.Mutable();
float sky = 0, block = 0;
float offset = 1 / 8f;
for (float zOffset = offset; zOffset >= -offset; zOffset -= 2 * offset)
for (float yOffset = offset; yOffset >= -offset; yOffset -= 2 * offset)
for (float xOffset = offset; xOffset >= -offset; xOffset -= 2 * offset) {
pos.setPos(lx + xOffset, ly + yOffset, lz + zOffset);
sky += world.getLightLevel(LightType.SKY, pos) / 8f;
block += world.getLightLevel(LightType.BLOCK, pos) / 8f;
}
return ((int) sky) << 20 | ((int) block) << 4;
}
}

View file

@ -2,8 +2,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
import static com.simibubi.create.foundation.utility.AngleHelper.angleLerp; import static com.simibubi.create.foundation.utility.AngleHelper.angleLerp;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllEntityTypes;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingContraption; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingContraption;
import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -219,4 +221,18 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
setPos(x, y, z); setPos(x, y, z);
this.angle = angle; this.angle = angle;
} }
@Override
@OnlyIn(Dist.CLIENT)
public void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks) {
float angle = getAngle(partialTicks);
Axis axis = getRotationAxis();
for (MatrixStack stack : matrixStacks)
MatrixStacker.of(stack)
.nudge(getEntityId())
.centre()
.rotate(angle, axis)
.unCentre();
}
} }

View file

@ -1,29 +0,0 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.util.Direction.Axis;
public class ControlledContraptionEntityRenderer extends AbstractContraptionEntityRenderer<ControlledContraptionEntity> {
public ControlledContraptionEntityRenderer(EntityRendererManager p_i46179_1_) {
super(p_i46179_1_);
}
@Override
protected void transform(ControlledContraptionEntity entity, float partialTicks,
MatrixStack[] matrixStacks) {
float angle = entity.getAngle(partialTicks);
Axis axis = entity.getRotationAxis();
for (MatrixStack stack : matrixStacks)
MatrixStacker.of(stack)
.nudge(entity.getEntityId())
.centre()
.rotate(angle, axis)
.unCentre();
}
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -47,14 +48,21 @@ public abstract class MovementBehaviour {
} }
public boolean hasSpecialMovementRenderer() { public boolean renderAsNormalTileEntity() {
return true; return false;
}
public boolean hasSpecialInstancedRendering() {
return false;
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) {} IRenderTypeBuffer buffer) {}
@OnlyIn(Dist.CLIENT)
public void addInstance(RenderedContraption contraption, MovementContext context) {}
public void onSpeedChanged(MovementContext context, Vec3d oldMotion, Vec3d motion) { public void onSpeedChanged(MovementContext context, Vec3d oldMotion, Vec3d motion) {
} }

View file

@ -0,0 +1,39 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
import com.simibubi.create.foundation.render.backend.light.GridAlignedBB;
public class NonStationaryLighter<C extends Contraption> extends ContraptionLighter<C> {
public NonStationaryLighter(C contraption) {
super(contraption);
}
@Override
protected GridAlignedBB contraptionBoundsToVolume(GridAlignedBB bounds) {
bounds.grow(2); // so we have at least enough data on the edges to avoid artifacts and have smooth lighting
bounds.minY = Math.max(bounds.minY, 0);
bounds.maxY = Math.min(bounds.maxY, 255);
return bounds;
}
@Override
public void tick(RenderedContraption owner) {
super.tick(owner);
GridAlignedBB contraptionBounds = getContraptionBounds();
if (!contraptionBounds.sameAs(bounds)) {
lightVolume.move(contraption.entity.world, contraptionBoundsToVolume(contraptionBounds));
bounds = contraptionBounds;
}
}
@Override
public GridAlignedBB getContraptionBounds() {
GridAlignedBB bb = GridAlignedBB.fromAABB(contraption.bounds);
bb.translate(contraption.entity.getPosition());
return bb;
}
}

View file

@ -7,6 +7,7 @@ import java.util.UUID;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllEntityTypes;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.StabilizedContraption; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.StabilizedContraption;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode; import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode;
@ -14,10 +15,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.mou
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.*;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -40,6 +38,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
/** /**
@ -494,4 +494,89 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
yaw = angle; yaw = angle;
} }
@Override
@OnlyIn(Dist.CLIENT)
public void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks) {
float angleInitialYaw = getInitialYaw();
float angleYaw = getYaw(partialTicks);
float anglePitch = getPitch(partialTicks);
for (MatrixStack stack : matrixStacks)
stack.translate(-.5f, 0, -.5f);
Entity ridingEntity = getRidingEntity();
if (ridingEntity instanceof AbstractMinecartEntity)
repositionOnCart(partialTicks, matrixStacks, ridingEntity);
else if (ridingEntity instanceof AbstractContraptionEntity) {
if (ridingEntity.getRidingEntity() instanceof AbstractMinecartEntity)
repositionOnCart(partialTicks, matrixStacks, ridingEntity.getRidingEntity());
else
repositionOnContraption(partialTicks, matrixStacks, ridingEntity);
}
for (MatrixStack stack : matrixStacks)
MatrixStacker.of(stack)
.nudge(getEntityId())
.centre()
.rotateY(angleYaw)
.rotateZ(anglePitch)
.rotateY(angleInitialYaw)
.unCentre();
}
@OnlyIn(Dist.CLIENT)
private void repositionOnContraption(float partialTicks, MatrixStack[] matrixStacks, Entity ridingEntity) {
Vec3d pos = getContraptionOffset(partialTicks, ridingEntity);
for (MatrixStack stack : matrixStacks)
stack.translate(pos.x, pos.y, pos.z);
}
// Minecarts do not always render at their exact location, so the contraption
// has to adjust aswell
@OnlyIn(Dist.CLIENT)
private void repositionOnCart(float partialTicks, MatrixStack[] matrixStacks, Entity ridingEntity) {
Vec3d cartPos = getCartOffset(partialTicks, ridingEntity);
if (cartPos == Vec3d.ZERO) return;
for (MatrixStack stack : matrixStacks)
stack.translate(cartPos.x, cartPos.y, cartPos.z);
}
@OnlyIn(Dist.CLIENT)
private Vec3d getContraptionOffset(float partialTicks, Entity ridingEntity) {
AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity;
Vec3d passengerPosition = parent.getPassengerPosition(this, partialTicks);
double x = passengerPosition.x - MathHelper.lerp(partialTicks, this.lastTickPosX, this.getX());
double y = passengerPosition.y - MathHelper.lerp(partialTicks, this.lastTickPosY, this.getY());
double z = passengerPosition.z - MathHelper.lerp(partialTicks, this.lastTickPosZ, this.getZ());
return new Vec3d(x, y, z);
}
@OnlyIn(Dist.CLIENT)
private Vec3d getCartOffset(float partialTicks, Entity ridingEntity) {
AbstractMinecartEntity cart = (AbstractMinecartEntity) ridingEntity;
double cartX = MathHelper.lerp(partialTicks, cart.lastTickPosX, cart.getX());
double cartY = MathHelper.lerp(partialTicks, cart.lastTickPosY, cart.getY());
double cartZ = MathHelper.lerp(partialTicks, cart.lastTickPosZ, cart.getZ());
Vec3d cartPos = cart.getPos(cartX, cartY, cartZ);
if (cartPos != null) {
Vec3d cartPosFront = cart.getPosOffset(cartX, cartY, cartZ, (double) 0.3F);
Vec3d cartPosBack = cart.getPosOffset(cartX, cartY, cartZ, (double) -0.3F);
if (cartPosFront == null)
cartPosFront = cartPos;
if (cartPosBack == null)
cartPosBack = cartPos;
cartX = cartPos.x - cartX;
cartY = (cartPosFront.y + cartPosBack.y) / 2.0D - cartY;
cartZ = cartPos.z - cartZ;
return new Vec3d(cartX, cartY, cartZ);
}
return Vec3d.ZERO;
}
} }

View file

@ -1,16 +1,9 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.client.renderer.culling.ClippingHelperImpl; import net.minecraft.client.renderer.culling.ClippingHelperImpl;
import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class OrientedContraptionEntityRenderer extends AbstractContraptionEntityRenderer<OrientedContraptionEntity> { public class OrientedContraptionEntityRenderer extends ContraptionEntityRenderer<OrientedContraptionEntity> {
public OrientedContraptionEntityRenderer(EntityRendererManager p_i46179_1_) { public OrientedContraptionEntityRenderer(EntityRendererManager p_i46179_1_) {
super(p_i46179_1_); super(p_i46179_1_);
@ -18,79 +11,12 @@ public class OrientedContraptionEntityRenderer extends AbstractContraptionEntity
@Override @Override
public boolean shouldRender(OrientedContraptionEntity entity, ClippingHelperImpl p_225626_2_, double p_225626_3_, public boolean shouldRender(OrientedContraptionEntity entity, ClippingHelperImpl p_225626_2_, double p_225626_3_,
double p_225626_5_, double p_225626_7_) { double p_225626_5_, double p_225626_7_) {
if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_)) if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_))
return false; return false;
if (entity.getContraption() if (entity.getContraption()
.getType() == ContraptionType.MOUNTED && entity.getRidingEntity() == null) .getType() == ContraptionType.MOUNTED && entity.getRidingEntity() == null)
return false; return false;
return true; return true;
} }
@Override
protected void transform(OrientedContraptionEntity entity, float partialTicks, MatrixStack[] matrixStacks) {
float angleInitialYaw = entity.getInitialYaw();
float angleYaw = entity.getYaw(partialTicks);
float anglePitch = entity.getPitch(partialTicks);
for (MatrixStack stack : matrixStacks)
stack.translate(-.5f, 0, -.5f);
Entity ridingEntity = entity.getRidingEntity();
if (ridingEntity instanceof AbstractMinecartEntity)
repositionOnCart(partialTicks, matrixStacks, ridingEntity);
if (ridingEntity instanceof AbstractContraptionEntity) {
if (ridingEntity.getRidingEntity() instanceof AbstractMinecartEntity)
repositionOnCart(partialTicks, matrixStacks, ridingEntity.getRidingEntity());
else
repositionOnContraption(entity, partialTicks, matrixStacks, ridingEntity);
}
for (MatrixStack stack : matrixStacks)
MatrixStacker.of(stack)
.nudge(entity.getEntityId())
.centre()
.rotateY(angleYaw)
.rotateZ(anglePitch)
.rotateY(angleInitialYaw)
.unCentre();
}
private void repositionOnContraption(OrientedContraptionEntity entity, float partialTicks,
MatrixStack[] matrixStacks, Entity ridingEntity) {
AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity;
Vec3d passengerPosition = parent.getPassengerPosition(entity, partialTicks);
double x = passengerPosition.x - MathHelper.lerp(partialTicks, entity.lastTickPosX, entity.getX());
double y = passengerPosition.y - MathHelper.lerp(partialTicks, entity.lastTickPosY, entity.getY());
double z = passengerPosition.z - MathHelper.lerp(partialTicks, entity.lastTickPosZ, entity.getZ());
for (MatrixStack stack : matrixStacks)
stack.translate(x, y, z);
}
// Minecarts do not always render at their exact location, so the contraption
// has to adjust aswell
private void repositionOnCart(float partialTicks, MatrixStack[] matrixStacks, Entity ridingEntity) {
AbstractMinecartEntity cart = (AbstractMinecartEntity) ridingEntity;
double cartX = MathHelper.lerp(partialTicks, cart.lastTickPosX, cart.getX());
double cartY = MathHelper.lerp(partialTicks, cart.lastTickPosY, cart.getY());
double cartZ = MathHelper.lerp(partialTicks, cart.lastTickPosZ, cart.getZ());
Vec3d cartPos = cart.getPos(cartX, cartY, cartZ);
if (cartPos != null) {
Vec3d cartPosFront = cart.getPosOffset(cartX, cartY, cartZ, (double) 0.3F);
Vec3d cartPosBack = cart.getPosOffset(cartX, cartY, cartZ, (double) -0.3F);
if (cartPosFront == null)
cartPosFront = cartPos;
if (cartPosBack == null)
cartPosBack = cartPos;
cartX = cartPos.x - cartX;
cartY = (cartPosFront.y + cartPosBack.y) / 2.0D - cartY;
cartZ = cartPos.z - cartZ;
for (MatrixStack stack : matrixStacks)
stack.translate(cartX, cartY, cartZ);
}
}
} }

View file

@ -1,5 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement.bearing; package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.AllTags.AllBlockTags;
@ -90,4 +93,9 @@ public class BearingContraption extends Contraption {
return facing.getAxis() == this.facing.getAxis(); return facing.getAxis() == this.facing.getAxis();
} }
@OnlyIn(Dist.CLIENT)
@Override
public ContraptionLighter<?> makeLighter() {
return new BearingLighter(this);
}
} }

View file

@ -0,0 +1,54 @@
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import com.simibubi.create.foundation.render.backend.light.GridAlignedBB;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import java.util.Set;
public class BearingLighter extends ContraptionLighter<BearingContraption> {
public BearingLighter(BearingContraption contraption) {
super(contraption);
}
@Override
public GridAlignedBB getContraptionBounds() {
Set<BlockPos> blocks = contraption.getBlocks().keySet();
Direction orientation = contraption.facing;
float maxDistanceSq = -1;
for (BlockPos pos : blocks) {
float x = pos.getX();
float y = pos.getY();
float z = pos.getZ();
float distSq = x * x + y * y + z * z;
if (distSq > maxDistanceSq) maxDistanceSq = distSq;
}
int radius = (int) (Math.ceil(Math.sqrt(maxDistanceSq)));
GridAlignedBB betterBounds = GridAlignedBB.ofRadius(radius);
GridAlignedBB contraptionBounds = GridAlignedBB.fromAABB(contraption.bounds);
Direction.Axis axis = orientation.getAxis();
if (axis == Direction.Axis.X) {
betterBounds.maxX = contraptionBounds.maxX;
betterBounds.minX = contraptionBounds.minX;
} else if (axis == Direction.Axis.Y) {
betterBounds.maxY = contraptionBounds.maxY;
betterBounds.minY = contraptionBounds.minY;
} else if (axis == Direction.Axis.Z) {
betterBounds.maxZ = contraptionBounds.maxZ;
betterBounds.minZ = contraptionBounds.minZ;
}
betterBounds.translate(contraption.anchor);
return betterBounds;
}
}

View file

@ -5,7 +5,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;

View file

@ -408,4 +408,8 @@ public class ClockworkBearingTileEntity extends KineticTileEntity implements IBe
return pos; return pos;
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -298,4 +298,9 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
TooltipHelper.addHint(tooltip, "hint.empty_bearing"); TooltipHelper.addHint(tooltip, "hint.empty_bearing");
return true; return true;
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -2,15 +2,11 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.*;
import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
@ -28,8 +24,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
Direction facing = context.state.get(BlockStateProperties.FACING); Direction facing = context.state.get(BlockStateProperties.FACING);
AllBlockPartials top = AllBlockPartials.BEARING_TOP; AllBlockPartials top = AllBlockPartials.BEARING_TOP;
SuperByteBuffer superBuffer = top.renderOn(context.state); SuperByteBuffer superBuffer = top.renderOn(context.state);
float renderPartialTicks = Minecraft.getInstance() float renderPartialTicks = AnimationTickHolder.getPartialTicks();
.getRenderPartialTicks();
// rotate to match blockstate // rotate to match blockstate
Axis axis = facing.getAxis(); Axis axis = facing.getAxis();
@ -63,7 +58,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
// render // render
superBuffer.light(msLocal.peek() superBuffer.light(msLocal.peek()
.getModel()); .getModel(), ContraptionRenderDispatcher.getLightOnContraption(context));
superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
} }

View file

@ -3,7 +3,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType;
import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.NonStationaryLighter;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
@ -26,12 +27,11 @@ public class StabilizedContraption extends Contraption {
if (!searchMovedStructure(world, offset, null)) if (!searchMovedStructure(world, offset, null))
return false; return false;
startMoving(world); startMoving(world);
expandBoundsAroundAxis(Axis.Y);
if (blocks.isEmpty()) if (blocks.isEmpty())
return false; return false;
return true; return true;
} }
@Override @Override
protected boolean isAnchoringBlockAt(BlockPos pos) { protected boolean isAnchoringBlockAt(BlockPos pos) {
return false; return false;
@ -64,4 +64,8 @@ public class StabilizedContraption extends Contraption {
return facing; return facing;
} }
@Override
public ContraptionLighter<?> makeLighter() {
return new NonStationaryLighter<>(this);
}
} }

View file

@ -1,9 +1,7 @@
package com.simibubi.create.content.contraptions.components.structureMovement.gantry; package com.simibubi.create.content.contraptions.components.structureMovement.gantry;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; import com.simibubi.create.content.contraptions.components.structureMovement.*;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType;
import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -60,4 +58,8 @@ public class GantryContraption extends TranslatingContraption {
return super.shouldUpdateAfterMovement(info) && !AllBlocks.GANTRY_PINION.has(info.state); return super.shouldUpdateAfterMovement(info) && !AllBlocks.GANTRY_PINION.has(info.state);
} }
@Override
public ContraptionLighter<?> makeLighter() {
return new NonStationaryLighter<>(this);
}
} }

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.gantry; package com.simibubi.create.content.contraptions.components.structureMovement.gantry;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllEntityTypes;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
@ -172,6 +173,9 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
return ContraptionRotationState.NONE; return ContraptionRotationState.NONE;
} }
@Override
public void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks) { }
public void updateClientMotion() { public void updateClientMotion() {
float modifier = movementAxis.getAxisDirection() float modifier = movementAxis.getAxisDirection()
.getOffset(); .getOffset();

View file

@ -1,18 +0,0 @@
package com.simibubi.create.content.contraptions.components.structureMovement.gantry;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
public class GantryContraptionEntityRenderer extends AbstractContraptionEntityRenderer<GantryContraptionEntity> {
public GantryContraptionEntityRenderer(EntityRendererManager p_i46179_1_) {
super(p_i46179_1_);
}
@Override
protected void transform(GantryContraptionEntity contraptionEntity, float partialTicks,
MatrixStack[] matrixStacks) {}
}

View file

@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
@ -59,7 +60,7 @@ public class GantryPinionRenderer extends KineticTileEntityRenderer {
.rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0); .rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0);
ms.translate(0, -9 / 16f, 0); ms.translate(0, -9 / 16f, 0);
ms.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-angleForTe / 2f)); ms.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-angleForTe));
ms.translate(0, 9 / 16f, 0); ms.translate(0, 9 / 16f, 0);
msr.unCentre(); msr.unCentre();
@ -70,6 +71,12 @@ public class GantryPinionRenderer extends KineticTileEntityRenderer {
ms.pop(); ms.pop();
} }
public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) {
float time = AnimationTickHolder.getRenderTick();
float offset = getRotationOffsetForPosition(te, pos, axis);
return ((time * te.getSpeed() * 3f / 20 + offset) % 360) / 180 * (float) Math.PI;
}
@Override @Override
protected BlockState getRenderedBlockState(KineticTileEntity te) { protected BlockState getRenderedBlockState(KineticTileEntity te) {
return shaft(getRotationAxisOf(te)); return shaft(getRotationAxisOf(te));

View file

@ -164,4 +164,8 @@ public class GantryPinionTileEntity extends KineticTileEntity implements IDispla
return te instanceof GantryShaftTileEntity && ((GantryShaftTileEntity) te).canAssembleOn(); return te instanceof GantryShaftTileEntity && ((GantryShaftTileEntity) te).canAssembleOn();
} }
@Override
public boolean shouldRenderAsTE() {
return true;
}
} }

View file

@ -1,9 +1,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement.glue; package com.simibubi.create.content.contraptions.components.structureMovement.glue;
import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllEntityTypes;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
@ -12,17 +8,13 @@ import com.simibubi.create.content.schematics.ISpecialEntityItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.BlockFace;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity; import net.minecraft.entity.*;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.Pose;
import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -30,20 +22,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket; import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ActionResultType; import net.minecraft.util.*;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Hand; import net.minecraft.util.math.*;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.RayTraceResult.Type; import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -52,6 +33,9 @@ import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor;
import org.apache.commons.lang3.Validate;
import javax.annotation.Nullable;
public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement { public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement {
@ -266,7 +250,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
ClientPlayerEntity cPlayer = (ClientPlayerEntity) player; ClientPlayerEntity cPlayer = (ClientPlayerEntity) player;
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
RayTraceResult ray = RayTraceResult ray =
cPlayer.pick(mc.playerController.getBlockReachDistance(), mc.getRenderPartialTicks(), false); cPlayer.pick(mc.playerController.getBlockReachDistance(), AnimationTickHolder.getPartialTicks(), false);
if (!(ray instanceof BlockRayTraceResult)) if (!(ray instanceof BlockRayTraceResult))
return; return;

View file

@ -10,7 +10,9 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType;
import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.NonStationaryLighter;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode; import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -33,6 +35,11 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper; import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.InvWrapper;
import org.apache.commons.lang3.tuple.Pair;
import java.util.List;
import static com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock.RAIL_SHAPE;
public class MountedContraption extends Contraption { public class MountedContraption extends Contraption {
@ -160,4 +167,9 @@ public class MountedContraption extends Contraption {
IItemHandlerModifiable handlerFromInv = new InvWrapper((IInventory) cart); IItemHandlerModifiable handlerFromInv = new InvWrapper((IInventory) cart);
inventory = new CombinedInvWrapper(handlerFromInv, inventory); inventory = new CombinedInvWrapper(handlerFromInv, inventory);
} }
@Override
public ContraptionLighter<?> makeLighter() {
return new NonStationaryLighter<>(this);
}
} }

View file

@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption; import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption;
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.*; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.*;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.CarpetBlock; import net.minecraft.block.CarpetBlock;
@ -20,6 +21,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraft.world.gen.feature.template.Template.BlockInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList; import java.util.ArrayList;
@ -236,4 +239,9 @@ public class PistonContraption extends TranslatingContraption {
return tag; return tag;
} }
@OnlyIn(Dist.CLIENT)
@Override
public ContraptionLighter<?> makeLighter() {
return new PistonLighter(this);
}
} }

View file

@ -0,0 +1,34 @@
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import com.simibubi.create.foundation.render.backend.light.GridAlignedBB;
import net.minecraft.util.math.Vec3i;
public class PistonLighter extends ContraptionLighter<PistonContraption> {
public PistonLighter(PistonContraption contraption) {
super(contraption);
}
@Override
public GridAlignedBB getContraptionBounds() {
GridAlignedBB bounds = GridAlignedBB.fromAABB(contraption.bounds);
bounds.translate(contraption.anchor);
int length = contraption.extensionLength;
Vec3i direction = contraption.orientation.getDirectionVec();
int shift = length / 2;
int shiftX = direction.getX() * shift;
int shiftY = direction.getY() * shift;
int shiftZ = direction.getZ() * shift;
bounds.translate(shiftX, shiftY, shiftZ);
int grow = (length + 1) / 2;
int extendX = Math.abs(direction.getX() * grow);
int extendY = Math.abs(direction.getY() * grow);
int extendZ = Math.abs(direction.getZ() * grow);
bounds.grow(extendX, extendY, extendZ);
return bounds;
}
}

View file

@ -7,7 +7,7 @@ import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;

View file

@ -4,6 +4,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ass
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType;
import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption; import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -54,4 +55,8 @@ public class PulleyContraption extends TranslatingContraption {
super.readNBT(world, nbt, spawnData); super.readNBT(world, nbt, spawnData);
} }
@Override
public ContraptionLighter<?> makeLighter() {
return new PulleyLighter(this);
}
} }

View file

@ -0,0 +1,31 @@
package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import com.simibubi.create.foundation.render.backend.light.GridAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class PulleyLighter extends ContraptionLighter<PulleyContraption> {
public PulleyLighter(PulleyContraption contraption) {
super(contraption);
}
@Override
public GridAlignedBB getContraptionBounds() {
GridAlignedBB bounds = GridAlignedBB.fromAABB(contraption.bounds);
World world = contraption.entity.world;
BlockPos.Mutable pos = new BlockPos.Mutable(contraption.anchor);
while (!AllBlocks.ROPE_PULLEY.has(world.getBlockState(pos)) && pos.getY() < 256) {
pos.move(0, 1, 0);
}
bounds.translate(pos);
bounds.minY = 1; // the super constructor will take care of making this 0
return bounds;
}
}

View file

@ -5,7 +5,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;

View file

@ -32,8 +32,8 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB makeRenderBoundingBox() {
return super.getRenderBoundingBox().expand(0, -offset, 0); return super.makeRenderBoundingBox().expand(0, -offset, 0);
} }
@Override @Override

View file

@ -0,0 +1,26 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.simibubi.create.foundation.render.AllProgramSpecs;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel;
import com.simibubi.create.content.contraptions.base.KineticRenderMaterials;
import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial;
import com.simibubi.create.content.contraptions.base.RotatingInstancedModel;
import com.simibubi.create.content.contraptions.components.actors.RotatingActorModel;
import net.minecraft.util.math.BlockPos;
public class ContraptionKineticRenderer extends InstancedTileRenderer<ContraptionProgram> {
@Override
public void registerMaterials() {
materials.put(KineticRenderMaterials.BELTS, new RenderMaterial<>(this, AllProgramSpecs.CONTRAPTION_BELT, BeltInstancedModel::new));
materials.put(KineticRenderMaterials.ROTATING, new RenderMaterial<>(this, AllProgramSpecs.CONTRAPTION_ROTATING, RotatingInstancedModel::new));
materials.put(KineticRenderMaterials.ACTORS, new RenderMaterial<>(this, AllProgramSpecs.CONTRAPTION_ACTOR, RotatingActorModel::new));
}
@Override
public BlockPos getOriginCoordinate() {
return BlockPos.ZERO;
}
}

View file

@ -0,0 +1,50 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.simibubi.create.foundation.render.backend.BufferedModel;
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.LightTexture;
import java.nio.ByteBuffer;
public class ContraptionModel extends BufferedModel {
public static final VertexFormat FORMAT = VertexFormat.builder()
.addAttributes(ContraptionVertexAttributes.class)
.build();
public ContraptionModel(BufferBuilder buf) {
super(buf);
}
@Override
protected void copyVertex(ByteBuffer to, int vertex) {
to.putFloat(getX(template, vertex));
to.putFloat(getY(template, vertex));
to.putFloat(getZ(template, vertex));
to.put(getNX(template, vertex));
to.put(getNY(template, vertex));
to.put(getNZ(template, vertex));
to.putFloat(getU(template, vertex));
to.putFloat(getV(template, vertex));
to.put(getR(template, vertex));
to.put(getG(template, vertex));
to.put(getB(template, vertex));
to.put(getA(template, vertex));
int light = getLight(template, vertex);
byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4);
byte block = (byte) (LightTexture.getBlockLightCoordinates(light) << 4);
to.put(block);
to.put(sky);
}
@Override
protected VertexFormat getModelFormat() {
return FORMAT;
}
}

View file

@ -0,0 +1,38 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.simibubi.create.foundation.render.backend.gl.BasicProgram;
import com.simibubi.create.foundation.render.backend.light.GridAlignedBB;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import org.lwjgl.opengl.GL20;
public class ContraptionProgram extends BasicProgram {
protected final int uLightBoxSize;
protected final int uLightBoxMin;
protected final int uModel;
protected int uLightVolume;
public ContraptionProgram(ResourceLocation name, int handle) {
super(name, handle);
uLightBoxSize = getUniformLocation("uLightBoxSize");
uLightBoxMin = getUniformLocation("uLightBoxMin");
uModel = getUniformLocation("uModel");
}
@Override
protected void registerSamplers() {
super.registerSamplers();
uLightVolume = setSamplerBinding("uLightVolume", 4);
}
public void bind(Matrix4f model, AxisAlignedBB lightVolume) {
double sizeX = lightVolume.maxX - lightVolume.minX;
double sizeY = lightVolume.maxY - lightVolume.minY;
double sizeZ = lightVolume.maxZ - lightVolume.minZ;
GL20.glUniform3f(uLightBoxSize, (float) sizeX, (float) sizeY, (float) sizeZ);
GL20.glUniform3f(uLightBoxMin, (float) lightVolume.minX, (float) lightVolume.minY, (float) lightVolume.minZ);
uploadMatrixUniform(uModel, model);
}
}

Some files were not shown because too many files have changed in this diff Show more