diff --git a/build.gradle b/build.gradle index 512b6a215f..9120046778 100644 --- a/build.gradle +++ b/build.gradle @@ -1,32 +1,16 @@ -buildscript { - repositories { - maven { url = 'https://maven.minecraftforge.net' } - mavenCentral() - maven { url = 'https://repo.spongepowered.org/repository/maven-public' } - maven { url = 'https://maven.parchmentmc.org' } - } - dependencies { - classpath "net.minecraftforge.gradle:ForgeGradle:${forgegradle_version}" - classpath "org.spongepowered:mixingradle:${mixingradle_version}" - classpath "org.parchmentmc:librarian:${librarian_version}" - } -} - plugins { + id 'eclipse' + id 'idea' + id 'maven-publish' + id 'net.minecraftforge.gradle' version "${forgegradle_version}" + id 'org.parchmentmc.librarian.forgegradle' version "${librarian_version}" + id 'org.spongepowered.mixin' version "${mixingradle_version}" id 'com.matthewprenger.cursegradle' version "${cursegradle_version}" } -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'org.parchmentmc.librarian.forgegradle' -apply plugin: 'eclipse' -apply plugin: 'maven-publish' -apply plugin: 'org.spongepowered.mixin' jarJar.enable() boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false'); -// jozu: I use a gradle workspace with both projects. -// The project is named Flywheel-Forge, but sub-projects are named by folder. -boolean inWorkspace = findProject(':Flywheel') != null ext.buildNumber = System.getenv('BUILD_NUMBER') @@ -38,8 +22,27 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) +mixin { + add sourceSets.main, 'create.refmap.json' + + config 'flywheel.backend.mixins.json' + config 'flywheel.impl.mixins.json' + config 'flywheel.impl.sodium.mixins.json' + config 'create.mixins.json' + + debug.verbose = true + debug.export = true +} + +idea { + module { + downloadJavadoc = true + downloadSources = true + } +} + minecraft { - if (Boolean.parseBoolean(project.use_parchment)) { + if (Boolean.parseBoolean(use_parchment)) { mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}" } else { mappings channel: 'official', version: "${minecraft_version}" @@ -48,64 +51,39 @@ minecraft { accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') runs { - client { - workingDirectory project.file('run') - arg '-mixin.config=create.mixins.json' - //jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling - //jvmArgs '-XX:+IgnoreUnrecognizedVMOptions', '-XX:+AllowEnhancedClassRedefinition' // uncomment with jbr + configureEach { + property 'forge.logging.markers', '' property 'forge.logging.console.level', 'info' + + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + + //jvmArgs '-XX:+IgnoreUnrecognizedVMOptions', '-XX:+AllowEnhancedClassRedefinition' // uncomment with jbr + mods { create { source sourceSets.main } - - if (inWorkspace) { - flywheel { - source project(":Flywheel").sourceSets.main - } - } } } + client { + workingDirectory project.file('run') + } + server { workingDirectory project.file('run/server') - arg '-mixin.config=create.mixins.json' - property 'forge.logging.console.level', 'info' - mods { - create { - source sourceSets.main - } - } } data { workingDirectory project.file('run') - arg '-mixin.config=create.mixins.json' property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' args '--mod', 'create', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources') - mods { - create { - source sourceSets.main - } - - if (inWorkspace) { - flywheel { - source project(":Flywheel").sourceSets.main - } - } - } } gameTestServer { workingDirectory project.file('run/gametest') - arg '-mixin.config=create.mixins.json' - property 'forge.logging.console.level', 'info' - mods { - create { - source sourceSets.main - } - } // setForceExit false <- FIXME 1.20 } } @@ -156,6 +134,7 @@ repositories { } } + mavenCentral() mavenLocal() flatDir { dirs 'libs' @@ -168,17 +147,14 @@ dependencies { jarJar("com.tterrag.registrate:Registrate:${registrate_version}") { jarJar.ranged(it, '[MC1.19.3-1.1.10,)') } - jarJar("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") { - jarJar.ranged(it, '[0.6.11,)') + jarJar("dev.engine_room.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") { + jarJar.ranged(it, '[1.0,2.0)') } implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}") - if (inWorkspace) { - implementation project(':Flywheel') - } else { - implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") - } + compileOnly fg.deobf("dev.engine_room.flywheel:flywheel-forge-api-${flywheel_minecraft_version}:${flywheel_version}") + runtimeOnly fg.deobf("dev.engine_room.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-common-api:${jei_version}") compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge-api:${jei_version}") @@ -252,10 +228,6 @@ sourceSets.main.resources { exclude '.cache/' } -mixin { - add sourceSets.main, 'create.refmap.json' -} - // Workaround for SpongePowered/MixinGradle#38 afterEvaluate { tasks.configureReobfTaskForReobfJar.mustRunAfter(tasks.compileJava) diff --git a/gradle.properties b/gradle.properties index 77c7349b21..4e57046bf4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,22 +8,22 @@ mod_version = 0.5.1.h artifact_minecraft_version = 1.20.1 minecraft_version = 1.20.1 -forge_version = 47.1.43 +forge_version = 47.2.6 # build dependency versions -forgegradle_version = 6.0.6 -mixingradle_version = 0.7-SNAPSHOT +forgegradle_version = [6.0.16,6.2) +mixingradle_version = 0.7.+ mixin_version = 0.8.5 librarian_version = 1.+ cursegradle_version = 1.4.0 -parchment_version = 2023.06.26 +parchment_version = 2023.09.03 use_parchment = true # dependency versions registrate_version = MC1.20-1.3.3 flywheel_minecraft_version = 1.20.1 -flywheel_version = 0.6.11-13 +flywheel_version = 1.0.0-beta-113 jei_minecraft_version = 1.20.1 jei_version = 15.10.0.39 curios_minecraft_version = 1.20.1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa7..c1962a79e2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d3f0..309b4e18db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d65..aeb74cbb43 100755 --- a/gradlew +++ b/gradlew @@ -85,9 +85,6 @@ done APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -144,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/settings.gradle b/settings.gradle index ecc4e71820..c339a6321c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,18 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + maven { url = 'https://repo.spongepowered.org/repository/maven-public' } + maven { url = 'https://maven.parchmentmc.org' } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' +} + rootProject.name = 'Create' diff --git a/src/main/java/com/simibubi/create/AllBlockEntityTypes.java b/src/main/java/com/simibubi/create/AllBlockEntityTypes.java index 8ff7849e6d..d0cccbc369 100644 --- a/src/main/java/com/simibubi/create/AllBlockEntityTypes.java +++ b/src/main/java/com/simibubi/create/AllBlockEntityTypes.java @@ -7,34 +7,34 @@ import com.simibubi.create.content.contraptions.actors.contraptionControls.Contr import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsRenderer; import com.simibubi.create.content.contraptions.actors.harvester.HarvesterBlockEntity; import com.simibubi.create.content.contraptions.actors.harvester.HarvesterRenderer; -import com.simibubi.create.content.contraptions.actors.psi.PSIInstance; +import com.simibubi.create.content.contraptions.actors.psi.PSIVisual; import com.simibubi.create.content.contraptions.actors.psi.PortableFluidInterfaceBlockEntity; import com.simibubi.create.content.contraptions.actors.psi.PortableItemInterfaceBlockEntity; import com.simibubi.create.content.contraptions.actors.psi.PortableStorageInterfaceRenderer; import com.simibubi.create.content.contraptions.actors.roller.RollerBlockEntity; import com.simibubi.create.content.contraptions.actors.roller.RollerRenderer; -import com.simibubi.create.content.contraptions.bearing.BearingInstance; import com.simibubi.create.content.contraptions.bearing.BearingRenderer; +import com.simibubi.create.content.contraptions.bearing.BearingVisual; import com.simibubi.create.content.contraptions.bearing.ClockworkBearingBlockEntity; import com.simibubi.create.content.contraptions.bearing.MechanicalBearingBlockEntity; import com.simibubi.create.content.contraptions.bearing.WindmillBearingBlockEntity; import com.simibubi.create.content.contraptions.chassis.ChassisBlockEntity; import com.simibubi.create.content.contraptions.chassis.StickerBlockEntity; -import com.simibubi.create.content.contraptions.chassis.StickerInstance; import com.simibubi.create.content.contraptions.chassis.StickerRenderer; +import com.simibubi.create.content.contraptions.chassis.StickerVisual; import com.simibubi.create.content.contraptions.elevator.ElevatorContactBlockEntity; import com.simibubi.create.content.contraptions.elevator.ElevatorPulleyBlockEntity; import com.simibubi.create.content.contraptions.elevator.ElevatorPulleyRenderer; import com.simibubi.create.content.contraptions.gantry.GantryCarriageBlockEntity; -import com.simibubi.create.content.contraptions.gantry.GantryCarriageInstance; import com.simibubi.create.content.contraptions.gantry.GantryCarriageRenderer; +import com.simibubi.create.content.contraptions.gantry.GantryCarriageVisual; import com.simibubi.create.content.contraptions.mounted.CartAssemblerBlockEntity; import com.simibubi.create.content.contraptions.piston.MechanicalPistonBlockEntity; import com.simibubi.create.content.contraptions.piston.MechanicalPistonRenderer; -import com.simibubi.create.content.contraptions.pulley.HosePulleyInstance; +import com.simibubi.create.content.contraptions.pulley.HosePulleyVisual; import com.simibubi.create.content.contraptions.pulley.PulleyBlockEntity; import com.simibubi.create.content.contraptions.pulley.PulleyRenderer; -import com.simibubi.create.content.contraptions.pulley.RopePulleyInstance; +import com.simibubi.create.content.contraptions.pulley.RopePulleyVisual; import com.simibubi.create.content.decoration.copycat.CopycatBlockEntity; import com.simibubi.create.content.decoration.placard.PlacardBlockEntity; import com.simibubi.create.content.decoration.placard.PlacardRenderer; @@ -43,13 +43,13 @@ import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorRenderer; import com.simibubi.create.content.decoration.steamWhistle.WhistleBlockEntity; import com.simibubi.create.content.decoration.steamWhistle.WhistleRenderer; import com.simibubi.create.content.equipment.armor.BacktankBlockEntity; -import com.simibubi.create.content.equipment.armor.BacktankInstance; import com.simibubi.create.content.equipment.armor.BacktankRenderer; +import com.simibubi.create.content.equipment.armor.BacktankVisual; import com.simibubi.create.content.equipment.bell.BellRenderer; import com.simibubi.create.content.equipment.bell.HauntedBellBlockEntity; import com.simibubi.create.content.equipment.bell.PeculiarBellBlockEntity; import com.simibubi.create.content.equipment.clipboard.ClipboardBlockEntity; -import com.simibubi.create.content.equipment.toolbox.ToolBoxInstance; +import com.simibubi.create.content.equipment.toolbox.ToolBoxVisual; import com.simibubi.create.content.equipment.toolbox.ToolboxBlockEntity; import com.simibubi.create.content.equipment.toolbox.ToolboxRenderer; import com.simibubi.create.content.fluids.drain.ItemDrainBlockEntity; @@ -61,99 +61,98 @@ import com.simibubi.create.content.fluids.pipes.SmartFluidPipeBlockEntity; import com.simibubi.create.content.fluids.pipes.StraightPipeBlockEntity; import com.simibubi.create.content.fluids.pipes.TransparentStraightPipeRenderer; import com.simibubi.create.content.fluids.pipes.valve.FluidValveBlockEntity; -import com.simibubi.create.content.fluids.pipes.valve.FluidValveInstance; import com.simibubi.create.content.fluids.pipes.valve.FluidValveRenderer; +import com.simibubi.create.content.fluids.pipes.valve.FluidValveVisual; import com.simibubi.create.content.fluids.pump.PumpBlockEntity; -import com.simibubi.create.content.fluids.pump.PumpCogInstance; +import com.simibubi.create.content.fluids.pump.PumpCogVisual; import com.simibubi.create.content.fluids.pump.PumpRenderer; import com.simibubi.create.content.fluids.spout.SpoutBlockEntity; import com.simibubi.create.content.fluids.spout.SpoutRenderer; import com.simibubi.create.content.fluids.tank.CreativeFluidTankBlockEntity; import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity; import com.simibubi.create.content.fluids.tank.FluidTankRenderer; -import com.simibubi.create.content.kinetics.base.CutoutRotatingInstance; -import com.simibubi.create.content.kinetics.base.HalfShaftInstance; -import com.simibubi.create.content.kinetics.base.HorizontalHalfShaftInstance; +import com.simibubi.create.content.kinetics.base.HalfShaftVisual; +import com.simibubi.create.content.kinetics.base.HorizontalHalfShaftVisual; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; -import com.simibubi.create.content.kinetics.base.ShaftInstance; import com.simibubi.create.content.kinetics.base.ShaftRenderer; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; +import com.simibubi.create.content.kinetics.base.ShaftVisual; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; import com.simibubi.create.content.kinetics.belt.BeltBlockEntity; -import com.simibubi.create.content.kinetics.belt.BeltInstance; import com.simibubi.create.content.kinetics.belt.BeltRenderer; +import com.simibubi.create.content.kinetics.belt.BeltVisual; import com.simibubi.create.content.kinetics.chainDrive.ChainGearshiftBlockEntity; import com.simibubi.create.content.kinetics.clock.CuckooClockBlockEntity; import com.simibubi.create.content.kinetics.clock.CuckooClockRenderer; import com.simibubi.create.content.kinetics.crafter.MechanicalCrafterBlockEntity; import com.simibubi.create.content.kinetics.crafter.MechanicalCrafterRenderer; -import com.simibubi.create.content.kinetics.crafter.ShaftlessCogwheelInstance; +import com.simibubi.create.content.kinetics.crafter.ShaftlessCogwheelVisual; import com.simibubi.create.content.kinetics.crank.HandCrankBlockEntity; -import com.simibubi.create.content.kinetics.crank.HandCrankInstance; import com.simibubi.create.content.kinetics.crank.HandCrankRenderer; +import com.simibubi.create.content.kinetics.crank.HandCrankVisual; import com.simibubi.create.content.kinetics.crank.ValveHandleBlockEntity; import com.simibubi.create.content.kinetics.crusher.CrushingWheelBlockEntity; import com.simibubi.create.content.kinetics.crusher.CrushingWheelControllerBlockEntity; import com.simibubi.create.content.kinetics.deployer.DeployerBlockEntity; -import com.simibubi.create.content.kinetics.deployer.DeployerInstance; import com.simibubi.create.content.kinetics.deployer.DeployerRenderer; +import com.simibubi.create.content.kinetics.deployer.DeployerVisual; import com.simibubi.create.content.kinetics.drill.DrillBlockEntity; -import com.simibubi.create.content.kinetics.drill.DrillInstance; import com.simibubi.create.content.kinetics.drill.DrillRenderer; +import com.simibubi.create.content.kinetics.drill.DrillVisual; import com.simibubi.create.content.kinetics.fan.EncasedFanBlockEntity; import com.simibubi.create.content.kinetics.fan.EncasedFanRenderer; -import com.simibubi.create.content.kinetics.fan.FanInstance; +import com.simibubi.create.content.kinetics.fan.FanVisual; import com.simibubi.create.content.kinetics.fan.NozzleBlockEntity; import com.simibubi.create.content.kinetics.flywheel.FlywheelBlockEntity; -import com.simibubi.create.content.kinetics.flywheel.FlywheelInstance; import com.simibubi.create.content.kinetics.flywheel.FlywheelRenderer; +import com.simibubi.create.content.kinetics.flywheel.FlywheelVisual; import com.simibubi.create.content.kinetics.gantry.GantryShaftBlockEntity; -import com.simibubi.create.content.kinetics.gauge.GaugeInstance; import com.simibubi.create.content.kinetics.gauge.GaugeRenderer; +import com.simibubi.create.content.kinetics.gauge.GaugeVisual; import com.simibubi.create.content.kinetics.gauge.SpeedGaugeBlockEntity; import com.simibubi.create.content.kinetics.gauge.StressGaugeBlockEntity; import com.simibubi.create.content.kinetics.gearbox.GearboxBlockEntity; -import com.simibubi.create.content.kinetics.gearbox.GearboxInstance; import com.simibubi.create.content.kinetics.gearbox.GearboxRenderer; +import com.simibubi.create.content.kinetics.gearbox.GearboxVisual; import com.simibubi.create.content.kinetics.mechanicalArm.ArmBlockEntity; -import com.simibubi.create.content.kinetics.mechanicalArm.ArmInstance; import com.simibubi.create.content.kinetics.mechanicalArm.ArmRenderer; +import com.simibubi.create.content.kinetics.mechanicalArm.ArmVisual; import com.simibubi.create.content.kinetics.millstone.MillstoneBlockEntity; -import com.simibubi.create.content.kinetics.millstone.MillstoneCogInstance; +import com.simibubi.create.content.kinetics.millstone.MillstoneCogVisual; import com.simibubi.create.content.kinetics.millstone.MillstoneRenderer; import com.simibubi.create.content.kinetics.mixer.MechanicalMixerBlockEntity; import com.simibubi.create.content.kinetics.mixer.MechanicalMixerRenderer; -import com.simibubi.create.content.kinetics.mixer.MixerInstance; +import com.simibubi.create.content.kinetics.mixer.MixerVisual; import com.simibubi.create.content.kinetics.motor.CreativeMotorBlockEntity; import com.simibubi.create.content.kinetics.motor.CreativeMotorRenderer; import com.simibubi.create.content.kinetics.press.MechanicalPressBlockEntity; import com.simibubi.create.content.kinetics.press.MechanicalPressRenderer; -import com.simibubi.create.content.kinetics.press.PressInstance; +import com.simibubi.create.content.kinetics.press.PressVisual; import com.simibubi.create.content.kinetics.saw.SawBlockEntity; -import com.simibubi.create.content.kinetics.saw.SawInstance; import com.simibubi.create.content.kinetics.saw.SawRenderer; +import com.simibubi.create.content.kinetics.saw.SawVisual; import com.simibubi.create.content.kinetics.simpleRelays.BracketedKineticBlockEntity; -import com.simibubi.create.content.kinetics.simpleRelays.BracketedKineticBlockEntityInstance; import com.simibubi.create.content.kinetics.simpleRelays.BracketedKineticBlockEntityRenderer; +import com.simibubi.create.content.kinetics.simpleRelays.BracketedKineticBlockEntityVisual; import com.simibubi.create.content.kinetics.simpleRelays.SimpleKineticBlockEntity; -import com.simibubi.create.content.kinetics.simpleRelays.encased.EncasedCogInstance; import com.simibubi.create.content.kinetics.simpleRelays.encased.EncasedCogRenderer; +import com.simibubi.create.content.kinetics.simpleRelays.encased.EncasedCogVisual; import com.simibubi.create.content.kinetics.speedController.SpeedControllerBlockEntity; import com.simibubi.create.content.kinetics.speedController.SpeedControllerRenderer; import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlockEntity; import com.simibubi.create.content.kinetics.steamEngine.SteamEngineBlockEntity; -import com.simibubi.create.content.kinetics.steamEngine.SteamEngineInstance; import com.simibubi.create.content.kinetics.steamEngine.SteamEngineRenderer; +import com.simibubi.create.content.kinetics.steamEngine.SteamEngineVisual; import com.simibubi.create.content.kinetics.transmission.ClutchBlockEntity; import com.simibubi.create.content.kinetics.transmission.GearshiftBlockEntity; -import com.simibubi.create.content.kinetics.transmission.SplitShaftInstance; import com.simibubi.create.content.kinetics.transmission.SplitShaftRenderer; +import com.simibubi.create.content.kinetics.transmission.SplitShaftVisual; import com.simibubi.create.content.kinetics.transmission.sequencer.SequencedGearshiftBlockEntity; import com.simibubi.create.content.kinetics.turntable.TurntableBlockEntity; import com.simibubi.create.content.kinetics.waterwheel.LargeWaterWheelBlockEntity; import com.simibubi.create.content.kinetics.waterwheel.WaterWheelBlockEntity; -import com.simibubi.create.content.kinetics.waterwheel.WaterWheelInstance; import com.simibubi.create.content.kinetics.waterwheel.WaterWheelRenderer; +import com.simibubi.create.content.kinetics.waterwheel.WaterWheelVisual; import com.simibubi.create.content.logistics.chute.ChuteBlockEntity; import com.simibubi.create.content.logistics.chute.ChuteRenderer; import com.simibubi.create.content.logistics.chute.SmartChuteBlockEntity; @@ -162,25 +161,26 @@ import com.simibubi.create.content.logistics.crate.CreativeCrateBlockEntity; import com.simibubi.create.content.logistics.depot.DepotBlockEntity; import com.simibubi.create.content.logistics.depot.DepotRenderer; import com.simibubi.create.content.logistics.depot.EjectorBlockEntity; -import com.simibubi.create.content.logistics.depot.EjectorInstance; import com.simibubi.create.content.logistics.depot.EjectorRenderer; +import com.simibubi.create.content.logistics.depot.EjectorVisual; import com.simibubi.create.content.logistics.funnel.FunnelBlockEntity; -import com.simibubi.create.content.logistics.funnel.FunnelInstance; import com.simibubi.create.content.logistics.funnel.FunnelRenderer; +import com.simibubi.create.content.logistics.funnel.FunnelVisual; import com.simibubi.create.content.logistics.tunnel.BeltTunnelBlockEntity; -import com.simibubi.create.content.logistics.tunnel.BeltTunnelInstance; import com.simibubi.create.content.logistics.tunnel.BeltTunnelRenderer; +import com.simibubi.create.content.logistics.tunnel.BeltTunnelVisual; import com.simibubi.create.content.logistics.tunnel.BrassTunnelBlockEntity; import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity; import com.simibubi.create.content.processing.basin.BasinBlockEntity; import com.simibubi.create.content.processing.basin.BasinRenderer; import com.simibubi.create.content.processing.burner.BlazeBurnerBlockEntity; import com.simibubi.create.content.processing.burner.BlazeBurnerRenderer; +import com.simibubi.create.content.processing.burner.BlazeBurnerVisual; import com.simibubi.create.content.redstone.analogLever.AnalogLeverBlockEntity; -import com.simibubi.create.content.redstone.analogLever.AnalogLeverInstance; import com.simibubi.create.content.redstone.analogLever.AnalogLeverRenderer; -import com.simibubi.create.content.redstone.diodes.BrassDiodeInstance; +import com.simibubi.create.content.redstone.analogLever.AnalogLeverVisual; import com.simibubi.create.content.redstone.diodes.BrassDiodeRenderer; +import com.simibubi.create.content.redstone.diodes.BrassDiodeVisual; import com.simibubi.create.content.redstone.diodes.PulseExtenderBlockEntity; import com.simibubi.create.content.redstone.diodes.PulseRepeaterBlockEntity; import com.simibubi.create.content.redstone.displayLink.DisplayLinkBlockEntity; @@ -195,8 +195,8 @@ import com.simibubi.create.content.redstone.nixieTube.NixieTubeRenderer; import com.simibubi.create.content.redstone.smartObserver.SmartObserverBlockEntity; import com.simibubi.create.content.redstone.thresholdSwitch.ThresholdSwitchBlockEntity; import com.simibubi.create.content.schematics.cannon.SchematicannonBlockEntity; -import com.simibubi.create.content.schematics.cannon.SchematicannonInstance; import com.simibubi.create.content.schematics.cannon.SchematicannonRenderer; +import com.simibubi.create.content.schematics.cannon.SchematicannonVisual; import com.simibubi.create.content.schematics.table.SchematicTableBlockEntity; import com.simibubi.create.content.trains.bogey.BogeyBlockEntityRenderer; import com.simibubi.create.content.trains.bogey.StandardBogeyBlockEntity; @@ -210,9 +210,9 @@ import com.simibubi.create.content.trains.station.StationBlockEntity; import com.simibubi.create.content.trains.station.StationRenderer; import com.simibubi.create.content.trains.track.FakeTrackBlockEntity; import com.simibubi.create.content.trains.track.TrackBlockEntity; -import com.simibubi.create.content.trains.track.TrackInstance; import com.simibubi.create.content.trains.track.TrackMaterial; import com.simibubi.create.content.trains.track.TrackRenderer; +import com.simibubi.create.content.trains.track.TrackVisual; import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRenderer; import com.tterrag.registrate.util.entry.BlockEntityEntry; @@ -221,7 +221,7 @@ public class AllBlockEntityTypes { // Schematics public static final BlockEntityEntry SCHEMATICANNON = REGISTRATE .blockEntity("schematicannon", SchematicannonBlockEntity::new) - .instance(() -> SchematicannonInstance::new) + .visual(() -> SchematicannonVisual::new) .validBlocks(AllBlocks.SCHEMATICANNON) .renderer(() -> SchematicannonRenderer::new) .register(); @@ -234,28 +234,28 @@ public class AllBlockEntityTypes { // Kinetics public static final BlockEntityEntry BRACKETED_KINETIC = REGISTRATE .blockEntity("simple_kinetic", BracketedKineticBlockEntity::new) - .instance(() -> BracketedKineticBlockEntityInstance::new, false) + .visual(() -> BracketedKineticBlockEntityVisual::new, false) .validBlocks(AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL) .renderer(() -> BracketedKineticBlockEntityRenderer::new) .register(); public static final BlockEntityEntry MOTOR = REGISTRATE .blockEntity("motor", CreativeMotorBlockEntity::new) - .instance(() -> HalfShaftInstance::new, false) + .visual(() -> HalfShaftVisual::new, false) .validBlocks(AllBlocks.CREATIVE_MOTOR) .renderer(() -> CreativeMotorRenderer::new) .register(); public static final BlockEntityEntry GEARBOX = REGISTRATE .blockEntity("gearbox", GearboxBlockEntity::new) - .instance(() -> GearboxInstance::new, false) + .visual(() -> GearboxVisual::new, false) .validBlocks(AllBlocks.GEARBOX) .renderer(() -> GearboxRenderer::new) .register(); public static final BlockEntityEntry ENCASED_SHAFT = REGISTRATE .blockEntity("encased_shaft", KineticBlockEntity::new) - .instance(() -> ShaftInstance::new, false) + .visual(() -> ShaftVisual::new, false) .validBlocks(AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT, AllBlocks.ENCASED_CHAIN_DRIVE, AllBlocks.METAL_GIRDER_ENCASED_SHAFT) .renderer(() -> ShaftRenderer::new) @@ -263,28 +263,28 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry ENCASED_COGWHEEL = REGISTRATE .blockEntity("encased_cogwheel", SimpleKineticBlockEntity::new) - .instance(() -> EncasedCogInstance::small, false) + .visual(() -> EncasedCogVisual::small, false) .validBlocks(AllBlocks.ANDESITE_ENCASED_COGWHEEL, AllBlocks.BRASS_ENCASED_COGWHEEL) .renderer(() -> EncasedCogRenderer::small) .register(); public static final BlockEntityEntry ENCASED_LARGE_COGWHEEL = REGISTRATE .blockEntity("encased_large_cogwheel", SimpleKineticBlockEntity::new) - .instance(() -> EncasedCogInstance::large, false) + .visual(() -> EncasedCogVisual::large, false) .validBlocks(AllBlocks.ANDESITE_ENCASED_LARGE_COGWHEEL, AllBlocks.BRASS_ENCASED_LARGE_COGWHEEL) .renderer(() -> EncasedCogRenderer::large) .register(); public static final BlockEntityEntry ADJUSTABLE_CHAIN_GEARSHIFT = REGISTRATE .blockEntity("adjustable_chain_gearshift", ChainGearshiftBlockEntity::new) - .instance(() -> ShaftInstance::new, false) + .visual(() -> ShaftVisual::new, false) .validBlocks(AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT) .renderer(() -> ShaftRenderer::new) .register(); public static final BlockEntityEntry ENCASED_FAN = REGISTRATE .blockEntity("encased_fan", EncasedFanBlockEntity::new) - .instance(() -> FanInstance::new, false) + .visual(() -> FanVisual::new, false) .validBlocks(AllBlocks.ENCASED_FAN) .renderer(() -> EncasedFanRenderer::new) .register(); @@ -297,35 +297,35 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry CLUTCH = REGISTRATE .blockEntity("clutch", ClutchBlockEntity::new) - .instance(() -> SplitShaftInstance::new, false) + .visual(() -> SplitShaftVisual::new, false) .validBlocks(AllBlocks.CLUTCH) .renderer(() -> SplitShaftRenderer::new) .register(); public static final BlockEntityEntry GEARSHIFT = REGISTRATE .blockEntity("gearshift", GearshiftBlockEntity::new) - .instance(() -> SplitShaftInstance::new, false) + .visual(() -> SplitShaftVisual::new, false) .validBlocks(AllBlocks.GEARSHIFT) .renderer(() -> SplitShaftRenderer::new) .register(); public static final BlockEntityEntry TURNTABLE = REGISTRATE .blockEntity("turntable", TurntableBlockEntity::new) - .instance(() -> SingleRotatingInstance::new, false) + .visual(() -> SingleRotatingVisual::new, false) .validBlocks(AllBlocks.TURNTABLE) .renderer(() -> KineticBlockEntityRenderer::new) .register(); public static final BlockEntityEntry HAND_CRANK = REGISTRATE .blockEntity("hand_crank", HandCrankBlockEntity::new) - .instance(() -> HandCrankInstance::new) + .visual(() -> HandCrankVisual::new) .validBlocks(AllBlocks.HAND_CRANK) .renderer(() -> HandCrankRenderer::new) .register(); - + public static final BlockEntityEntry VALVE_HANDLE = REGISTRATE .blockEntity("valve_handle", ValveHandleBlockEntity::new) - .instance(() -> HandCrankInstance::new) + .visual(() -> HandCrankVisual::new) .validBlocks(AllBlocks.COPPER_VALVE_HANDLE) .validBlocks(AllBlocks.DYED_VALVE_HANDLES.toArray()) .renderer(() -> HandCrankRenderer::new) @@ -333,28 +333,28 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry CUCKOO_CLOCK = REGISTRATE .blockEntity("cuckoo_clock", CuckooClockBlockEntity::new) - .instance(() -> HorizontalHalfShaftInstance::new) + .visual(() -> HorizontalHalfShaftVisual::new) .validBlocks(AllBlocks.CUCKOO_CLOCK, AllBlocks.MYSTERIOUS_CUCKOO_CLOCK) .renderer(() -> CuckooClockRenderer::new) .register(); public static final BlockEntityEntry GANTRY_SHAFT = REGISTRATE .blockEntity("gantry_shaft", GantryShaftBlockEntity::new) - .instance(() -> SingleRotatingInstance::new, false) + .visual(() -> SingleRotatingVisual::new, false) .validBlocks(AllBlocks.GANTRY_SHAFT) .renderer(() -> KineticBlockEntityRenderer::new) .register(); public static final BlockEntityEntry GANTRY_PINION = REGISTRATE .blockEntity("gantry_pinion", GantryCarriageBlockEntity::new) - .instance(() -> GantryCarriageInstance::new) + .visual(() -> GantryCarriageVisual::new) .validBlocks(AllBlocks.GANTRY_CARRIAGE) .renderer(() -> GantryCarriageRenderer::new) .register(); public static final BlockEntityEntry MECHANICAL_PUMP = REGISTRATE .blockEntity("mechanical_pump", PumpBlockEntity::new) - .instance(() -> PumpCogInstance::new) + .visual(() -> PumpCogVisual::new) .validBlocks(AllBlocks.MECHANICAL_PUMP) .renderer(() -> PumpRenderer::new) .register(); @@ -383,7 +383,7 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry FLUID_VALVE = REGISTRATE .blockEntity("fluid_valve", FluidValveBlockEntity::new) - .instance(() -> FluidValveInstance::new) + .visual(() -> FluidValveVisual::new) .validBlocks(AllBlocks.FLUID_VALVE) .renderer(() -> FluidValveRenderer::new) .register(); @@ -402,7 +402,7 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry HOSE_PULLEY = REGISTRATE .blockEntity("hose_pulley", HosePulleyBlockEntity::new) - .instance(() -> HosePulleyInstance::new) + .visual(() -> HosePulleyVisual::new) .validBlocks(AllBlocks.HOSE_PULLEY) .renderer(() -> HosePulleyRenderer::new) .register(); @@ -421,7 +421,7 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry BELT = REGISTRATE .blockEntity("belt", BeltBlockEntity::new) - .instance(() -> BeltInstance::new, BeltBlockEntity::shouldRenderNormally) + .visual(() -> BeltVisual::new, BeltBlockEntity::shouldRenderNormally) .validBlocks(AllBlocks.BELT) .renderer(() -> BeltRenderer::new) .register(); @@ -440,21 +440,21 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry ANDESITE_TUNNEL = REGISTRATE .blockEntity("andesite_tunnel", BeltTunnelBlockEntity::new) - .instance(() -> BeltTunnelInstance::new) + .visual(() -> BeltTunnelVisual::new) .validBlocks(AllBlocks.ANDESITE_TUNNEL) .renderer(() -> BeltTunnelRenderer::new) .register(); public static final BlockEntityEntry BRASS_TUNNEL = REGISTRATE .blockEntity("brass_tunnel", BrassTunnelBlockEntity::new) - .instance(() -> BeltTunnelInstance::new) + .visual(() -> BeltTunnelVisual::new) .validBlocks(AllBlocks.BRASS_TUNNEL) .renderer(() -> BeltTunnelRenderer::new) .register(); public static final BlockEntityEntry MECHANICAL_ARM = REGISTRATE .blockEntity("mechanical_arm", ArmBlockEntity::new) - .instance(() -> ArmInstance::new) + .visual(() -> ArmVisual::new) .validBlocks(AllBlocks.MECHANICAL_ARM) .renderer(() -> ArmRenderer::new) .register(); @@ -466,35 +466,35 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry MECHANICAL_PISTON = REGISTRATE .blockEntity("mechanical_piston", MechanicalPistonBlockEntity::new) - .instance(() -> ShaftInstance::new, false) + .visual(() -> ShaftVisual::new, false) .validBlocks(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON) .renderer(() -> MechanicalPistonRenderer::new) .register(); public static final BlockEntityEntry WINDMILL_BEARING = REGISTRATE .blockEntity("windmill_bearing", WindmillBearingBlockEntity::new) - .instance(() -> BearingInstance::new) + .visual(() -> BearingVisual::new) .validBlocks(AllBlocks.WINDMILL_BEARING) .renderer(() -> BearingRenderer::new) .register(); public static final BlockEntityEntry MECHANICAL_BEARING = REGISTRATE .blockEntity("mechanical_bearing", MechanicalBearingBlockEntity::new) - .instance(() -> BearingInstance::new) + .visual(() -> BearingVisual::new) .validBlocks(AllBlocks.MECHANICAL_BEARING) .renderer(() -> BearingRenderer::new) .register(); public static final BlockEntityEntry CLOCKWORK_BEARING = REGISTRATE .blockEntity("clockwork_bearing", ClockworkBearingBlockEntity::new) - .instance(() -> BearingInstance::new) + .visual(() -> BearingVisual::new) .validBlocks(AllBlocks.CLOCKWORK_BEARING) .renderer(() -> BearingRenderer::new) .register(); public static final BlockEntityEntry ROPE_PULLEY = REGISTRATE .blockEntity("rope_pulley", PulleyBlockEntity::new) - .instance(() -> RopePulleyInstance::new, false) + .visual(() -> RopePulleyVisual::new, false) .validBlocks(AllBlocks.ROPE_PULLEY) .renderer(() -> PulleyRenderer::new) .register(); @@ -519,7 +519,7 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry STICKER = REGISTRATE .blockEntity("sticker", StickerBlockEntity::new) - .instance(() -> StickerInstance::new, false) + .visual(() -> StickerVisual::new, false) .validBlocks(AllBlocks.STICKER) .renderer(() -> StickerRenderer::new) .register(); @@ -532,14 +532,14 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry DRILL = REGISTRATE .blockEntity("drill", DrillBlockEntity::new) - .instance(() -> DrillInstance::new, false) + .visual(() -> DrillVisual::new, false) .validBlocks(AllBlocks.MECHANICAL_DRILL) .renderer(() -> DrillRenderer::new) .register(); public static final BlockEntityEntry SAW = REGISTRATE .blockEntity("saw", SawBlockEntity::new) - .instance(() -> SawInstance::new) + .visual(() -> SawVisual::new) .validBlocks(AllBlocks.MECHANICAL_SAW) .renderer(() -> SawRenderer::new) .register(); @@ -559,7 +559,7 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry PORTABLE_STORAGE_INTERFACE = REGISTRATE .blockEntity("portable_storage_interface", PortableItemInterfaceBlockEntity::new) - .instance(() -> PSIInstance::new) + .visual(() -> PSIVisual::new) .validBlocks(AllBlocks.PORTABLE_STORAGE_INTERFACE) .renderer(() -> PortableStorageInterfaceRenderer::new) .register(); @@ -567,14 +567,14 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry PORTABLE_FLUID_INTERFACE = REGISTRATE .blockEntity("portable_fluid_interface", PortableFluidInterfaceBlockEntity::new) - .instance(() -> PSIInstance::new) + .visual(() -> PSIVisual::new) .validBlocks(AllBlocks.PORTABLE_FLUID_INTERFACE) .renderer(() -> PortableStorageInterfaceRenderer::new) .register(); public static final BlockEntityEntry STEAM_ENGINE = REGISTRATE .blockEntity("steam_engine", SteamEngineBlockEntity::new) - .instance(() -> SteamEngineInstance::new, false) + .visual(() -> SteamEngineVisual::new, false) .validBlocks(AllBlocks.STEAM_ENGINE) .renderer(() -> SteamEngineRenderer::new) .register(); @@ -587,28 +587,28 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry POWERED_SHAFT = REGISTRATE .blockEntity("powered_shaft", PoweredShaftBlockEntity::new) - .instance(() -> SingleRotatingInstance::new, false) + .visual(() -> SingleRotatingVisual::new, false) .validBlocks(AllBlocks.POWERED_SHAFT) .renderer(() -> KineticBlockEntityRenderer::new) .register(); public static final BlockEntityEntry FLYWHEEL = REGISTRATE .blockEntity("flywheel", FlywheelBlockEntity::new) - .instance(() -> FlywheelInstance::new, false) + .visual(() -> FlywheelVisual::new, false) .validBlocks(AllBlocks.FLYWHEEL) .renderer(() -> FlywheelRenderer::new) .register(); public static final BlockEntityEntry MILLSTONE = REGISTRATE .blockEntity("millstone", MillstoneBlockEntity::new) - .instance(() -> MillstoneCogInstance::new, false) + .visual(() -> MillstoneCogVisual::new, false) .validBlocks(AllBlocks.MILLSTONE) .renderer(() -> MillstoneRenderer::new) .register(); public static final BlockEntityEntry CRUSHING_WHEEL = REGISTRATE .blockEntity("crushing_wheel", CrushingWheelBlockEntity::new) - .instance(() -> CutoutRotatingInstance::new, false) + .visual(() -> SingleRotatingVisual::new, false) .validBlocks(AllBlocks.CRUSHING_WHEEL) .renderer(() -> KineticBlockEntityRenderer::new) .register(); @@ -622,35 +622,35 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry WATER_WHEEL = REGISTRATE .blockEntity("water_wheel", WaterWheelBlockEntity::new) - .instance(() -> WaterWheelInstance::standard, false) + .visual(() -> WaterWheelVisual::standard, false) .validBlocks(AllBlocks.WATER_WHEEL) .renderer(() -> WaterWheelRenderer::standard) .register(); public static final BlockEntityEntry LARGE_WATER_WHEEL = REGISTRATE .blockEntity("large_water_wheel", LargeWaterWheelBlockEntity::new) - .instance(() -> WaterWheelInstance::large, false) + .visual(() -> WaterWheelVisual::large, false) .validBlocks(AllBlocks.LARGE_WATER_WHEEL) .renderer(() -> WaterWheelRenderer::large) .register(); public static final BlockEntityEntry MECHANICAL_PRESS = REGISTRATE .blockEntity("mechanical_press", MechanicalPressBlockEntity::new) - .instance(() -> PressInstance::new) + .visual(() -> PressVisual::new) .validBlocks(AllBlocks.MECHANICAL_PRESS) .renderer(() -> MechanicalPressRenderer::new) .register(); public static final BlockEntityEntry MECHANICAL_MIXER = REGISTRATE .blockEntity("mechanical_mixer", MechanicalMixerBlockEntity::new) - .instance(() -> MixerInstance::new) + .visual(() -> MixerVisual::new) .validBlocks(AllBlocks.MECHANICAL_MIXER) .renderer(() -> MechanicalMixerRenderer::new) .register(); public static final BlockEntityEntry DEPLOYER = REGISTRATE .blockEntity("deployer", DeployerBlockEntity::new) - .instance(() -> DeployerInstance::new) + .visual(() -> DeployerVisual::new) .validBlocks(AllBlocks.DEPLOYER) .renderer(() -> DeployerRenderer::new) .register(); @@ -663,52 +663,53 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry HEATER = REGISTRATE .blockEntity("blaze_heater", BlazeBurnerBlockEntity::new) + .visual(() -> BlazeBurnerVisual::new, false) .validBlocks(AllBlocks.BLAZE_BURNER) .renderer(() -> BlazeBurnerRenderer::new) .register(); public static final BlockEntityEntry MECHANICAL_CRAFTER = REGISTRATE .blockEntity("mechanical_crafter", MechanicalCrafterBlockEntity::new) - .instance(() -> ShaftlessCogwheelInstance::new) + .visual(() -> ShaftlessCogwheelVisual::new) .validBlocks(AllBlocks.MECHANICAL_CRAFTER) .renderer(() -> MechanicalCrafterRenderer::new) .register(); public static final BlockEntityEntry SEQUENCED_GEARSHIFT = REGISTRATE .blockEntity("sequenced_gearshift", SequencedGearshiftBlockEntity::new) - .instance(() -> SplitShaftInstance::new, false) + .visual(() -> SplitShaftVisual::new, false) .validBlocks(AllBlocks.SEQUENCED_GEARSHIFT) .renderer(() -> SplitShaftRenderer::new) .register(); public static final BlockEntityEntry ROTATION_SPEED_CONTROLLER = REGISTRATE .blockEntity("rotation_speed_controller", SpeedControllerBlockEntity::new) - .instance(() -> ShaftInstance::new) + .visual(() -> ShaftVisual::new) .validBlocks(AllBlocks.ROTATION_SPEED_CONTROLLER) .renderer(() -> SpeedControllerRenderer::new) .register(); public static final BlockEntityEntry SPEEDOMETER = REGISTRATE .blockEntity("speedometer", SpeedGaugeBlockEntity::new) - .instance(() -> GaugeInstance.Speed::new) + .visual(() -> GaugeVisual.Speed::new) .validBlocks(AllBlocks.SPEEDOMETER) .renderer(() -> GaugeRenderer::speed) .register(); public static final BlockEntityEntry STRESSOMETER = REGISTRATE .blockEntity("stressometer", StressGaugeBlockEntity::new) - .instance(() -> GaugeInstance.Stress::new) + .visual(() -> GaugeVisual.Stress::new) .validBlocks(AllBlocks.STRESSOMETER) .renderer(() -> GaugeRenderer::stress) .register(); public static final BlockEntityEntry ANALOG_LEVER = REGISTRATE .blockEntity("analog_lever", AnalogLeverBlockEntity::new) - .instance(() -> AnalogLeverInstance::new, false) + .visual(() -> AnalogLeverVisual::new, false) .validBlocks(AllBlocks.ANALOG_LEVER) .renderer(() -> AnalogLeverRenderer::new) .register(); - + public static final BlockEntityEntry PLACARD = REGISTRATE .blockEntity("placard", PlacardBlockEntity::new) .validBlocks(AllBlocks.PLACARD) @@ -763,14 +764,14 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry WEIGHTED_EJECTOR = REGISTRATE .blockEntity("weighted_ejector", EjectorBlockEntity::new) - .instance(() -> EjectorInstance::new) + .visual(() -> EjectorVisual::new) .validBlocks(AllBlocks.WEIGHTED_EJECTOR) .renderer(() -> EjectorRenderer::new) .register(); public static final BlockEntityEntry FUNNEL = REGISTRATE .blockEntity("funnel", FunnelBlockEntity::new) - .instance(() -> FunnelInstance::new) + .visual(() -> FunnelVisual::new) .validBlocks(AllBlocks.BRASS_FUNNEL, AllBlocks.BRASS_BELT_FUNNEL, AllBlocks.ANDESITE_FUNNEL, AllBlocks.ANDESITE_BELT_FUNNEL) .renderer(() -> FunnelRenderer::new) @@ -784,14 +785,14 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry PULSE_EXTENDER = REGISTRATE .blockEntity("pulse_extender", PulseExtenderBlockEntity::new) - .instance(() -> BrassDiodeInstance::new, false) + .visual(() -> BrassDiodeVisual::new, false) .validBlocks(AllBlocks.PULSE_EXTENDER) .renderer(() -> BrassDiodeRenderer::new) .register(); public static final BlockEntityEntry PULSE_REPEATER = REGISTRATE .blockEntity("pulse_repeater", PulseRepeaterBlockEntity::new) - .instance(() -> BrassDiodeInstance::new, false) + .visual(() -> BrassDiodeVisual::new, false) .validBlocks(AllBlocks.PULSE_REPEATER) .renderer(() -> BrassDiodeRenderer::new) .register(); @@ -805,7 +806,7 @@ public class AllBlockEntityTypes { // Curiosities public static final BlockEntityEntry BACKTANK = REGISTRATE .blockEntity("backtank", BacktankBlockEntity::new) - .instance(() -> BacktankInstance::new) + .visual(() -> BacktankVisual::new) .validBlocks(AllBlocks.COPPER_BACKTANK, AllBlocks.NETHERITE_BACKTANK) .renderer(() -> BacktankRenderer::new) .register(); @@ -824,18 +825,18 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry TOOLBOX = REGISTRATE .blockEntity("toolbox", ToolboxBlockEntity::new) - .instance(() -> ToolBoxInstance::new, false) + .visual(() -> ToolBoxVisual::new, false) .validBlocks(AllBlocks.TOOLBOXES.toArray()) .renderer(() -> ToolboxRenderer::new) .register(); public static final BlockEntityEntry TRACK = REGISTRATE .blockEntity("track", TrackBlockEntity::new) - .instance(() -> TrackInstance::new) + .visual(() -> TrackVisual::new) .validBlocksDeferred(TrackMaterial::allBlocks) .renderer(() -> TrackRenderer::new) .register(); - + public static final BlockEntityEntry FAKE_TRACK = REGISTRATE .blockEntity("fake_track", FakeTrackBlockEntity::new) .validBlocks(AllBlocks.FAKE_TRACK) @@ -867,7 +868,7 @@ public class AllBlockEntityTypes { public static final BlockEntityEntry FLAP_DISPLAY = REGISTRATE .blockEntity("flap_display", FlapDisplayBlockEntity::new) - .instance(() -> ShaftlessCogwheelInstance::new) + .visual(() -> ShaftlessCogwheelVisual::new) .renderer(() -> FlapDisplayRenderer::new) .validBlocks(AllBlocks.DISPLAY_BOARD) .register(); @@ -883,7 +884,7 @@ public class AllBlockEntityTypes { .renderer(() -> TrackObserverRenderer::new) .validBlocks(AllBlocks.TRACK_OBSERVER) .register(); - + public static final BlockEntityEntry CLIPBOARD = REGISTRATE .blockEntity("clipboard", ClipboardBlockEntity::new) .validBlocks(AllBlocks.CLIPBOARD) diff --git a/src/main/java/com/simibubi/create/AllEntityTypes.java b/src/main/java/com/simibubi/create/AllEntityTypes.java index 5d6b70220b..2b21ec3f38 100644 --- a/src/main/java/com/simibubi/create/AllEntityTypes.java +++ b/src/main/java/com/simibubi/create/AllEntityTypes.java @@ -8,6 +8,7 @@ import com.simibubi.create.content.contraptions.gantry.GantryContraptionEntity; import com.simibubi.create.content.contraptions.glue.SuperGlueEntity; import com.simibubi.create.content.contraptions.glue.SuperGlueRenderer; import com.simibubi.create.content.contraptions.render.ContraptionEntityRenderer; +import com.simibubi.create.content.contraptions.render.ContraptionVisual; import com.simibubi.create.content.contraptions.render.OrientedContraptionEntityRenderer; import com.simibubi.create.content.equipment.blueprint.BlueprintEntity; import com.simibubi.create.content.equipment.blueprint.BlueprintRenderer; @@ -15,7 +16,7 @@ import com.simibubi.create.content.equipment.potatoCannon.PotatoProjectileEntity import com.simibubi.create.content.equipment.potatoCannon.PotatoProjectileRenderer; import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; import com.simibubi.create.content.trains.entity.CarriageContraptionEntityRenderer; -import com.simibubi.create.content.trains.entity.CarriageContraptionInstance; +import com.simibubi.create.content.trains.entity.CarriageContraptionVisual; import com.simibubi.create.foundation.data.CreateEntityBuilder; import com.simibubi.create.foundation.utility.Lang; import com.tterrag.registrate.util.entry.EntityEntry; @@ -33,15 +34,22 @@ import net.minecraft.world.entity.MobCategory; public class AllEntityTypes { public static final EntityEntry ORIENTED_CONTRAPTION = contraption("contraption", - OrientedContraptionEntity::new, () -> OrientedContraptionEntityRenderer::new, 5, 3, true).register(); + OrientedContraptionEntity::new, () -> OrientedContraptionEntityRenderer::new, 5, 3, true) + .visual(() -> ContraptionVisual::new) + .register(); public static final EntityEntry CONTROLLED_CONTRAPTION = contraption("stationary_contraption", ControlledContraptionEntity::new, () -> ContraptionEntityRenderer::new, - 20, 40, false).register(); + 20, 40, false) + .visual(() -> ContraptionVisual::new) + .register(); public static final EntityEntry GANTRY_CONTRAPTION = contraption("gantry_contraption", - GantryContraptionEntity::new, () -> ContraptionEntityRenderer::new, 10, 40, false).register(); + GantryContraptionEntity::new, () -> ContraptionEntityRenderer::new, 10, 40, false) + .visual(() -> ContraptionVisual::new) + .register(); public static final EntityEntry CARRIAGE_CONTRAPTION = contraption("carriage_contraption", CarriageContraptionEntity::new, - () -> CarriageContraptionEntityRenderer::new, 15, 3, true).instance(() -> CarriageContraptionInstance::new) + () -> CarriageContraptionEntityRenderer::new, 15, 3, true) + .visual(() -> CarriageContraptionVisual::new) .register(); public static final EntityEntry SUPER_GLUE = diff --git a/src/main/java/com/simibubi/create/AllPartialModels.java b/src/main/java/com/simibubi/create/AllPartialModels.java index 8fde351369..9a5b37c76f 100644 --- a/src/main/java/com/simibubi/create/AllPartialModels.java +++ b/src/main/java/com/simibubi/create/AllPartialModels.java @@ -6,12 +6,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.content.fluids.FluidTransportBehaviour; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.DyeColor; @@ -58,7 +58,7 @@ public class AllPartialModels { ANALOG_LEVER_INDICATOR = block("analog_lever/indicator"), FUNNEL_FLAP = block("funnel/flap"), BELT_FUNNEL_FLAP = block("belt_funnel/flap"), BELT_TUNNEL_FLAP = block("belt_tunnel/flap"), FLEXPEATER_INDICATOR = block("diodes/indicator"), - + ROLLER_WHEEL = block("mechanical_roller/wheel"), ROLLER_FRAME = block("mechanical_roller/frame"), @@ -67,7 +67,7 @@ public class AllPartialModels { CUCKOO_PIG = block("cuckoo_clock/pig"), CUCKOO_CREEPER = block("cuckoo_clock/creeper"), GANTRY_COGS = block("gantry_carriage/wheels"), - + ROPE_COIL = block("rope_pulley/rope_coil"), ROPE_HALF = block("rope_pulley/rope_half"), ROPE_HALF_MAGNET = block("rope_pulley/rope_half_magnet"), @@ -208,7 +208,7 @@ public class AllPartialModels { METAL_GIRDER_BRACKETS.put(d, block("metal_girder/bracket_" + Lang.asId(d.name()))); for (int i = 0; i < 8; i++) CONTRAPTION_CONTROLS_INDICATOR.add(block("contraption_controls/indicator_" + i)); - + putFoldingDoor("andesite_door"); putFoldingDoor("copper_door"); } @@ -219,11 +219,11 @@ public class AllPartialModels { } private static PartialModel block(String path) { - return new PartialModel(Create.asResource("block/" + path)); + return PartialModel.of(Create.asResource("block/" + path)); } private static PartialModel entity(String path) { - return new PartialModel(Create.asResource("entity/" + path)); + return PartialModel.of(Create.asResource("entity/" + path)); } public static void init() { diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 0b2fe21be7..5763dec8dd 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -1,8 +1,8 @@ package com.simibubi.create; import com.simibubi.create.content.contraptions.glue.SuperGlueSelectionHandler; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; -import com.simibubi.create.content.contraptions.render.SBBContraptionManager; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfoManager; import com.simibubi.create.content.decoration.encasing.CasingConnectivity; import com.simibubi.create.content.equipment.bell.SoulPulseEffectHandler; import com.simibubi.create.content.equipment.potatoCannon.PotatoCannonRenderHandler; @@ -18,8 +18,9 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsClient; import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.outliner.Outliner; import com.simibubi.create.foundation.ponder.element.WorldSectionElement; +import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.CreateContexts; +import com.simibubi.create.foundation.render.StitchedSprite; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.Components; import com.simibubi.create.foundation.utility.ModelSwapper; @@ -62,8 +63,10 @@ public class CreateClient { public static void onCtorClient(IEventBus modEventBus, IEventBus forgeEventBus) { modEventBus.addListener(CreateClient::clientInit); modEventBus.addListener(AllParticleTypes::registerFactories); - modEventBus.addListener(CreateContexts::flwInit); - modEventBus.addListener(ContraptionRenderDispatcher::gatherContext); + + modEventBus.addListener(StitchedSprite::onTextureStitchPost); + + AllInstanceTypes.init(); MODEL_SWAPPER.registerListeners(modEventBus); @@ -77,7 +80,7 @@ public class CreateClient { BUFFER_CACHE.registerCompartment(CachedBufferer.DIRECTIONAL_PARTIAL); BUFFER_CACHE.registerCompartment(KineticBlockEntityRenderer.KINETIC_BLOCK); BUFFER_CACHE.registerCompartment(WaterWheelRenderer.WATER_WHEEL); - BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20); + BUFFER_CACHE.registerCompartment(ContraptionRenderInfo.CONTRAPTION, 20); BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); AllPartialModels.init(); @@ -92,7 +95,7 @@ public class CreateClient { BUFFER_CACHE.invalidate(); SCHEMATIC_HANDLER.updateRenderers(); - ContraptionRenderDispatcher.reset(); + ContraptionRenderInfoManager.resetAll(); } public static void checkGraphicsFanciness() { diff --git a/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java b/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java index 0424ccf85c..96668a0080 100644 --- a/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java +++ b/src/main/java/com/simibubi/create/compat/jei/GhostIngredientHandler.java @@ -29,20 +29,20 @@ public class GhostIngredientHandler> boolean doStart) { boolean isAttributeFilter = gui instanceof AttributeFilterScreen; List> targets = new LinkedList<>(); - + if (ingredient.getType() == VanillaTypes.ITEM_STACK) { for (int i = 36; i < gui.getMenu().slots.size(); i++) { if (gui.getMenu().slots.get(i) .isActive()) targets.add(new GhostTarget<>(gui, i - 36, isAttributeFilter)); - + // Only accept items in 1st slot. 2nd is used for functionality, don't wanna // override that one if (isAttributeFilter) break; } } - + return targets; } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java index f25074fe48..c71ed7271f 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java @@ -1,8 +1,6 @@ package com.simibubi.create.compat.jei.category.animations; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; @@ -12,10 +10,10 @@ import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.util.Mth; import net.minecraft.world.level.block.Blocks; @@ -84,14 +82,10 @@ public class AnimatedBlazeBurner extends AnimatedKinetics { uScroll = uScroll - Math.floor(uScroll); uScroll = uScroll * spriteWidth / 2; - Minecraft mc = Minecraft.getInstance(); - MultiBufferSource.BufferSource buffer = mc.renderBuffers() - .bufferSource(); - VertexConsumer vb = buffer.getBuffer(RenderType.cutoutMipped()); CachedBufferer.partial(AllPartialModels.BLAZE_BURNER_FLAME, Blocks.AIR.defaultBlockState()) - .shiftUVScrolling(spriteShift, (float) uScroll, (float) vScroll) - .light(LightTexture.FULL_BRIGHT) - .renderInto(matrixStack, vb); + .shiftUVScrolling(spriteShift, (float) uScroll, (float) vScroll) + .light(LightTexture.FULL_BRIGHT) + .renderInto(matrixStack, graphics.bufferSource().getBuffer(RenderType.cutoutMipped())); matrixStack.popPose(); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java index 9fbf5186db..c969e4efc3 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java @@ -1,10 +1,10 @@ package com.simibubi.create.compat.jei.category.animations; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.gui.AllGuiTextures; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.gui.GuiGraphics; public class AnimatedCrafter extends AnimatedKinetics { @@ -17,9 +17,9 @@ public class AnimatedCrafter extends AnimatedKinetics { AllGuiTextures.JEI_SHADOW.render(graphics, -16, 13); matrixStack.translate(3, 16, 0); - TransformStack.cast(matrixStack) - .rotateX(-12.5f) - .rotateY(-22.5f); + TransformStack.of(matrixStack) + .rotateXDegrees(-12.5f) + .rotateYDegrees(-22.5f); int scale = 22; blockElement(cogwheel()) diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java index 3b7d9ce1dc..16cde6f09c 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java @@ -1,6 +1,5 @@ package com.simibubi.create.compat.jei.category.animations; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.gui.CustomLightingSettings; @@ -8,13 +7,14 @@ import com.simibubi.create.foundation.gui.ILightingSettings; import com.simibubi.create.foundation.gui.element.GuiGameElement; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import mezz.jei.api.gui.drawable.IDrawable; import net.minecraft.core.Direction.Axis; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; public abstract class AnimatedKinetics implements IDrawable { - + public int offset = 0; public static final ILightingSettings DEFAULT_LIGHTING = CustomLightingSettings.builder() diff --git a/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java index 83c8900048..f8e3caf9f0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java @@ -28,7 +28,7 @@ import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.elevator.ElevatorContraption; import com.simibubi.create.content.contraptions.glue.SuperGlueEntity; import com.simibubi.create.content.contraptions.mounted.MountedContraption; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; import com.simibubi.create.content.contraptions.sync.ContraptionSeatMappingPacket; import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorBlock; import com.simibubi.create.content.trains.entity.CarriageContraption; @@ -383,7 +383,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit if (!contraption.deferInvalidate) return; contraption.deferInvalidate = false; - ContraptionRenderDispatcher.invalidate(contraption); + ContraptionRenderInfo.invalidate(contraption); }); if (!(level() instanceof ServerLevelAccessor sl)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java index 1370881763..01545f4bd1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java @@ -18,6 +18,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; +import java.util.function.Function; import javax.annotation.Nullable; @@ -55,8 +56,6 @@ import com.simibubi.create.content.contraptions.pulley.PulleyBlock; import com.simibubi.create.content.contraptions.pulley.PulleyBlock.MagnetBlock; import com.simibubi.create.content.contraptions.pulley.PulleyBlock.RopeBlock; import com.simibubi.create.content.contraptions.pulley.PulleyBlockEntity; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; -import com.simibubi.create.content.contraptions.render.EmptyLighter; import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorBlock; import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; import com.simibubi.create.content.kinetics.base.IRotate; @@ -121,8 +120,6 @@ import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -162,8 +159,7 @@ public abstract class Contraption { // Client public Map modelData; public Map presentBlockEntities; - public List maybeInstancedBlockEntities; - public List specialRenderedBlockEntities; + public List renderedBlockEntities; protected ContraptionWorld world; public boolean deferInvalidate; @@ -180,8 +176,7 @@ public abstract class Contraption { glueToRemove = new HashSet<>(); initialPassengers = new HashMap<>(); presentBlockEntities = new HashMap<>(); - maybeInstancedBlockEntities = new ArrayList<>(); - specialRenderedBlockEntities = new ArrayList<>(); + renderedBlockEntities = new ArrayList<>(); pendingSubContraptions = new ArrayList<>(); stabilizedSubContraptions = new HashMap<>(); simplifiedEntityColliders = Optional.empty(); @@ -709,7 +704,7 @@ public abstract class Contraption { public void readNBT(Level world, CompoundTag nbt, boolean spawnData) { blocks.clear(); presentBlockEntities.clear(); - specialRenderedBlockEntities.clear(); + renderedBlockEntities.clear(); Tag blocks = nbt.get("Blocks"); // used to differentiate between the 'old' and the paletted serialization @@ -942,20 +937,17 @@ public abstract class Contraption { if (be == null) return; be.setLevel(world); - modelData.put(info.pos(), be.getModelData()); if (be instanceof KineticBlockEntity kbe) kbe.setSpeed(0); be.getBlockState(); - MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(info.state()); - if (movementBehaviour == null || !movementBehaviour.hasSpecialInstancedRendering()) - maybeInstancedBlockEntities.add(be); - - if (movementBehaviour != null && !movementBehaviour.renderAsNormalBlockEntity()) - return; - presentBlockEntities.put(info.pos(), be); - specialRenderedBlockEntities.add(be); + modelData.put(info.pos(), be.getModelData()); + + MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(info.state()); + if (movementBehaviour == null || !movementBehaviour.disableBlockEntityRendering()) { + renderedBlockEntities.add(be); + } }); } @@ -1385,12 +1377,6 @@ public abstract class Contraption { return interactors; } - @OnlyIn(Dist.CLIENT) - public ContraptionLighter makeLighter() { - // TODO: move lighters to registry - return new EmptyLighter(this); - } - public void invalidateColliders() { simplifiedEntityColliders = Optional.empty(); gatherBBsOffThread(); @@ -1458,12 +1444,18 @@ public abstract class Contraption { return storage.getFluids(); } - public Collection getRenderedBlocks() { - return blocks.values(); + public RenderedBlocks getRenderedBlocks() { + return new RenderedBlocks(pos -> { + StructureBlockInfo info = blocks.get(pos); + if (info == null) { + return Blocks.AIR.defaultBlockState(); + } + return info.state(); + }, blocks.keySet()); } - public Collection getSpecialRenderedBEs() { - return specialRenderedBlockEntities; + public Collection getRenderedBEs() { + return renderedBlockEntities; } public boolean isHiddenInPortal(BlockPos localPos) { @@ -1511,4 +1503,7 @@ public abstract class Contraption { return false; } + public record RenderedBlocks(Function lookup, Iterable positions) { + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/ControlledContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/ControlledContraptionEntity.java index 6ce543d157..79f0b07497 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/ControlledContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/ControlledContraptionEntity.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions; import static com.simibubi.create.foundation.utility.AngleHelper.angleLerp; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllEntityTypes; import com.simibubi.create.content.contraptions.bearing.BearingContraption; @@ -11,6 +10,7 @@ import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -51,7 +51,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { entity.setContraption(contraption); return entity; } - + @Override public void setPos(double x, double y, double z) { super.setPos(x, y, z); @@ -246,10 +246,12 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { float angle = getAngle(partialTicks); Axis axis = getRotationAxis(); - TransformStack.cast(matrixStack) - .nudge(getId()) - .centre() - .rotate(angle, axis) - .unCentre(); + if (axis != null) { + TransformStack.of(matrixStack) + .nudge(getId()) + .center() + .rotateDegrees(angle, axis) + .uncenter(); + } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/DirectionalExtenderScrollOptionSlot.java b/src/main/java/com/simibubi/create/content/contraptions/DirectionalExtenderScrollOptionSlot.java index 27b58da19e..5b19e632ad 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/DirectionalExtenderScrollOptionSlot.java +++ b/src/main/java/com/simibubi/create/content/contraptions/DirectionalExtenderScrollOptionSlot.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.contraptions; import java.util.function.BiPredicate; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.CenteredSideValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -27,8 +27,8 @@ public class DirectionalExtenderScrollOptionSlot extends CenteredSideValueBoxTra @Override public void rotate(BlockState state, PoseStack ms) { if (!getSide().getAxis().isHorizontal()) - TransformStack.cast(ms) - .rotateY(AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.FACING)) + 180); + TransformStack.of(ms) + .rotateYDegrees(AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.FACING)) + 180); super.rotate(state, ms); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java index 98db27e530..736f5e1863 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java @@ -8,7 +8,6 @@ import java.util.UUID; import javax.annotation.Nullable; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllEntityTypes; import com.simibubi.create.content.contraptions.bearing.StabilizedContraption; @@ -23,6 +22,7 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -539,13 +539,13 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { repositionOnContraption(matrixStack, partialTicks, ridingEntity); } - TransformStack.cast(matrixStack) + TransformStack.of(matrixStack) .nudge(getId()) - .centre() - .rotateY(angleYaw) - .rotateZ(anglePitch) - .rotateY(angleInitialYaw) - .unCentre(); + .center() + .rotateYDegrees(angleYaw) + .rotateZDegrees(anglePitch) + .rotateYDegrees(angleInitialYaw) + .uncenter(); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/ActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/actors/ActorInstance.java new file mode 100644 index 0000000000..5d1b1ddfb6 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/ActorInstance.java @@ -0,0 +1,88 @@ +package com.simibubi.create.content.contraptions.actors; + +import org.joml.Quaternionf; +import org.joml.Quaternionfc; +import org.joml.Vector3f; + +import dev.engine_room.flywheel.api.instance.InstanceHandle; +import dev.engine_room.flywheel.api.instance.InstanceType; +import dev.engine_room.flywheel.lib.instance.AbstractInstance; +import net.minecraft.core.BlockPos; + +public class ActorInstance extends AbstractInstance { + public float x; + public float y; + public float z; + public byte blockLight; + public byte skyLight; + public float rotationOffset; + public byte rotationAxisX; + public byte rotationAxisY; + public byte rotationAxisZ; + public Quaternionf rotation = new Quaternionf(); + public byte rotationCenterX = 64; + public byte rotationCenterY = 64; + public byte rotationCenterZ = 64; + public float speed; + + public ActorInstance(InstanceType type, InstanceHandle handle) { + super(type, handle); + } + + public ActorInstance setPosition(BlockPos pos) { + this.x = pos.getX(); + this.y = pos.getY(); + this.z = pos.getZ(); + return this; + } + + public ActorInstance setBlockLight(int blockLight) { + this.blockLight = (byte) blockLight; + return this; + } + + public ActorInstance setSkyLight(int skyLight) { + this.skyLight = (byte) skyLight; + return this; + } + + public ActorInstance setRotationOffset(float rotationOffset) { + this.rotationOffset = rotationOffset; + return this; + } + + public ActorInstance setSpeed(float speed) { + this.speed = speed; + return this; + } + + public ActorInstance setRotationAxis(Vector3f axis) { + setRotationAxis(axis.x(), axis.y(), axis.z()); + return this; + } + + public ActorInstance 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 ActorInstance setRotationCenter(Vector3f axis) { + setRotationCenter(axis.x(), axis.y(), axis.z()); + return this; + } + + public ActorInstance 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 ActorInstance setLocalRotation(Quaternionfc q) { + this.rotation.set(q); + return this; + } + +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsBlockEntity.java b/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsBlockEntity.java index bcfca357b8..6b9c2d0c97 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsBlockEntity.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.actors.contraptionControls; import java.util.List; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.content.contraptions.actors.trainControls.ControlsBlock; @@ -17,6 +16,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -135,9 +135,9 @@ public class ContraptionControlsBlockEntity extends SmartBlockEntity { public void rotate(BlockState state, PoseStack ms) { Direction facing = state.getValue(ControlsBlock.FACING); float yRot = AngleHelper.horizontalAngle(facing); - TransformStack.cast(ms) - .rotateY(yRot + 180) - .rotateX(67.5f); + TransformStack.of(ms) + .rotateYDegrees(yRot + 180) + .rotateXDegrees(67.5f); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsMovement.java b/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsMovement.java index b3e9536ecf..e0bf94a583 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsMovement.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsMovement.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.actors.contraptionControls; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; @@ -138,11 +138,6 @@ public class ContraptionControlsMovement implements MovementBehaviour { .string(); } - @Override - public boolean renderAsNormalBlockEntity() { - return true; - } - @Override @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext ctx, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsRenderer.java index 66548a08f2..f281b623a9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/contraptionControls/ContraptionControlsRenderer.java @@ -2,8 +2,6 @@ package com.simibubi.create.content.contraptions.actors.contraptionControls; import java.util.Random; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; @@ -20,7 +18,9 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.DyeHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.renderer.MultiBufferSource; @@ -93,14 +93,14 @@ public class ContraptionControlsRenderer extends SmartBlockEntityRenderer, Batched { - @Override - public ActorData create() { - return new ActorData(); - } - - @Override - public BufferLayout getLayout() { - return AllInstanceFormats.ACTOR; - } - - @Override - public StructWriter getWriter(VecBuffer backing) { - return new UnsafeActorWriter(backing, this); - } - - @Override - public ResourceLocation getProgramSpec() { - return AllProgramSpecs.ACTOR; - } - - @Override - public void transform(ActorData d, ModelTransformer.Params b) { - - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/UnsafeActorWriter.java b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/UnsafeActorWriter.java deleted file mode 100644 index c54b11db1a..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/UnsafeActorWriter.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.simibubi.create.content.contraptions.actors.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.api.struct.StructType; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; - -public class UnsafeActorWriter extends UnsafeBufferWriter { - public UnsafeActorWriter(VecBuffer backingBuffer, StructType vertexType) { - super(backingBuffer, vertexType); - } - - @Override - protected void writeInternal(ActorData d) { - long addr = writePointer; - MemoryUtil.memPutFloat(addr, d.x); - MemoryUtil.memPutFloat(addr + 4, d.y); - MemoryUtil.memPutFloat(addr + 8, d.z); - MemoryUtil.memPutByte(addr + 12, d.blockLight); - MemoryUtil.memPutByte(addr + 13, d.skyLight); - MemoryUtil.memPutFloat(addr + 14, d.rotationOffset); - MemoryUtil.memPutByte(addr + 18, d.rotationAxisX); - MemoryUtil.memPutByte(addr + 19, d.rotationAxisY); - MemoryUtil.memPutByte(addr + 20, d.rotationAxisZ); - MemoryUtil.memPutFloat(addr + 21, d.qX); - MemoryUtil.memPutFloat(addr + 25, d.qY); - MemoryUtil.memPutFloat(addr + 29, d.qZ); - MemoryUtil.memPutFloat(addr + 33, d.qW); - MemoryUtil.memPutByte(addr + 37, d.rotationCenterX); - MemoryUtil.memPutByte(addr + 38, d.rotationCenterY); - MemoryUtil.memPutByte(addr + 39, d.rotationCenterZ); - MemoryUtil.memPutFloat(addr + 40, d.speed); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/package-info.java b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/package-info.java deleted file mode 100644 index 0498b1729e..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -package com.simibubi.create.content.contraptions.actors.flwdata; - -import javax.annotation.ParametersAreNonnullByDefault; - -import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterActorVisual.java similarity index 59% rename from src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterActorInstance.java rename to src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterActorVisual.java index a9baf2f65d..7427392456 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterActorVisual.java @@ -1,28 +1,28 @@ package com.simibubi.create.content.contraptions.actors.harvester; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.Vec3; -public class HarvesterActorInstance extends ActorInstance { +public class HarvesterActorVisual extends ActorVisual { static float originOffset = 1 / 16f; static Vec3 rotOffset = new Vec3(0.5f, -2 * originOffset + 0.5f, originOffset + 0.5f); - protected ModelData harvester; + protected TransformedInstance harvester; private Direction facing; protected float horizontalAngle; @@ -30,31 +30,30 @@ public class HarvesterActorInstance extends ActorInstance { private double rotation; private double previousRotation; - public HarvesterActorInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) { - super(materialManager, simulationWorld, context); + public HarvesterActorVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, MovementContext movementContext) { + super(visualizationContext, simulationWorld, movementContext); - Material material = materialManager.defaultCutout() - .material(Materials.TRANSFORMED); - - BlockState state = context.state; + BlockState state = movementContext.state; facing = state.getValue(BlockStateProperties.HORIZONTAL_FACING); - harvester = material.getModel(getRollingPartial(), state).createInstance(); + harvester = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(getRollingPartial())) + .createInstance(); horizontalAngle = facing.toYRot() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0); - harvester.setBlockLight(localBlockLight()); + harvester.light(localBlockLight(), 0); + harvester.setChanged(); } protected PartialModel getRollingPartial() { return AllPartialModels.HARVESTER_BLADE; } - + protected Vec3 getRotationOffset() { return rotOffset; } - + protected double getRadius() { return 6.5; } @@ -84,17 +83,23 @@ public class HarvesterActorInstance extends ActorInstance { @Override public void beginFrame() { - harvester.loadIdentity() + harvester.setIdentityTransform() .translate(context.localPos) - .centre() - .rotateY(horizontalAngle) - .unCentre() + .center() + .rotateYDegrees(horizontalAngle) + .uncenter() .translate(getRotationOffset()) - .rotateX(getRotation()) - .translateBack(getRotationOffset()); + .rotateXDegrees((float) getRotation()) + .translateBack(getRotationOffset()) + .setChanged(); } - protected double getRotation() { + @Override + protected void _delete() { + harvester.delete(); + } + + protected double getRotation() { return AngleHelper.angleLerp(AnimationTickHolder.getPartialTicks(), previousRotation, rotation); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java index 3f7c7cb7d9..8680025d71 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java @@ -4,18 +4,18 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.mutable.MutableBoolean; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.BlockPos; import net.minecraft.tags.BlockTags; @@ -45,25 +45,6 @@ public class HarvesterMovementBehaviour implements MovementBehaviour { .getOpposite()); } - @Override - public boolean hasSpecialInstancedRendering() { - return true; - } - - @Nullable - @Override - public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, - MovementContext context) { - return new HarvesterActorInstance(materialManager, simulationWorld, context); - } - - @Override - public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, - ContraptionMatrices matrices, MultiBufferSource buffers) { - if (!ContraptionRenderDispatcher.canInstance()) - HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers); - } - @Override public Vec3 getActiveAreaOffset(MovementContext context) { return Vec3.atLowerCornerOf(context.state.getValue(HarvesterBlock.FACING) @@ -218,4 +199,23 @@ public class HarvesterMovementBehaviour implements MovementBehaviour { .createLegacyBlock(); } + @Override + public boolean disableBlockEntityRendering() { + return true; + } + + @Override + public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, + ContraptionMatrices matrices, MultiBufferSource buffers) { + if (!VisualizationManager.supportsVisualization(context.world)) + HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers); + } + + @Nullable + @Override + public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, + MovementContext movementContext) { + return new HarvesterActorVisual(visualizationContext, simulationWorld, movementContext); + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterRenderer.java index 9b99a16eba..0aa9b7102c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterRenderer.java @@ -2,19 +2,19 @@ package com.simibubi.create.content.contraptions.actors.harvester; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -53,8 +53,8 @@ public class HarvesterRenderer extends SafeBlockEntityRenderer consumer) { + consumer.accept(middle); + consumer.accept(top); + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIActorInstance.java deleted file mode 100644 index 9cee93e997..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIActorInstance.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.simibubi.create.content.contraptions.actors.psi; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.animation.LerpedFloat; - -public class PSIActorInstance extends ActorInstance { - - private final PIInstance instance; - - public PSIActorInstance(MaterialManager materialManager, VirtualRenderWorld world, MovementContext context) { - super(materialManager, world, context); - - instance = new PIInstance(materialManager, context.state, context.localPos); - - instance.init(false); - instance.middle.setBlockLight(localBlockLight()); - instance.top.setBlockLight(localBlockLight()); - } - - @Override - public void beginFrame() { - LerpedFloat lf = PortableStorageInterfaceMovement.getAnimation(context); - instance.tick(lf.settled()); - instance.beginFrame(lf.getValue(AnimationTickHolder.getPartialTicks())); - } - -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIActorVisual.java b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIActorVisual.java new file mode 100644 index 0000000000..130d8dc82a --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIActorVisual.java @@ -0,0 +1,36 @@ +package com.simibubi.create.content.contraptions.actors.psi; + +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.content.contraptions.render.ActorVisual; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; + +import dev.engine_room.flywheel.api.visualization.VisualizationContext; + +public class PSIActorVisual extends ActorVisual { + + private final PIInstance instance; + + public PSIActorVisual(VisualizationContext context, VirtualRenderWorld world, MovementContext movementContext) { + super(context, world, movementContext); + + instance = new PIInstance(context.instancerProvider(), movementContext.state, movementContext.localPos); + + instance.init(false); + instance.middle.light(localBlockLight(), 0); + instance.top.light(localBlockLight(), 0); + } + + @Override + public void beginFrame() { + LerpedFloat lf = PortableStorageInterfaceMovement.getAnimation(context); + instance.tick(lf.settled()); + instance.beginFrame(lf.getValue(AnimationTickHolder.getPartialTicks())); + } + + @Override + protected void _delete() { + instance.remove(); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIInstance.java b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIInstance.java deleted file mode 100644 index 4fa1020412..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIInstance.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.simibubi.create.content.contraptions.actors.psi; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.api.instance.TickableInstance; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -public class PSIInstance extends BlockEntityInstance implements DynamicInstance, TickableInstance { - - private final PIInstance instance; - - public PSIInstance(MaterialManager materialManager, PortableStorageInterfaceBlockEntity blockEntity) { - super(materialManager, blockEntity); - - instance = new PIInstance(materialManager, blockState, getInstancePosition()); - } - - @Override - public void init() { - instance.init(isLit()); - } - - @Override - public void tick() { - instance.tick(isLit()); - } - - @Override - public void beginFrame() { - instance.beginFrame(blockEntity.getExtensionDistance(AnimationTickHolder.getPartialTicks())); - } - - @Override - public void updateLight() { - relight(pos, instance.middle, instance.top); - } - - @Override - public void remove() { - instance.remove(); - } - - private boolean isLit() { - return blockEntity.isConnected(); - } - -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIVisual.java b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIVisual.java new file mode 100644 index 0000000000..e92d39b744 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PSIVisual.java @@ -0,0 +1,53 @@ +package com.simibubi.create.content.contraptions.actors.psi; + +import java.util.function.Consumer; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visual.TickableVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import dev.engine_room.flywheel.lib.visual.SimpleTickableVisual; + +public class PSIVisual extends AbstractBlockEntityVisual implements SimpleDynamicVisual, SimpleTickableVisual { + + private final PIInstance instance; + + public PSIVisual(VisualizationContext visualizationContext, PortableStorageInterfaceBlockEntity blockEntity, float partialTick) { + super(visualizationContext, blockEntity, partialTick); + + instance = new PIInstance(visualizationContext.instancerProvider(), blockState, getVisualPosition()); + + instance.init(isLit()); + } + + @Override + public void tick(TickableVisual.Context ctx) { + instance.tick(isLit()); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + instance.beginFrame(blockEntity.getExtensionDistance(ctx.partialTick())); + } + + @Override + public void updateLight(float partialTick) { + relight(instance.middle, instance.top); + } + + @Override + protected void _delete() { + instance.remove(); + } + + private boolean isLit() { + return blockEntity.isConnected(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + instance.collectCrumblingInstances(consumer); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceMovement.java b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceMovement.java index d27f8c0a2a..e72ad5c8a7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceMovement.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceMovement.java @@ -4,18 +4,18 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.content.trains.entity.CarriageContraption; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -40,22 +40,22 @@ public class PortableStorageInterfaceMovement implements MovementBehaviour { } @Override - public boolean hasSpecialInstancedRendering() { + public boolean disableBlockEntityRendering() { return true; } @Nullable @Override - public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, - MovementContext context) { - return new PSIActorInstance(materialManager, simulationWorld, context); + public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, + MovementContext movementContext) { + return new PSIActorVisual(visualizationContext, simulationWorld, movementContext); } @Override @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) { - if (!ContraptionRenderDispatcher.canInstance()) + if (!VisualizationManager.supportsVisualization(context.world)) PortableStorageInterfaceRenderer.renderInContraption(context, renderWorld, matrices, buffer); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceRenderer.java index 6ceffab7d4..99e1ecfb21 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/psi/PortableStorageInterfaceRenderer.java @@ -2,23 +2,23 @@ package com.simibubi.create.content.contraptions.actors.psi; import java.util.function.Consumer; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -35,7 +35,7 @@ public class PortableStorageInterfaceRenderer extends SafeBlockEntityRenderer sbb - .light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + sbb -> sbb.light(LevelRenderer.getLightColor(renderWorld, context.localPos)) + .useLevelLight(context.world, matrices.getWorld()) .renderInto(matrices.getViewProjection(), vb)); } @@ -80,10 +80,10 @@ public class PortableStorageInterfaceRenderer extends SafeBlockEntityRenderer material = materialManager.defaultCutout() - .material(Materials.TRANSFORMED); - frame = material.getModel(AllPartialModels.ROLLER_FRAME, context.state) - .createInstance(); - frame.setBlockLight(localBlockLight()); - } - - @Override - public void beginFrame() { - harvester.loadIdentity() - .translate(context.localPos) - .centre() - .rotateY(horizontalAngle) - .unCentre() - .translate(0, -.25, 17 / 16f) - .rotateX(getRotation()) - .translate(0, -.5, .5) - .rotateY(90); - - frame.loadIdentity() - .translate(context.localPos) - .centre() - .rotateY(horizontalAngle + 180) - .unCentre(); - } - - @Override - protected PartialModel getRollingPartial() { - return AllPartialModels.ROLLER_WHEEL; - } - - @Override - protected Vec3 getRotationOffset() { - return Vec3.ZERO; - } - - @Override - protected double getRadius() { - return 16.5; - } - -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerActorVisual.java b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerActorVisual.java new file mode 100644 index 0000000000..e692cd1bab --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerActorVisual.java @@ -0,0 +1,70 @@ +package com.simibubi.create.content.contraptions.actors.roller; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.contraptions.actors.harvester.HarvesterActorVisual; +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; + +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import net.minecraft.world.phys.Vec3; + +public class RollerActorVisual extends HarvesterActorVisual { + + TransformedInstance frame; + + public RollerActorVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, + MovementContext movementContext) { + super(visualizationContext, simulationWorld, movementContext); + + frame = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ROLLER_FRAME)) + .createInstance(); + frame.light(localBlockLight(), 0); + } + + @Override + public void beginFrame() { + harvester.setIdentityTransform() + .translate(context.localPos) + .center() + .rotateYDegrees(horizontalAngle) + .uncenter() + .translate(0, -.25, 17 / 16f) + .rotateXDegrees((float) getRotation()) + .translate(0, -.5, .5) + .rotateYDegrees(90) + .setChanged(); + + frame.setIdentityTransform() + .translate(context.localPos) + .center() + .rotateYDegrees(horizontalAngle + 180) + .uncenter() + .setChanged(); + } + + @Override + protected PartialModel getRollingPartial() { + return AllPartialModels.ROLLER_WHEEL; + } + + @Override + protected Vec3 getRotationOffset() { + return Vec3.ZERO; + } + + @Override + protected double getRadius() { + return 16.5; + } + + @Override + protected void _delete() { + super._delete(); + + frame.delete(); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerBlockEntity.java b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerBlockEntity.java index 69fb55bc1d..d525bef7b1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerBlockEntity.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.actors.roller; import java.util.List; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -182,11 +182,11 @@ public class RollerBlockEntity extends SmartBlockEntity { public void rotate(BlockState state, PoseStack ms) { Direction facing = state.getValue(RollerBlock.FACING); float yRot = AngleHelper.horizontalAngle(facing) + 180; - TransformStack.cast(ms) - .rotateY(yRot) - .rotateX(90); + TransformStack.of(ms) + .rotateYDegrees(yRot) + .rotateXDegrees(90); } - + @Override public boolean testHit(BlockState state, Vec3 localHit) { Vec3 offset = getLocalOffset(state); diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerMovementBehaviour.java index f057acd73a..f640dbd269 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerMovementBehaviour.java @@ -9,15 +9,13 @@ import java.util.function.BiConsumer; import javax.annotation.Nullable; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.AllTags; +import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.actors.roller.RollerBlockEntity.RollingMode; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.pulley.PulleyContraption; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; import com.simibubi.create.content.logistics.filter.FilterItemStack; import com.simibubi.create.content.trains.bogey.StandardBogeyBlock; @@ -37,8 +35,11 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -70,21 +71,21 @@ public class RollerMovementBehaviour extends BlockBreakingMovementBehaviour { } @Override - public boolean hasSpecialInstancedRendering() { + public boolean disableBlockEntityRendering() { return true; } @Nullable @Override - public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, - MovementContext context) { - return new RollerActorInstance(materialManager, simulationWorld, context); + public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, + MovementContext movementContext) { + return new RollerActorVisual(visualizationContext, simulationWorld, movementContext); } @Override public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffers) { - if (!ContraptionRenderDispatcher.canInstance()) + if (!VisualizationManager.supportsVisualization(context.world)) RollerRenderer.renderInContraption(context, renderWorld, matrices, buffers); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerRenderer.java index ec3cab40e4..06064e32b3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/RollerRenderer.java @@ -2,19 +2,20 @@ package com.simibubi.create.content.contraptions.actors.roller; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.actors.harvester.HarvesterRenderer; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRenderer; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context; @@ -34,6 +35,7 @@ public class RollerRenderer extends SmartBlockEntityRenderer super.renderSafe(be, partialTicks, ms, buffer, light, overlay); BlockState blockState = be.getBlockState(); + VertexConsumer vc = buffer.getBuffer(RenderType.cutoutMipped()); ms.pushPose(); ms.translate(0, -0.25, 0); @@ -43,21 +45,22 @@ public class RollerRenderer extends SmartBlockEntityRenderer .scale(17 / 16f)); HarvesterRenderer.transform(be.getLevel(), facing, superBuffer, be.getAnimatedSpeed(), Vec3.ZERO); superBuffer.translate(0, -.5, .5) - .rotateY(90) + .rotateYDegrees(90) .light(light) - .renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped())); + .renderInto(ms, vc); ms.popPose(); CachedBufferer.partial(AllPartialModels.ROLLER_FRAME, blockState) - .rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing) + 180)) + .rotateCentered(AngleHelper.rad(AngleHelper.horizontalAngle(facing) + 180), Direction.UP) .light(light) - .renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped())); + .renderInto(ms, vc); } public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffers) { BlockState blockState = context.state; Direction facing = blockState.getValue(HORIZONTAL_FACING); + VertexConsumer vc = buffers.getBuffer(RenderType.cutoutMipped()); SuperByteBuffer superBuffer = CachedBufferer.partial(AllPartialModels.ROLLER_WHEEL, blockState); float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()) ? context.getAnimationSpeed() @@ -73,18 +76,20 @@ public class RollerRenderer extends SmartBlockEntityRenderer PoseStack viewProjection = matrices.getViewProjection(); viewProjection.pushPose(); viewProjection.translate(0, -.25, 0); - int contraptionWorldLight = ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld); + int contraptionWorldLight = LevelRenderer.getLightColor(renderWorld, context.localPos); superBuffer.translate(0, -.5, .5) - .rotateY(90) - .light(matrices.getWorld(), contraptionWorldLight) - .renderInto(viewProjection, buffers.getBuffer(RenderType.cutoutMipped())); + .rotateYDegrees(90) + .light(contraptionWorldLight) + .useLevelLight(context.world, matrices.getWorld()) + .renderInto(viewProjection, vc); viewProjection.popPose(); CachedBufferer.partial(AllPartialModels.ROLLER_FRAME, blockState) .transform(matrices.getModel()) - .rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing) + 180)) - .light(matrices.getWorld(), contraptionWorldLight) - .renderInto(viewProjection, buffers.getBuffer(RenderType.cutoutMipped())); + .rotateCentered(AngleHelper.rad(AngleHelper.horizontalAngle(facing) + 180), Direction.UP) + .light(contraptionWorldLight) + .useLevelLight(context.world, matrices.getWorld()) + .renderInto(viewProjection, vc); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/TrackPaverV2.java b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/TrackPaverV2.java index b716d8f25f..e7b4fc6280 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/roller/TrackPaverV2.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/roller/TrackPaverV2.java @@ -101,7 +101,7 @@ public class TrackPaverV2 { Map, Double> yLevels = new HashMap<>(); Map, Double> tLevels = new HashMap<>(); - BlockPos tePosition = bc.tePositions.getFirst(); + BlockPos bePosition = bc.bePositions.getFirst(); double radius = -task.getHorizontalInterval() .getFirst(); double r1 = radius - .575; @@ -109,10 +109,10 @@ public class TrackPaverV2 { double handleLength = bc.getHandleLength(); Vec3 start = bc.starts.getFirst() - .subtract(Vec3.atLowerCornerOf(tePosition)) + .subtract(Vec3.atLowerCornerOf(bePosition)) .add(0, 3 / 16f, 0); Vec3 end = bc.starts.getSecond() - .subtract(Vec3.atLowerCornerOf(tePosition)) + .subtract(Vec3.atLowerCornerOf(bePosition)) .add(0, 3 / 16f, 0); Vec3 startHandle = bc.axes.getFirst() .scale(handleLength) @@ -190,7 +190,7 @@ public class TrackPaverV2 { BlockPos targetPos = new BlockPos(entry.getKey() .getFirst(), floor, entry.getKey() - .getSecond()).offset(tePosition); + .getSecond()).offset(bePosition); task.put(targetPos.getX(), targetPos.getZ(), targetPos.getY() + (yValue - floor >= .5 ? .5f : 0)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsMovementBehaviour.java index bc85048924..45f840136a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsMovementBehaviour.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.actors.trainControls; import java.util.Collection; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; @@ -11,6 +10,7 @@ import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.Direction; @@ -32,7 +32,7 @@ public class ControlsMovementBehaviour implements MovementBehaviour { public ItemStack canBeDisabledVia(MovementContext context) { return null; } - + @Override public void stopMoving(MovementContext context) { context.contraption.entity.stopControlling(context.localPos); diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsRenderer.java index b4c71c2de0..265542dbb3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/trainControls/ControlsRenderer.java @@ -1,17 +1,17 @@ package com.simibubi.create.content.contraptions.actors.trainControls; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.Direction; @@ -29,30 +29,32 @@ public class ControlsRenderer { float hAngle = 180 + AngleHelper.horizontalAngle(facing); PoseStack ms = matrices.getModel(); cover.transform(ms) - .centre() - .rotateY(hAngle) - .unCentre() - .light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .center() + .rotateYDegrees(hAngle) + .uncenter() + .light(LevelRenderer.getLightColor(renderWorld, context.localPos)) + .useLevelLight(context.world, matrices.getWorld()) .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped())); double yOffset = Mth.lerp(equipAnimation * equipAnimation, -0.15f, 0.05f); for (boolean first : Iterate.trueAndFalse) { - float vAngle = (float) Mth.clamp(first ? firstLever * 70 - 25 : secondLever * 15, -45, 45); + float vAngle = Mth.clamp(first ? firstLever * 70 - 25 : secondLever * 15, -45, 45); SuperByteBuffer lever = CachedBufferer.partial(AllPartialModels.TRAIN_CONTROLS_LEVER, state); ms.pushPose(); - TransformStack.cast(ms) - .centre() - .rotateY(hAngle) + TransformStack.of(ms) + .center() + .rotateYDegrees(hAngle) .translate(0, 0, 4 / 16f) - .rotateX(vAngle - 45) + .rotateXDegrees(vAngle - 45) .translate(0, yOffset, 0) - .rotateX(45) - .unCentre() + .rotateXDegrees(45) + .uncenter() .translate(0, -2 / 16f, -3 / 16f) .translate(first ? 0 : 6 / 16f, 0, 0); lever.transform(ms) - .light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .light(LevelRenderer.getLightColor(renderWorld, context.localPos)) + .useLevelLight(context.world, matrices.getWorld()) .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid())); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/AnchoredLighter.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/AnchoredLighter.java deleted file mode 100644 index 43788e2239..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/AnchoredLighter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.simibubi.create.content.contraptions.bearing; - -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; - -public class AnchoredLighter extends ContraptionLighter { - - public AnchoredLighter(Contraption contraption) { - super(contraption); - } - - @Override - public GridAlignedBB getContraptionBounds() { - GridAlignedBB bb = GridAlignedBB.from(contraption.bounds); - bb.translate(contraption.anchor); - return bb; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingContraption.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingContraption.java index 37d35bd267..ce4f40be7b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingContraption.java @@ -7,7 +7,6 @@ import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.content.contraptions.AssemblyException; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.ContraptionType; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; import com.simibubi.create.content.decoration.copycat.CopycatBlockEntity; import com.simibubi.create.infrastructure.config.AllConfigs; @@ -18,8 +17,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; public class BearingContraption extends Contraption { @@ -104,9 +101,4 @@ public class BearingContraption extends Contraption { return facing.getAxis() == this.facing.getAxis(); } - @OnlyIn(Dist.CLIENT) - @Override - public ContraptionLighter makeLighter() { - return new AnchoredLighter(this); - } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingInstance.java deleted file mode 100644 index e79787850e..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingInstance.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.simibubi.create.content.contraptions.bearing; - -import org.joml.Quaternionf; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.materials.oriented.OrientedData; -import com.mojang.math.Axis; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.BackHalfShaftInstance; -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; -import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class BearingInstance extends BackHalfShaftInstance implements DynamicInstance { - final OrientedData topInstance; - - final Axis rotationAxis; - final Quaternionf blockOrientation; - - public BearingInstance(MaterialManager materialManager, B blockEntity) { - super(materialManager, blockEntity); - - Direction facing = blockState.getValue(BlockStateProperties.FACING); - rotationAxis = Axis.of(Direction.get(Direction.AxisDirection.POSITIVE, axis).step()); - - blockOrientation = getBlockStateOrientation(facing); - - PartialModel top = - blockEntity.isWoodenTop() ? AllPartialModels.BEARING_TOP_WOODEN : AllPartialModels.BEARING_TOP; - - topInstance = getOrientedMaterial().getModel(top, blockState).createInstance(); - - topInstance.setPosition(getInstancePosition()).setRotation(blockOrientation); - } - - @Override - public void beginFrame() { - float interpolatedAngle = blockEntity.getInterpolatedAngle(AnimationTickHolder.getPartialTicks() - 1); - Quaternionf rot = rotationAxis.rotationDegrees(interpolatedAngle); - - rot.mul(blockOrientation); - - topInstance.setRotation(rot); - } - - @Override - public void updateLight() { - super.updateLight(); - relight(pos, topInstance); - } - - @Override - public void remove() { - super.remove(); - topInstance.delete(); - } - - static Quaternionf getBlockStateOrientation(Direction facing) { - Quaternionf orientation; - - if (facing.getAxis().isHorizontal()) { - orientation = Axis.YP.rotationDegrees(AngleHelper.horizontalAngle(facing.getOpposite())); - } else { - orientation = new Quaternionf(); - } - - orientation.mul(Axis.XP.rotationDegrees(-90 - AngleHelper.verticalAngle(facing))); - return orientation; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingRenderer.java index c7a4921c23..e77b0500b8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.contraptions.bearing; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; @@ -10,6 +8,8 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -27,7 +27,7 @@ public class BearingRenderer protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.canUseInstancing(be.getLevel())) return; + if (VisualizationManager.supportsVisualization(be.getLevel())) return; super.renderSafe(be, partialTicks, ms, buffer, light, overlay); @@ -42,9 +42,9 @@ public class BearingRenderer if (facing.getAxis() .isHorizontal()) - superBuffer.rotateCentered(Direction.UP, - AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite()))); - superBuffer.rotateCentered(Direction.EAST, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing))); + superBuffer.rotateCentered( + AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())), Direction.UP); + superBuffer.rotateCentered(AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing)), Direction.EAST); superBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid())); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingVisual.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingVisual.java new file mode 100644 index 0000000000..67edcfe3db --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/BearingVisual.java @@ -0,0 +1,90 @@ +package com.simibubi.create.content.contraptions.bearing; + +import java.util.function.Consumer; + +import org.joml.Quaternionf; + +import com.mojang.math.Axis; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.BackHalfShaftVisual; +import com.simibubi.create.content.kinetics.base.KineticBlockEntity; +import com.simibubi.create.foundation.utility.AngleHelper; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.OrientedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class BearingVisual extends BackHalfShaftVisual implements SimpleDynamicVisual { + final OrientedInstance topInstance; + + final Axis rotationAxis; + final Quaternionf blockOrientation; + + public BearingVisual(VisualizationContext context, B blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + Direction facing = blockState.getValue(BlockStateProperties.FACING); + rotationAxis = Axis.of(Direction.get(Direction.AxisDirection.POSITIVE, axis).step()); + + blockOrientation = getBlockStateOrientation(facing); + + PartialModel top = + blockEntity.isWoodenTop() ? AllPartialModels.BEARING_TOP_WOODEN : AllPartialModels.BEARING_TOP; + + topInstance = instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(top)) + .createInstance(); + + topInstance.position(getVisualPosition()) + .rotation(blockOrientation) + .setChanged(); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + float interpolatedAngle = blockEntity.getInterpolatedAngle(ctx.partialTick() - 1); + Quaternionf rot = rotationAxis.rotationDegrees(interpolatedAngle); + + rot.mul(blockOrientation); + + topInstance.rotation(rot) + .setChanged(); + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + relight(topInstance); + } + + @Override + protected void _delete() { + super._delete(); + topInstance.delete(); + } + + static Quaternionf getBlockStateOrientation(Direction facing) { + Quaternionf orientation; + + if (facing.getAxis().isHorizontal()) { + orientation = Axis.YP.rotationDegrees(AngleHelper.horizontalAngle(facing.getOpposite())); + } else { + orientation = new Quaternionf(); + } + + orientation.mul(Axis.XP.rotationDegrees(-90 - AngleHelper.verticalAngle(facing))); + return orientation; + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(topInstance); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/ClockworkContraption.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/ClockworkContraption.java index 1ab8f97af9..8ceca23c08 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/ClockworkContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/ClockworkContraption.java @@ -9,15 +9,12 @@ import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.content.contraptions.AssemblyException; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.ContraptionType; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; import com.simibubi.create.foundation.utility.NBTHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; public class ClockworkContraption extends Contraption { @@ -132,9 +129,4 @@ public class ClockworkContraption extends Contraption { HOUR, MINUTE } - @Override - @OnlyIn(Dist.CLIENT) - public ContraptionLighter makeLighter() { - return new AnchoredLighter(this); - } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingInstance.java deleted file mode 100644 index 68e2689d90..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingInstance.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.simibubi.create.content.contraptions.bearing; - -import org.joml.Quaternionf; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.materials.oriented.OrientedData; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.mojang.math.Axis; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.foundation.render.AllMaterialSpecs; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class StabilizedBearingInstance extends ActorInstance { - - final OrientedData topInstance; - final RotatingData shaft; - - final Direction facing; - final Axis rotationAxis; - final Quaternionf blockOrientation; - - public StabilizedBearingInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) { - super(materialManager, simulationWorld, context); - - BlockState blockState = context.state; - - facing = blockState.getValue(BlockStateProperties.FACING); - rotationAxis = Axis.of(Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()).step()); - - blockOrientation = BearingInstance.getBlockStateOrientation(facing); - - topInstance = materialManager.defaultSolid() - .material(Materials.ORIENTED) - .getModel(AllPartialModels.BEARING_TOP, blockState) - .createInstance(); - - int blockLight = localBlockLight(); - topInstance.setPosition(context.localPos) - .setRotation(blockOrientation) - .setBlockLight(blockLight); - - shaft = materialManager.defaultSolid() - .material(AllMaterialSpecs.ROTATING) - .getModel(AllPartialModels.SHAFT_HALF, blockState, blockState.getValue(BlockStateProperties.FACING).getOpposite()) - .createInstance(); - - // not rotating so no need to set speed, axis, etc. - shaft.setPosition(context.localPos) - .setBlockLight(blockLight); - } - - @Override - public void beginFrame() { - float counterRotationAngle = StabilizedBearingMovementBehaviour.getCounterRotationAngle(context, facing, AnimationTickHolder.getPartialTicks()); - - Quaternionf rotation = rotationAxis.rotationDegrees(counterRotationAngle); - - rotation.mul(blockOrientation); - - topInstance.setRotation(rotation); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingMovementBehaviour.java index 2d3800b4ef..310add5939 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingMovementBehaviour.java @@ -4,9 +4,6 @@ import javax.annotation.Nullable; import org.joml.Quaternionf; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.mojang.math.Axis; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; @@ -14,13 +11,17 @@ import com.simibubi.create.content.contraptions.ControlledContraptionEntity; import com.simibubi.create.content.contraptions.OrientedContraptionEntity; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.Direction; @@ -35,12 +36,17 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour { public ItemStack canBeDisabledVia(MovementContext context) { return null; } - + + @Override + public boolean disableBlockEntityRendering() { + return true; + } + @Override @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) { - if (ContraptionRenderDispatcher.canInstance()) + if (!VisualizationManager.supportsVisualization(context.world)) return; Direction facing = context.state.getValue(BlockStateProperties.FACING); @@ -49,7 +55,7 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour { float renderPartialTicks = AnimationTickHolder.getPartialTicks(); // rotate to match blockstate - Quaternionf orientation = BearingInstance.getBlockStateOrientation(facing); + Quaternionf orientation = BearingVisual.getBlockStateOrientation(facing); // rotate against parent float angle = getCounterRotationAngle(context, facing, renderPartialTicks) * facing.getAxisDirection() @@ -66,21 +72,16 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour { superBuffer.rotateCentered(orientation); // render - superBuffer - .light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + superBuffer.light(LevelRenderer.getLightColor(renderWorld, context.localPos)) + .useLevelLight(context.world, matrices.getWorld()) .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid())); } - @Override - public boolean hasSpecialInstancedRendering() { - return true; - } - @Nullable @Override - public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, - MovementContext context) { - return new StabilizedBearingInstance(materialManager, simulationWorld, context); + public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, + MovementContext movementContext) { + return new StabilizedBearingVisual(visualizationContext, simulationWorld, movementContext); } static float getCounterRotationAngle(MovementContext context, Direction facing, float renderPartialTicks) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingVisual.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingVisual.java new file mode 100644 index 0000000000..81e11bfc65 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingVisual.java @@ -0,0 +1,73 @@ +package com.simibubi.create.content.contraptions.bearing; + +import org.joml.Quaternionf; + +import com.mojang.math.Axis; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.content.contraptions.render.ActorVisual; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; + +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.OrientedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class StabilizedBearingVisual extends ActorVisual { + + final OrientedInstance topInstance; + final RotatingInstance shaft; + + final Direction facing; + final Axis rotationAxis; + final Quaternionf blockOrientation; + + public StabilizedBearingVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, MovementContext movementContext) { + super(visualizationContext, simulationWorld, movementContext); + + BlockState blockState = movementContext.state; + + facing = blockState.getValue(BlockStateProperties.FACING); + rotationAxis = Axis.of(Direction.get(Direction.AxisDirection.POSITIVE, facing.getAxis()).step()); + + blockOrientation = BearingVisual.getBlockStateOrientation(facing); + + topInstance = instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.BEARING_TOP)) + .createInstance(); + + int blockLight = localBlockLight(); + topInstance.position(movementContext.localPos) + .rotation(blockOrientation) + .light(blockLight, 0); + + shaft = instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.SHAFT_HALF, blockState.getValue(BlockStateProperties.FACING).getOpposite())) + .createInstance(); + + // not rotating so no need to set speed, axis, etc. + shaft.setPosition(movementContext.localPos) + .light(blockLight, 0); + } + + @Override + public void beginFrame() { + float counterRotationAngle = StabilizedBearingMovementBehaviour.getCounterRotationAngle(context, facing, AnimationTickHolder.getPartialTicks()); + + Quaternionf rotation = rotationAxis.rotationDegrees(counterRotationAngle); + + rotation.mul(blockOrientation); + + topInstance.rotation(rotation); + } + + @Override + protected void _delete() { + topInstance.delete(); + shaft.delete(); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedContraption.java index c4ef7cf302..67c9946244 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedContraption.java @@ -3,15 +3,11 @@ package com.simibubi.create.content.contraptions.bearing; import com.simibubi.create.content.contraptions.AssemblyException; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.ContraptionType; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; -import com.simibubi.create.content.contraptions.render.NonStationaryLighter; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; public class StabilizedContraption extends Contraption { @@ -66,9 +62,4 @@ public class StabilizedContraption extends Contraption { return facing; } - @Override - @OnlyIn(Dist.CLIENT) - public ContraptionLighter makeLighter() { - return new NonStationaryLighter<>(this); - } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/behaviour/BellMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/behaviour/BellMovementBehaviour.java index 55987d46e0..7796239796 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/behaviour/BellMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/behaviour/BellMovementBehaviour.java @@ -11,12 +11,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.phys.Vec3; public class BellMovementBehaviour implements MovementBehaviour { - - @Override - public boolean renderAsNormalBlockEntity() { - return true; - } - @Override public boolean isActive(MovementContext context) { return MovementBehaviour.super.isActive(context) && !(context.contraption instanceof CarriageContraption); diff --git a/src/main/java/com/simibubi/create/content/contraptions/behaviour/CampfireMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/behaviour/CampfireMovementBehaviour.java index a6be9bf458..05315b3138 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/behaviour/CampfireMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/behaviour/CampfireMovementBehaviour.java @@ -5,11 +5,6 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.level.block.CampfireBlock; public class CampfireMovementBehaviour implements MovementBehaviour { - @Override - public boolean renderAsNormalBlockEntity() { - return true; - } - @Override public void tick(MovementContext context) { if (context.world == null || !context.world.isClientSide || context.position == null diff --git a/src/main/java/com/simibubi/create/content/contraptions/behaviour/MovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/behaviour/MovementBehaviour.java index 3cf7dd7a6b..02f502258f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/behaviour/MovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/behaviour/MovementBehaviour.java @@ -2,12 +2,12 @@ package com.simibubi.create.content.contraptions.behaviour; import javax.annotation.Nullable; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.item.ItemEntity; @@ -41,11 +41,11 @@ public interface MovementBehaviour { return null; return new ItemStack(block); } - + default void onDisabledByControls(MovementContext context) { cancelStall(context); } - + default boolean mustTickWhileDisabled() { return false; } @@ -63,7 +63,7 @@ public interface MovementBehaviour { Vec3 vec = context.position; if (vec == null) return; - + ItemEntity itemEntity = new ItemEntity(context.world, vec.x, vec.y, vec.z, remainder); itemEntity.setDeltaMovement(context.motion.add(0, 0.5f, 0) .scale(context.world.random.nextFloat() * .3f)); @@ -73,18 +73,14 @@ public interface MovementBehaviour { default void onSpeedChanged(MovementContext context, Vec3 oldMotion, Vec3 motion) {} default void stopMoving(MovementContext context) {} - + default void cancelStall(MovementContext context) { context.stall = false; } default void writeExtraData(MovementContext context) {} - default boolean renderAsNormalBlockEntity() { - return false; - } - - default boolean hasSpecialInstancedRendering() { + default boolean disableBlockEntityRendering() { return false; } @@ -94,8 +90,8 @@ public interface MovementBehaviour { @OnlyIn(Dist.CLIENT) @Nullable - default ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, - MovementContext context) { + default ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, + MovementContext movementContext) { return null; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerBlockEntity.java b/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerBlockEntity.java index 8b4454bea0..131113c78f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerBlockEntity.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.chassis; import java.util.List; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.contraptions.glue.SuperGlueEntity; @@ -12,6 +11,7 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -70,7 +70,7 @@ public class StickerBlockEntity extends SmartBlockEntity { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> playSound(false)); piston.chase(target, .4f, Chaser.LINEAR); - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> VisualizationHelper.queueUpdate(this)); } public boolean isAttachedToBlock() { @@ -85,7 +85,7 @@ public class StickerBlockEntity extends SmartBlockEntity { protected void write(CompoundTag tag, boolean clientPacket) { super.write(tag, clientPacket); } - + @Override protected void read(CompoundTag compound, boolean clientPacket) { super.read(compound, clientPacket); diff --git a/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerInstance.java deleted file mode 100644 index 4b4c4a262b..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerInstance.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.simibubi.create.content.contraptions.chassis; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.client.Minecraft; -import net.minecraft.core.Direction; -import net.minecraft.util.Mth; - -public class StickerInstance extends BlockEntityInstance implements DynamicInstance { - - float lastOffset = Float.NaN; - final Direction facing; - final boolean fakeWorld; - final int offset; - - private final ModelData head; - - public StickerInstance(MaterialManager materialManager, StickerBlockEntity blockEntity) { - super(materialManager, blockEntity); - - head = getTransformMaterial().getModel(AllPartialModels.STICKER_HEAD, blockState).createInstance(); - - fakeWorld = blockEntity.getLevel() != Minecraft.getInstance().level; - facing = blockState.getValue(StickerBlock.FACING); - offset = blockState.getValue(StickerBlock.EXTENDED) ? 1 : 0; - - animateHead(offset); - } - - @Override - public void beginFrame() { - float offset = blockEntity.piston.getValue(AnimationTickHolder.getPartialTicks()); - - if (fakeWorld) - offset = this.offset; - - if (Mth.equal(offset, lastOffset)) - return; - - animateHead(offset); - - lastOffset = offset; - } - - private void animateHead(float offset) { - head.loadIdentity() - .translate(getInstancePosition()) - .nudge(blockEntity.hashCode()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing) + 90) - .unCentre() - .translate(0, (offset * offset) * 4 / 16f, 0); - } - - @Override - public void updateLight() { - relight(pos, head); - } - - @Override - public void remove() { - head.delete(); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerRenderer.java index 846663029a..8245657d41 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.chassis; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; @@ -9,6 +8,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -25,7 +25,7 @@ public class StickerRenderer extends SafeBlockEntityRenderer protected void renderSafe(StickerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.canUseInstancing(be.getLevel())) return; + if (VisualizationManager.supportsVisualization(be.getLevel())) return; BlockState state = be.getBlockState(); SuperByteBuffer head = CachedBufferer.partial(AllPartialModels.STICKER_HEAD, state); @@ -36,10 +36,10 @@ public class StickerRenderer extends SafeBlockEntityRenderer Direction facing = state.getValue(StickerBlock.FACING); head.nudge(be.hashCode()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing) + 90) - .unCentre() + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing)) + .rotateXDegrees(AngleHelper.verticalAngle(facing) + 90) + .uncenter() .translate(0, (offset * offset) * 4 / 16f, 0); head.light(light) diff --git a/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerVisual.java b/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerVisual.java new file mode 100644 index 0000000000..d44a3e95d7 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/chassis/StickerVisual.java @@ -0,0 +1,82 @@ +package com.simibubi.create.content.contraptions.chassis; + +import java.util.function.Consumer; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.foundation.utility.AngleHelper; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import net.minecraft.client.Minecraft; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; + +public class StickerVisual extends AbstractBlockEntityVisual implements SimpleDynamicVisual { + + float lastOffset = Float.NaN; + final Direction facing; + final boolean fakeWorld; + final int offset; + + private final TransformedInstance head; + + public StickerVisual(VisualizationContext context, StickerBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + head = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.STICKER_HEAD)).createInstance(); + + fakeWorld = blockEntity.getLevel() != Minecraft.getInstance().level; + facing = blockState.getValue(StickerBlock.FACING); + offset = blockState.getValue(StickerBlock.EXTENDED) ? 1 : 0; + + animateHead(offset); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + float offset = blockEntity.piston.getValue(ctx.partialTick()); + + if (fakeWorld) + offset = this.offset; + + if (Mth.equal(offset, lastOffset)) + return; + + animateHead(offset); + + lastOffset = offset; + } + + private void animateHead(float offset) { + head.setIdentityTransform() + .translate(getVisualPosition()) + .nudge(blockEntity.hashCode()) + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing)) + .rotateXDegrees(AngleHelper.verticalAngle(facing) + 90) + .uncenter() + .translate(0, (offset * offset) * 4 / 16f, 0) + .setChanged(); + } + + @Override + public void updateLight(float partialTick) { + relight(head); + } + + @Override + protected void _delete() { + head.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(head); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/elevator/ElevatorPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/elevator/ElevatorPulleyInstance.java deleted file mode 100644 index ac5e07f786..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/elevator/ElevatorPulleyInstance.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.simibubi.create.content.contraptions.elevator; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.light.TickingLightListener; -import com.simibubi.create.content.kinetics.base.ShaftInstance; - -// TODO -public class ElevatorPulleyInstance extends ShaftInstance implements DynamicInstance, TickingLightListener { - - public ElevatorPulleyInstance(MaterialManager materialManager, ElevatorPulleyBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - public boolean tickLightListener() { - return false; - } - - @Override - public void beginFrame() { - } - -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/elevator/ElevatorPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/elevator/ElevatorPulleyRenderer.java index c34c701dd8..d9a89b15b7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/elevator/ElevatorPulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/elevator/ElevatorPulleyRenderer.java @@ -30,14 +30,13 @@ public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer .75f) { - halfRope.centre() - .rotateY(blockStateAngle) - .unCentre(); + halfRope.center() + .rotateYDegrees(blockStateAngle) + .uncenter(); AbstractPulleyRenderer.renderAt(world, halfRope.shiftUVScrolling(beltShift, (float) beltScroll * spriteSize), f > .75f ? f - 1 : f, pos, ms, vb); @@ -95,9 +94,9 @@ public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer implements SimpleDynamicVisual { + + public ElevatorPulleyVisual(VisualizationContext context, ElevatorPulleyBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + } + +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryCarriageRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryCarriageRenderer.java index f99fe87941..b27a04ca10 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryCarriageRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryCarriageRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.gantry; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -31,7 +31,7 @@ public class GantryCarriageRenderer extends KineticBlockEntityRenderer implements DynamicInstance { +public class GantryCarriageVisual extends ShaftVisual implements SimpleDynamicVisual { - private final ModelData gantryCogs; + private final TransformedInstance gantryCogs; final Direction facing; final Boolean alongFirst; @@ -25,11 +31,10 @@ public class GantryCarriageInstance extends ShaftInstance consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(gantryCogs); + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryContraption.java b/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryContraption.java index 5ec56c80e6..447ff7bf84 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/gantry/GantryContraption.java @@ -4,16 +4,12 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.AssemblyException; import com.simibubi.create.content.contraptions.ContraptionType; import com.simibubi.create.content.contraptions.TranslatingContraption; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; -import com.simibubi.create.content.contraptions.render.NonStationaryLighter; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; public class GantryContraption extends TranslatingContraption { @@ -65,9 +61,4 @@ public class GantryContraption extends TranslatingContraption { return super.shouldUpdateAfterMovement(info) && !AllBlocks.GANTRY_CARRIAGE.has(info.state()); } - @Override - @OnlyIn(Dist.CLIENT) - public ContraptionLighter makeLighter() { - return new NonStationaryLighter<>(this); - } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/minecart/CouplingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/minecart/CouplingRenderer.java index da2dc0e5d2..c0fc44402e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/minecart/CouplingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/minecart/CouplingRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.minecart; import static net.minecraft.util.Mth.lerp; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.LevelRenderer; @@ -79,7 +79,7 @@ public class CouplingRenderer { double connectorPitch = Math.atan2(endPointDiff.y, endPointDiff.multiply(1, 0, 1) .length()) * 180 / Math.PI; - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); carts.forEachWithContext((cart, isFirst) -> { CartEndpoint cartTransform = transforms.get(isFirst); @@ -87,7 +87,7 @@ public class CouplingRenderer { cartTransform.apply(ms, camera); attachment.light(lightValues.get(isFirst)) .renderInto(ms, builder); - msr.rotateY(connectorYaw - cartTransform.yaw); + msr.rotateYDegrees((float) connectorYaw - cartTransform.yaw); ring.light(lightValues.get(isFirst)) .renderInto(ms, builder); ms.popPose(); @@ -100,8 +100,8 @@ public class CouplingRenderer { ms.pushPose(); msr.translate(firstEndpoint.subtract(camera)) - .rotateY(connectorYaw) - .rotateZ(connectorPitch); + .rotateYDegrees((float) connectorYaw) + .rotateZDegrees((float) connectorPitch); ms.scale((float) endPointDiff.length(), 1, 1); connector.light(meanSkyLight << 20 | meanBlockLight << 4) @@ -201,14 +201,14 @@ public class CouplingRenderer { } public void apply(PoseStack ms, Vec3 camera) { - TransformStack.cast(ms) + TransformStack.of(ms) .translate(camera.scale(-1) .add(x, y, z)) - .rotateY(yaw) - .rotateZ(pitch) - .rotateX(roll) + .rotateYDegrees(yaw) + .rotateZDegrees(pitch) + .rotateXDegrees(roll) .translate(offset, 0, 0) - .rotateY(flip ? 180 : 0); + .rotateYDegrees(flip ? 180 : 0); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/mounted/MountedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/mounted/MountedContraption.java index 620b470972..0c2052a3d8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/mounted/MountedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/mounted/MountedContraption.java @@ -11,8 +11,6 @@ import com.simibubi.create.content.contraptions.AssemblyException; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.ContraptionType; import com.simibubi.create.content.contraptions.mounted.CartAssemblerBlockEntity.CartMovementMode; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; -import com.simibubi.create.content.contraptions.render.NonStationaryLighter; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; @@ -32,8 +30,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraft.world.phys.AABB; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.wrapper.InvWrapper; public class MountedContraption extends Contraption { @@ -159,10 +155,5 @@ public class MountedContraption extends Contraption { if (cart instanceof Container container) storage.attachExternal(new ContraptionInvWrapper(true, new InvWrapper(container))); } - - @Override - @OnlyIn(Dist.CLIENT) - public ContraptionLighter makeLighter() { - return new NonStationaryLighter<>(this); - } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/piston/PistonContraption.java b/src/main/java/com/simibubi/create/content/contraptions/piston/PistonContraption.java index 859cf40643..3072c36041 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/piston/PistonContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/piston/PistonContraption.java @@ -19,7 +19,6 @@ import com.simibubi.create.content.contraptions.BlockMovementChecks; import com.simibubi.create.content.contraptions.ContraptionType; import com.simibubi.create.content.contraptions.TranslatingContraption; import com.simibubi.create.content.contraptions.piston.MechanicalPistonBlock.PistonState; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.infrastructure.config.AllConfigs; @@ -36,8 +35,6 @@ import net.minecraft.world.level.block.state.properties.PistonType; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.phys.AABB; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; public class PistonContraption extends TranslatingContraption { @@ -244,9 +241,4 @@ public class PistonContraption extends TranslatingContraption { return tag; } - @OnlyIn(Dist.CLIENT) - @Override - public ContraptionLighter makeLighter() { - return new PistonLighter(this); - } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/piston/PistonLighter.java b/src/main/java/com/simibubi/create/content/contraptions/piston/PistonLighter.java deleted file mode 100644 index b21c795059..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/piston/PistonLighter.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.simibubi.create.content.contraptions.piston; - -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; - -import net.minecraft.core.Vec3i; - -public class PistonLighter extends ContraptionLighter { - public PistonLighter(PistonContraption contraption) { - super(contraption); - } - - @Override - public GridAlignedBB getContraptionBounds() { - GridAlignedBB bounds = GridAlignedBB.from(contraption.bounds); - bounds.translate(contraption.anchor); - - int length = contraption.extensionLength; - Vec3i direction = contraption.orientation.getNormal(); - - 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; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyInstance.java deleted file mode 100644 index 522b81c2ae..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyInstance.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.simibubi.create.content.contraptions.pulley; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.core.instancing.ConditionalInstance; -import com.jozufozu.flywheel.core.instancing.GroupInstance; -import com.jozufozu.flywheel.core.instancing.SelectInstance; -import com.jozufozu.flywheel.core.materials.oriented.OrientedData; -import com.jozufozu.flywheel.light.LightPacking; -import com.jozufozu.flywheel.light.LightVolume; -import com.jozufozu.flywheel.light.TickingLightListener; -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.jozufozu.flywheel.util.box.ImmutableBox; -import com.mojang.math.Axis; -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; -import com.simibubi.create.content.kinetics.base.ShaftInstance; - -import net.minecraft.core.Direction; -import net.minecraft.util.Mth; -import net.minecraft.world.level.LightLayer; - -public abstract class AbstractPulleyInstance extends ShaftInstance implements DynamicInstance, TickingLightListener { - - final OrientedData coil; - final SelectInstance magnet; - final GroupInstance rope; - final ConditionalInstance halfRope; - - protected float offset; - protected final Direction rotatingAbout; - protected final Axis rotationAxis; - - private final GridAlignedBB volume = new GridAlignedBB(); - private final LightVolume light; - - public AbstractPulleyInstance(MaterialManager dispatcher, T blockEntity) { - super(dispatcher, blockEntity); - - rotatingAbout = Direction.get(Direction.AxisDirection.POSITIVE, axis); - rotationAxis = Axis.of(rotatingAbout.step()); - - coil = getCoilModel().createInstance() - .setPosition(getInstancePosition()); - - magnet = new SelectInstance<>(this::getMagnetModelIndex); - magnet.addModel(getMagnetModel()) - .addModel(getHalfMagnetModel()); - - rope = new GroupInstance<>(getRopeModel()); - halfRope = new ConditionalInstance<>(getHalfRopeModel()).withCondition(this::shouldRenderHalfRope); - - updateOffset(); - updateVolume(); - - light = new LightVolume(world, volume); - light.initialize(); - } - - @Override - public void beginFrame() { - updateOffset(); - coil.setRotation(rotationAxis.rotationDegrees(offset * 180)); - - int neededRopeCount = getNeededRopeCount(); - rope.resize(neededRopeCount); - - magnet.update() - .get() - .ifPresent(data -> { - int i = Math.max(0, Mth.floor(offset)); - short packed = light.getPackedLight(pos.getX(), pos.getY() - i, pos.getZ()); - data.setPosition(getInstancePosition()) - .nudge(0, -offset, 0) - .setBlockLight(LightPacking.getBlock(packed)) - .setSkyLight(LightPacking.getSky(packed)); - }); - - halfRope.update() - .get() - .ifPresent(rope1 -> { - float f = offset % 1; - float halfRopeNudge = f > .75f ? f - 1 : f; - - short packed = light.getPackedLight(pos.getX(), pos.getY(), pos.getZ()); - rope1.setPosition(getInstancePosition()) - .nudge(0, -halfRopeNudge, 0) - .setBlockLight(LightPacking.getBlock(packed)) - .setSkyLight(LightPacking.getSky(packed)); - }); - - if (isRunning()) { - int size = rope.size(); - int bottomY = pos.getY() - size; - for (int i = 0; i < size; i++) { - short packed = light.getPackedLight(pos.getX(), bottomY + i, pos.getZ()); - - rope.get(i) - .setPosition(getInstancePosition()) - .nudge(0, -offset + i + 1, 0) - .setBlockLight(LightPacking.getBlock(packed)) - .setSkyLight(LightPacking.getSky(packed)); - } - } else { - rope.clear(); - } - } - - @Override - public void updateLight() { - super.updateLight(); - relight(pos, coil); - } - - @Override - public void remove() { - super.remove(); - coil.delete(); - magnet.delete(); - rope.clear(); - halfRope.delete(); - light.delete(); - } - - protected abstract Instancer getRopeModel(); - - protected abstract Instancer getMagnetModel(); - - protected abstract Instancer getHalfMagnetModel(); - - protected abstract Instancer getCoilModel(); - - protected abstract Instancer getHalfRopeModel(); - - protected abstract float getOffset(); - - protected abstract boolean isRunning(); - - @Override - public boolean tickLightListener() { - if (updateVolume()) { - light.move(volume); - return true; - } - return false; - } - - private boolean updateVolume() { - int length = Mth.ceil(offset) + 2; - - if (volume.sizeY() < length) { - volume.assign(pos.below(length), pos) - .fixMinMax(); - return true; - } - return false; - } - - private void updateOffset() { - offset = getOffset(); - } - - private int getNeededRopeCount() { - return Math.max(0, Mth.ceil(offset - 1.25f)); - } - - private boolean shouldRenderHalfRope() { - float f = offset % 1; - return offset > .75f && (f < .25f || f > .75f); - } - - private int getMagnetModelIndex() { - if (isRunning() || offset == 0) { - return offset > .25f ? 0 : 1; - } else { - return -1; - } - } - - @Override - public boolean decreaseFramerateWithDistance() { - return false; - } - - @Override - public ImmutableBox getVolume() { - return volume; - } - - @Override - public void onLightUpdate(LightLayer type, ImmutableBox changed) { - super.onLightUpdate(type, changed); - light.onLightUpdate(type, changed); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyRenderer.java index 7983fd0eed..caca5fd8db 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.contraptions.pulley; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.kinetics.base.IRotate; @@ -11,6 +9,8 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -44,7 +44,7 @@ public abstract class AbstractPulleyRenderer exten protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.canUseInstancing(be.getLevel())) + if (VisualizationManager.supportsVisualization(be.getLevel())) return; super.renderSafe(be, partialTicks, ms, buffer, light, overlay); @@ -53,8 +53,9 @@ public abstract class AbstractPulleyRenderer exten Axis rotationAxis = ((IRotate) be.getBlockState() .getBlock()).getRotationAxis(be.getBlockState()); + VertexConsumer vb = buffer.getBuffer(RenderType.solid()); kineticRotationTransform(getRotatedCoil(be), be, rotationAxis, AngleHelper.rad(offset * 180), light) - .renderInto(ms, buffer.getBuffer(RenderType.solid())); + .renderInto(ms, vb); Level world = be.getLevel(); BlockState blockState = be.getBlockState(); @@ -65,7 +66,6 @@ public abstract class AbstractPulleyRenderer exten SuperByteBuffer magnet = renderMagnet(be); SuperByteBuffer rope = renderRope(be); - VertexConsumer vb = buffer.getBuffer(RenderType.solid()); if (running || offset == 0) renderAt(world, offset > .25f ? magnet : halfMagnet, offset, pos, ms, vb); @@ -85,7 +85,7 @@ public abstract class AbstractPulleyRenderer exten BlockPos actualPos = pulleyPos.below((int) offset); int light = LevelRenderer.getLightColor(world, world.getBlockState(actualPos), actualPos); partial.translate(0, -offset, 0) - .light(light) + .light(light) .renderInto(ms, buffer); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyVisual.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyVisual.java new file mode 100644 index 0000000000..d5dd84a903 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/pulley/AbstractPulleyVisual.java @@ -0,0 +1,235 @@ +package com.simibubi.create.content.contraptions.pulley; + +import java.util.function.Consumer; + +import com.mojang.math.Axis; +import com.simibubi.create.content.kinetics.base.KineticBlockEntity; +import com.simibubi.create.content.kinetics.base.ShaftVisual; +import com.simibubi.create.foundation.render.ConditionalInstance; +import com.simibubi.create.foundation.render.GroupInstance; +import com.simibubi.create.foundation.render.SelectInstance; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.OrientedInstance; +import dev.engine_room.flywheel.lib.math.MoreMath; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import it.unimi.dsi.fastutil.bytes.ByteArrayList; +import it.unimi.dsi.fastutil.bytes.ByteList; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +import it.unimi.dsi.fastutil.longs.LongSet; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.SectionPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.LightLayer; + +public abstract class AbstractPulleyVisual extends ShaftVisual implements SimpleDynamicVisual { + private final OrientedInstance coil; + private final SelectInstance magnet; + private final GroupInstance rope; + private final ConditionalInstance halfRope; + + protected final Direction rotatingAbout; + protected final Axis rotationAxis; + + private final LightCache lightCache = new LightCache(); + + private float offset; + + public AbstractPulleyVisual(VisualizationContext dispatcher, T blockEntity, float partialTick) { + super(dispatcher, blockEntity, partialTick); + + rotatingAbout = Direction.get(Direction.AxisDirection.POSITIVE, axis); + rotationAxis = Axis.of(rotatingAbout.step()); + + coil = getCoilModel().createInstance() + .position(getVisualPosition()); + coil.setChanged(); + + magnet = new SelectInstance<>(this::getMagnetModelIndex); + magnet.addModel(getMagnetModel()) + .addModel(getHalfMagnetModel()); + + rope = new GroupInstance<>(getRopeModel()); + halfRope = new ConditionalInstance<>(getHalfRopeModel()).withCondition(this::shouldRenderHalfRope); + + updateOffset(partialTick); + } + + @Override + public void setSectionCollector(SectionCollector sectionCollector) { + super.setSectionCollector(sectionCollector); + lightCache.updateSections(); + } + + protected abstract Instancer getRopeModel(); + + protected abstract Instancer getMagnetModel(); + + protected abstract Instancer getHalfMagnetModel(); + + protected abstract Instancer getCoilModel(); + + protected abstract Instancer getHalfRopeModel(); + + protected abstract float getOffset(float pt); + + protected abstract boolean isRunning(); + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + updateOffset(ctx.partialTick()); + coil.rotation(rotationAxis.rotationDegrees(offset * 180)) + .setChanged(); + + int neededRopeCount = getNeededRopeCount(); + rope.resize(neededRopeCount); + + magnet.update() + .get() + .ifPresent(data -> { + int i = Math.max(0, Mth.floor(offset)); + int light = lightCache.getPackedLight(i); + data.position(getVisualPosition()) + .translatePosition(0, -offset, 0) + .light(light) + .setChanged(); + }); + + halfRope.update() + .get() + .ifPresent(rope1 -> { + float f = offset % 1; + float halfRopeNudge = f > .75f ? f - 1 : f; + + int light = lightCache.getPackedLight(0); + rope1.position(getVisualPosition()) + .translatePosition(0, -halfRopeNudge, 0) + .light(light) + .setChanged(); + }); + + if (isRunning()) { + int size = rope.size(); + for (int i = 0; i < size; i++) { + int light = lightCache.getPackedLight(size - 1 - i); + + rope.get(i) + .position(getVisualPosition()) + .translatePosition(0, -offset + i + 1, 0) + .light(light) + .setChanged(); + } + } else { + rope.clear(); + } + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + relight(coil); + + lightCache.update(); + } + + private void updateOffset(float pt) { + offset = getOffset(pt); + lightCache.setSize(Mth.ceil(offset) + 2); + } + + private int getNeededRopeCount() { + return Math.max(0, Mth.ceil(offset - 1.25f)); + } + + private boolean shouldRenderHalfRope() { + float f = offset % 1; + return offset > .75f && (f < .25f || f > .75f); + } + + private int getMagnetModelIndex() { + if (isRunning() || offset == 0) { + return offset > .25f ? 0 : 1; + } else { + return -1; + } + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(coil); + magnet.forEach(consumer); + rope.forEach(consumer); + halfRope.forEach(consumer); + } + + @Override + protected void _delete() { + super._delete(); + coil.delete(); + magnet.delete(); + rope.clear(); + halfRope.delete(); + } + + private class LightCache { + private final ByteList data = new ByteArrayList(); + private final LongSet sections = new LongOpenHashSet(); + private final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); + private int sectionCount; + + public void setSize(int size) { + if (size != data.size()) { + data.size(size); + + int sectionCount = MoreMath.ceilingDiv(size + 15 - pos.getY() + pos.getY() / 4 * 4, SectionPos.SECTION_SIZE); + if (sectionCount != this.sectionCount) { + this.sectionCount = sectionCount; + sections.clear(); + int sectionX = SectionPos.blockToSectionCoord(pos.getX()); + int sectionY = SectionPos.blockToSectionCoord(pos.getY()); + int sectionZ = SectionPos.blockToSectionCoord(pos.getZ()); + for (int i = 0; i < sectionCount; i++) { + sections.add(SectionPos.asLong(sectionX, sectionY - i, sectionZ)); + } + // Will be null during initialization + if (lightSections != null) { + updateSections(); + } + } + } + } + + public void updateSections() { + lightSections.sections(sections); + } + + public void update() { + mutablePos.set(pos); + + for (int i = 0; i < data.size(); i++) { + int blockLight = level.getBrightness(LightLayer.BLOCK, mutablePos); + int skyLight = level.getBrightness(LightLayer.SKY, mutablePos); + int light = ((skyLight << 4) & 0xF) | (blockLight & 0xF); + data.set(i, (byte) light); + mutablePos.move(Direction.DOWN); + } + } + + public int getPackedLight(int offset) { + if (offset < 0 || offset >= data.size()) { + return 0; + } + + int light = Byte.toUnsignedInt(data.getByte(offset)); + int blockLight = light & 0xF; + int skyLight = (light >>> 4) & 0xF; + return LightTexture.pack(blockLight, skyLight); + } + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/HosePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/HosePulleyInstance.java deleted file mode 100644 index 862954199b..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/HosePulleyInstance.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.simibubi.create.content.contraptions.pulley; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.materials.oriented.OrientedData; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.fluids.hosePulley.HosePulleyBlockEntity; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -public class HosePulleyInstance extends AbstractPulleyInstance { - - public HosePulleyInstance(MaterialManager dispatcher, HosePulleyBlockEntity blockEntity) { - super(dispatcher, blockEntity); - } - - protected Instancer getRopeModel() { - return getOrientedMaterial().getModel(AllPartialModels.HOSE, blockState); - } - - protected Instancer getMagnetModel() { - return materialManager.defaultCutout() - .material(Materials.ORIENTED) - .getModel(AllPartialModels.HOSE_MAGNET, blockState); - } - - protected Instancer getHalfMagnetModel() { - return materialManager.defaultCutout() - .material(Materials.ORIENTED) - .getModel(AllPartialModels.HOSE_HALF_MAGNET, blockState); - } - - protected Instancer getCoilModel() { - return getOrientedMaterial().getModel(AllPartialModels.HOSE_COIL, blockState, rotatingAbout); - } - - protected Instancer getHalfRopeModel() { - return getOrientedMaterial().getModel(AllPartialModels.HOSE_HALF, blockState); - } - - protected float getOffset() { - return blockEntity.getInterpolatedOffset(AnimationTickHolder.getPartialTicks()); - } - - protected boolean isRunning() { - return true; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/HosePulleyVisual.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/HosePulleyVisual.java new file mode 100644 index 0000000000..7857e22dbe --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/pulley/HosePulleyVisual.java @@ -0,0 +1,51 @@ +package com.simibubi.create.content.contraptions.pulley; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.fluids.hosePulley.HosePulleyBlockEntity; + +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.OrientedInstance; +import dev.engine_room.flywheel.lib.model.Models; + +public class HosePulleyVisual extends AbstractPulleyVisual { + public HosePulleyVisual(VisualizationContext dispatcher, HosePulleyBlockEntity blockEntity, float partialTick) { + super(dispatcher, blockEntity, partialTick); + } + + @Override + protected Instancer getRopeModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.HOSE)); + } + + @Override + protected Instancer getMagnetModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.HOSE_MAGNET)); + } + + @Override + protected Instancer getHalfMagnetModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.HOSE_HALF_MAGNET)); + } + + @Override + protected Instancer getCoilModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.HOSE_COIL, rotatingAbout)); + } + + @Override + protected Instancer getHalfRopeModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.HOSE_HALF)); + } + + @Override + protected float getOffset(float pt) { + return blockEntity.getInterpolatedOffset(pt); + } + + @Override + protected boolean isRunning() { + return true; + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyContraption.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyContraption.java index cc4eb19a45..8310a4cae6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyContraption.java @@ -3,18 +3,15 @@ package com.simibubi.create.content.contraptions.pulley; import com.simibubi.create.content.contraptions.AssemblyException; import com.simibubi.create.content.contraptions.ContraptionType; import com.simibubi.create.content.contraptions.TranslatingContraption; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; public class PulleyContraption extends TranslatingContraption { int initialOffset; - + @Override public ContraptionType getType() { return ContraptionType.PULLEY; @@ -57,13 +54,7 @@ public class PulleyContraption extends TranslatingContraption { super.readNBT(world, nbt, spawnData); } - @Override - @OnlyIn(Dist.CLIENT) - public ContraptionLighter makeLighter() { - return new PulleyLighter(this); - } - - public int getInitialOffset() { + public int getInitialOffset() { return initialOffset; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyLighter.java deleted file mode 100644 index b9a5a13e97..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyLighter.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.simibubi.create.content.contraptions.pulley; - -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; - -public class PulleyLighter extends ContraptionLighter { - public PulleyLighter(PulleyContraption contraption) { - super(contraption); - } - - @Override - public GridAlignedBB getContraptionBounds() { - - GridAlignedBB bounds = GridAlignedBB.from(contraption.bounds); - - Level world = contraption.entity.level(); - - BlockPos.MutableBlockPos pos = contraption.anchor.mutable(); - while (!AllBlocks.ROPE_PULLEY.has(world.getBlockState(pos)) && pos.getY() < world.getMaxBuildHeight()) - pos.move(0, 1, 0); - - bounds.translate(pos); - bounds.setMinY(world.getMinBuildHeight()); - return bounds; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyRenderer.java index 0be9e3c42a..0b201bc2eb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/pulley/PulleyRenderer.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.pulley; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.Direction.Axis; import net.minecraft.util.Mth; @@ -64,10 +64,10 @@ public class PulleyRenderer extends AbstractPulleyRenderer { return offset; } - + @Override public int getViewDistance() { return 128; } - + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyInstance.java deleted file mode 100644 index 70ce307ff7..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyInstance.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.simibubi.create.content.contraptions.pulley; - - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.materials.oriented.OrientedData; -import com.simibubi.create.AllBlocks; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -public class RopePulleyInstance extends AbstractPulleyInstance { - public RopePulleyInstance(MaterialManager materialManager, PulleyBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - protected Instancer getRopeModel() { - return getOrientedMaterial().getModel(AllBlocks.ROPE.getDefaultState()); - } - - protected Instancer getMagnetModel() { - return getOrientedMaterial().getModel(AllBlocks.PULLEY_MAGNET.getDefaultState()); - } - - protected Instancer getHalfMagnetModel() { - return getOrientedMaterial().getModel(AllPartialModels.ROPE_HALF_MAGNET, blockState); - } - - protected Instancer getCoilModel() { - return getOrientedMaterial().getModel(AllPartialModels.ROPE_COIL, blockState, rotatingAbout); - } - - protected Instancer getHalfRopeModel() { - return getOrientedMaterial().getModel(AllPartialModels.ROPE_HALF, blockState); - } - - protected float getOffset() { - float partialTicks = AnimationTickHolder.getPartialTicks(); - return PulleyRenderer.getBlockEntityOffset(partialTicks, blockEntity); - } - - protected boolean isRunning() { - return PulleyRenderer.isPulleyRunning(blockEntity); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyVisual.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyVisual.java new file mode 100644 index 0000000000..6b13def27f --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyVisual.java @@ -0,0 +1,53 @@ +package com.simibubi.create.content.contraptions.pulley; + + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.foundation.render.VirtualRenderHelper; + +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.OrientedInstance; +import dev.engine_room.flywheel.lib.model.Models; + +public class RopePulleyVisual extends AbstractPulleyVisual { + public RopePulleyVisual(VisualizationContext context, PulleyBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Instancer getRopeModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, VirtualRenderHelper.blockModel(AllBlocks.ROPE.getDefaultState())); + } + + @Override + protected Instancer getMagnetModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, VirtualRenderHelper.blockModel(AllBlocks.PULLEY_MAGNET.getDefaultState())); + } + + @Override + protected Instancer getHalfMagnetModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.ROPE_HALF_MAGNET)); + } + + @Override + protected Instancer getCoilModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.ROPE_COIL, rotatingAbout)); + } + + @Override + protected Instancer getHalfRopeModel() { + return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.ROPE_HALF)); + } + + @Override + protected float getOffset(float pt) { + return PulleyRenderer.getBlockEntityOffset(pt, blockEntity); + } + + @Override + protected boolean isRunning() { + return PulleyRenderer.isPulleyRunning(blockEntity); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/render/ActorInstance.java deleted file mode 100644 index ff37307d89..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ActorInstance.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; - -import net.minecraft.world.level.LightLayer; - -public abstract class ActorInstance { - protected final MaterialManager materialManager; - protected final VirtualRenderWorld simulationWorld; - protected final MovementContext context; - - public ActorInstance(MaterialManager materialManager, VirtualRenderWorld world, MovementContext context) { - this.materialManager = materialManager; - this.simulationWorld = world; - this.context = context; - } - - public void tick() { } - - public void beginFrame() { } - - protected int localBlockLight() { - return simulationWorld.getBrightness(LightLayer.BLOCK, context.localPos); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ActorVisual.java b/src/main/java/com/simibubi/create/content/contraptions/render/ActorVisual.java new file mode 100644 index 0000000000..99adac46d2 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/render/ActorVisual.java @@ -0,0 +1,49 @@ +package com.simibubi.create.content.contraptions.render; + +import com.simibubi.create.content.contraptions.behaviour.MovementContext; + +import dev.engine_room.flywheel.api.instance.InstancerProvider; +import dev.engine_room.flywheel.api.visual.Visual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.LightLayer; + +public abstract class ActorVisual implements Visual { + protected final VisualizationContext visualizationContext; + protected final InstancerProvider instancerProvider; + protected final BlockAndTintGetter simulationWorld; + protected final MovementContext context; + + private boolean deleted; + + public ActorVisual(VisualizationContext visualizationContext, BlockAndTintGetter world, MovementContext context) { + this.visualizationContext = visualizationContext; + this.instancerProvider = visualizationContext.instancerProvider(); + this.simulationWorld = world; + this.context = context; + } + + public void tick() { } + + public void beginFrame() { } + + protected int localBlockLight() { + return simulationWorld.getBrightness(LightLayer.BLOCK, context.localPos); + } + + @Override + public void update(float partialTick) { + } + + protected abstract void _delete(); + + @Override + public final void delete() { + if (deleted) { + return; + } + + _delete(); + deleted = true; + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionEntityRenderer.java index 9005060ae6..e19c50135b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionEntityRenderer.java @@ -1,17 +1,30 @@ package com.simibubi.create.content.contraptions.render; +import org.apache.commons.lang3.tuple.Pair; + import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.Contraption; +import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.foundation.render.BlockEntityRenderHelper; +import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class ContraptionEntityRenderer extends EntityRenderer { - public ContraptionEntityRenderer(EntityRendererProvider.Context context) { super(context); } @@ -22,7 +35,7 @@ public class ContraptionEntityRenderer exte } @Override - public boolean shouldRender(C entity, Frustum clippingHelper, double cameraX, double cameraY, + public boolean shouldRender(C entity, Frustum frustum, double cameraX, double cameraY, double cameraZ) { if (entity.getContraption() == null) return false; @@ -31,18 +44,71 @@ public class ContraptionEntityRenderer exte if (!entity.isReadyForRender()) return false; - return super.shouldRender(entity, clippingHelper, cameraX, cameraY, cameraZ); + return super.shouldRender(entity, frustum, cameraX, cameraY, cameraZ); } @Override - public void render(C entity, float yaw, float partialTicks, PoseStack ms, MultiBufferSource buffers, + public void render(C entity, float yaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffers, int overlay) { - super.render(entity, yaw, partialTicks, ms, buffers, overlay); + super.render(entity, yaw, partialTicks, poseStack, buffers, overlay); Contraption contraption = entity.getContraption(); - if (contraption != null) { - ContraptionRenderDispatcher.renderFromEntity(entity, contraption, buffers); + if (contraption == null) { + return; } + + Level level = entity.level(); + ContraptionRenderInfo renderInfo = ContraptionRenderInfo.get(contraption); + VirtualRenderWorld renderWorld = renderInfo.getRenderWorld(); + ContraptionMatrices matrices = renderInfo.getMatrices(); + matrices.setup(poseStack, entity); + + if (!VisualizationManager.supportsVisualization(level)) { + for (RenderType renderType : RenderType.chunkBufferLayers()) { + SuperByteBuffer sbb = renderInfo.getBuffer(renderType); + if (!sbb.isEmpty()) { + VertexConsumer vc = buffers.getBuffer(renderType); + sbb.transform(matrices.getModel()) + .useLevelLight(level, matrices.getWorld()) + .renderInto(poseStack, vc); + } + } + } + + renderBlockEntities(level, renderWorld, contraption, matrices, buffers); + renderActors(level, renderWorld, contraption, matrices, buffers); + + matrices.clear(); } + private static void renderBlockEntities(Level level, VirtualRenderWorld renderWorld, Contraption c, + ContraptionMatrices matrices, MultiBufferSource buffer) { + BlockEntityRenderHelper.renderBlockEntities(level, renderWorld, c.getRenderedBEs(), + matrices.getModelViewProjection(), matrices.getLight(), buffer); + } + + private static void renderActors(Level level, VirtualRenderWorld renderWorld, Contraption c, + ContraptionMatrices matrices, MultiBufferSource buffer) { + PoseStack m = matrices.getModel(); + + for (Pair actor : c.getActors()) { + MovementContext context = actor.getRight(); + if (context == null) + continue; + if (context.world == null) + context.world = level; + StructureTemplate.StructureBlockInfo blockInfo = actor.getLeft(); + + MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state()); + if (movementBehaviour != null) { + if (c.isHiddenInPortal(blockInfo.pos())) + continue; + m.pushPose(); + TransformStack.of(m) + .translate(blockInfo.pos()); + movementBehaviour.renderInContraption(context, renderWorld, matrices, buffer); + m.popPose(); + } + } + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionGroup.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionGroup.java deleted file mode 100644 index 17a92c8800..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionGroup.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup; -import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; - -import net.minecraft.client.renderer.RenderType; - -public class ContraptionGroup

extends InstancedMaterialGroup

{ - - private final FlwContraption contraption; - - public ContraptionGroup(FlwContraption contraption, InstancingEngine

owner, RenderType type) { - super(owner, type); - - this.contraption = contraption; - } - - @Override - protected void setup(P program) { - contraption.setup(program); - } - - public static

InstancingEngine.GroupFactory

forContraption(FlwContraption c) { - return (materialManager, type) -> new ContraptionGroup<>(c, materialManager, type); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionInstanceManager.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionInstanceManager.java deleted file mode 100644 index b38ab41cd0..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionInstanceManager.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import java.util.ArrayList; - -import javax.annotation.Nullable; - -import org.apache.commons.lang3.tuple.Pair; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.TaskEngine; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.simibubi.create.AllMovementBehaviours; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; - -import net.minecraft.client.Camera; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; - -public class ContraptionInstanceManager extends BlockEntityInstanceManager { - - protected ArrayList actors = new ArrayList<>(); - - private final VirtualRenderWorld renderWorld; - - private Contraption contraption; - - ContraptionInstanceManager(MaterialManager materialManager, VirtualRenderWorld renderWorld, Contraption contraption) { - super(materialManager); - this.renderWorld = renderWorld; - this.contraption = contraption; - } - - public void tick() { - actors.forEach(ActorInstance::tick); - } - - @Override - protected boolean canCreateInstance(BlockEntity blockEntity) { - return !contraption.isHiddenInPortal(blockEntity.getBlockPos()); - } - - @Override - public void beginFrame(TaskEngine taskEngine, Camera info) { - super.beginFrame(taskEngine, info); - - actors.forEach(ActorInstance::beginFrame); - } - - @Override - protected void updateInstance(DynamicInstance dyn, float lookX, float lookY, float lookZ, int cX, int cY, int cZ) { - dyn.beginFrame(); - } - - @Nullable - public ActorInstance createActor(Pair actor) { - StructureBlockInfo blockInfo = actor.getLeft(); - MovementContext context = actor.getRight(); - - if (contraption.isHiddenInPortal(context.localPos)) - return null; - - MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state()); - - if (movementBehaviour != null && movementBehaviour.hasSpecialInstancedRendering()) { - ActorInstance instance = movementBehaviour.createInstance(materialManager, renderWorld, context); - - actors.add(instance); - - return instance; - } - - return null; - } - - @Override - public void detachLightListeners() { - // noop, no light updater for contraption levels - } -} - diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionLighter.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionLighter.java deleted file mode 100644 index e917aeb631..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionLighter.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import com.jozufozu.flywheel.light.GPULightVolume; -import com.jozufozu.flywheel.light.LightListener; -import com.jozufozu.flywheel.light.LightUpdater; -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.jozufozu.flywheel.util.box.ImmutableBox; -import com.simibubi.create.content.contraptions.Contraption; - -import net.minecraft.world.level.LightLayer; - -public abstract class ContraptionLighter implements LightListener { - protected final C contraption; - public final GPULightVolume lightVolume; - protected final LightUpdater lightUpdater; - - protected final GridAlignedBB bounds; - - protected boolean scheduleRebuild; - - protected ContraptionLighter(C contraption) { - this.contraption = contraption; - lightUpdater = LightUpdater.get(contraption.entity.level()); - - bounds = getContraptionBounds(); - growBoundsForEdgeData(bounds); - - lightVolume = new GPULightVolume(contraption.entity.level(), bounds); - - lightVolume.initialize(); - scheduleRebuild = true; - - lightUpdater.addListener(this); - } - - public abstract GridAlignedBB getContraptionBounds(); - - @Override - public boolean isListenerInvalid() { - return lightVolume.isListenerInvalid(); - } - - @Override - public void onLightUpdate(LightLayer type, ImmutableBox changed) { - lightVolume.onLightUpdate(type, changed); - } - - @Override - public void onLightPacket(int chunkX, int chunkZ) { - lightVolume.onLightPacket(chunkX, chunkZ); - } - - protected static void growBoundsForEdgeData(GridAlignedBB bounds) { - // so we have at least enough data on the edges to avoid artifacts and have smooth lighting - bounds.grow(2); - } - - @Override - public ImmutableBox getVolume() { - return bounds; - } - - public void delete() { - lightUpdater.removeListener(this); - lightVolume.delete(); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionMatrices.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionMatrices.java index 2bee34e8d4..c7584bdf79 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionMatrices.java +++ b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionMatrices.java @@ -22,9 +22,7 @@ public class ContraptionMatrices { private final Matrix4f world = new Matrix4f(); private final Matrix4f light = new Matrix4f(); - private boolean ready; - - public void setup(PoseStack viewProjection, AbstractContraptionEntity entity) { + void setup(PoseStack viewProjection, AbstractContraptionEntity entity) { float partialTicks = AnimationTickHolder.getPartialTicks(); this.viewProjection.pushPose(); @@ -41,17 +39,14 @@ public class ContraptionMatrices { light.set(world); light.mul(model.last() .pose()); - - ready = true; } - public void clear() { + void clear() { clearStack(modelViewProjection); clearStack(viewProjection); clearStack(model); world.identity(); light.identity(); - ready = false; } public PoseStack getModelViewProjection() { @@ -74,10 +69,6 @@ public class ContraptionMatrices { return light; } - public boolean isReady() { - return ready; - } - public static void transform(PoseStack ms, PoseStack transform) { ms.last() .pose() diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionProgram.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionProgram.java deleted file mode 100644 index c1eb10ad26..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionProgram.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import org.joml.Matrix4f; -import org.lwjgl.opengl.GL20; - -import com.jozufozu.flywheel.core.shader.WorldProgram; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.phys.AABB; - -public class ContraptionProgram extends WorldProgram { - 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, AABB 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); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderDispatcher.java deleted file mode 100644 index eb41e43f58..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderDispatcher.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import java.util.Collection; - -import org.apache.commons.lang3.tuple.Pair; - -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.gl.error.GlError; -import com.jozufozu.flywheel.config.BackendType; -import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferedData; -import com.jozufozu.flywheel.core.model.WorldModelBuilder; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.event.BeginFrameEvent; -import com.jozufozu.flywheel.event.GatherContextEvent; -import com.jozufozu.flywheel.event.ReloadRenderersEvent; -import com.jozufozu.flywheel.event.RenderLayerEvent; -import com.jozufozu.flywheel.util.WorldAttached; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.AllMovementBehaviours; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.ContraptionWorld; -import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; -import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.foundation.render.BlockEntityRenderHelper; -import com.simibubi.create.foundation.render.SuperByteBuffer; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LightLayer; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; - -@OnlyIn(Dist.CLIENT) -@Mod.EventBusSubscriber(Dist.CLIENT) -public class ContraptionRenderDispatcher { - - private static WorldAttached> WORLDS = new WorldAttached<>(SBBContraptionManager::new); - - /** - * Reset a contraption's renderer. - * - * @param contraption The contraption to invalidate. - * @return true if there was a renderer associated with the given contraption. - */ - public static boolean invalidate(Contraption contraption) { - Level level = contraption.entity.level(); - - return WORLDS.get(level) - .invalidate(contraption); - } - - public static void tick(Level world) { - if (Minecraft.getInstance() - .isPaused()) - return; - - WORLDS.get(world) - .tick(); - } - - @SubscribeEvent - public static void beginFrame(BeginFrameEvent event) { - WORLDS.get(event.getWorld()) - .beginFrame(event); - } - - @SubscribeEvent - public static void renderLayer(RenderLayerEvent event) { - WORLDS.get(event.getWorld()) - .renderLayer(event); - - GlError.pollAndThrow(() -> "contraption layer: " + event.getLayer()); - } - - @SubscribeEvent - public static void onRendererReload(ReloadRenderersEvent event) { - reset(); - } - - public static void gatherContext(GatherContextEvent e) { - reset(); - } - - public static void renderFromEntity(AbstractContraptionEntity entity, Contraption contraption, - MultiBufferSource buffers) { - Level world = entity.level(); - - ContraptionRenderInfo renderInfo = WORLDS.get(world) - .getRenderInfo(contraption); - ContraptionMatrices matrices = renderInfo.getMatrices(); - - // something went wrong with the other rendering - if (!matrices.isReady()) - return; - - VirtualRenderWorld renderWorld = renderInfo.renderWorld; - - renderBlockEntities(world, renderWorld, contraption, matrices, buffers); - - if (buffers instanceof MultiBufferSource.BufferSource) - ((MultiBufferSource.BufferSource) buffers).endBatch(); - - renderActors(world, renderWorld, contraption, matrices, buffers); - } - - public static VirtualRenderWorld setupRenderWorld(Level world, Contraption c) { - ContraptionWorld contraptionWorld = c.getContraptionWorld(); - - BlockPos origin = c.anchor; - int minBuildHeight = contraptionWorld.getMinBuildHeight(); - int height = contraptionWorld.getHeight(); - VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, minBuildHeight, height, origin) { - @Override - public boolean supportsFlywheel() { - return canInstance(); - } - }; - - renderWorld.setBlockEntities(c.presentBlockEntities.values()); - for (StructureTemplate.StructureBlockInfo info : c.getBlocks() - .values()) - // Skip individual lighting updates to prevent lag with large contraptions - // FIXME 1.20 this '0' used to be Block.UPDATE_SUPPRESS_LIGHT, yet VirtualRenderWorld didn't actually parse the flags at all - renderWorld.setBlock(info.pos(), info.state(), 0); - - renderWorld.runLightEngine(); - return renderWorld; - } - - public static void renderBlockEntities(Level world, VirtualRenderWorld renderWorld, Contraption c, - ContraptionMatrices matrices, MultiBufferSource buffer) { - BlockEntityRenderHelper.renderBlockEntities(world, renderWorld, c.getSpecialRenderedBEs(), - matrices.getModelViewProjection(), matrices.getLight(), buffer); - } - - protected static void renderActors(Level world, VirtualRenderWorld renderWorld, Contraption c, - ContraptionMatrices matrices, MultiBufferSource buffer) { - PoseStack m = matrices.getModel(); - - for (Pair actor : c.getActors()) { - MovementContext context = actor.getRight(); - if (context == null) - continue; - if (context.world == null) - context.world = world; - StructureTemplate.StructureBlockInfo blockInfo = actor.getLeft(); - - MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state()); - if (movementBehaviour != null) { - if (c.isHiddenInPortal(blockInfo.pos())) - continue; - m.pushPose(); - TransformStack.cast(m) - .translate(blockInfo.pos()); - movementBehaviour.renderInContraption(context, renderWorld, matrices, buffer); - m.popPose(); - } - } - } - - public static SuperByteBuffer buildStructureBuffer(VirtualRenderWorld renderWorld, Contraption c, - RenderType layer) { - Collection values = c.getRenderedBlocks(); - ShadeSeparatedBufferedData data = new WorldModelBuilder(layer).withRenderWorld(renderWorld) - .withBlocks(values) - .withModelData(c.modelData) - .build(); - SuperByteBuffer sbb = new SuperByteBuffer(data); - data.release(); - return sbb; - } - - public static int getLight(Level world, float lx, float ly, float lz) { - BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); - float block = 0, sky = 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.set(lx + xOffset, ly + yOffset, lz + zOffset); - block += world.getBrightness(LightLayer.BLOCK, pos) / 8f; - sky += world.getBrightness(LightLayer.SKY, pos) / 8f; - } - - return LightTexture.pack((int) block, (int) sky); - } - - public static int getContraptionWorldLight(MovementContext context, VirtualRenderWorld renderWorld) { - return LevelRenderer.getLightColor(renderWorld, context.localPos); - } - - public static void reset() { - WORLDS.empty(ContraptionRenderingWorld::delete); - - if (Backend.isOn()) { - WORLDS = new WorldAttached<>(FlwContraptionManager::new); - } else { - WORLDS = new WorldAttached<>(SBBContraptionManager::new); - } - } - - public static boolean canInstance() { - return Backend.getBackendType() == BackendType.INSTANCING; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderInfo.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderInfo.java index ff3ebf3e3c..1979d80011 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderInfo.java +++ b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderInfo.java @@ -1,77 +1,144 @@ package com.simibubi.create.content.contraptions.render; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.event.BeginFrameEvent; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.foundation.utility.AnimationTickHolder; +import org.apache.commons.lang3.tuple.Pair; -import net.minecraft.util.Mth; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.CreateClient; +import com.simibubi.create.content.contraptions.Contraption; +import com.simibubi.create.content.contraptions.Contraption.RenderedBlocks; +import com.simibubi.create.content.contraptions.ContraptionWorld; +import com.simibubi.create.foundation.render.ShadedBlockSbbBuilder; +import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.SuperByteBufferCache; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; + +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.ModelUtil; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.block.ModelBlockRenderer; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; +import net.minecraftforge.client.model.data.ModelData; public class ContraptionRenderInfo { - public final Contraption contraption; - public final VirtualRenderWorld renderWorld; + public static final SuperByteBufferCache.Compartment> CONTRAPTION = new SuperByteBufferCache.Compartment<>(); + private static final ThreadLocal THREAD_LOCAL_OBJECTS = ThreadLocal.withInitial(ThreadLocalObjects::new); + private final Contraption contraption; + private final VirtualRenderWorld renderWorld; private final ContraptionMatrices matrices = new ContraptionMatrices(); - private boolean visible; - public ContraptionRenderInfo(Contraption contraption, VirtualRenderWorld renderWorld) { + ContraptionRenderInfo(Level level, Contraption contraption) { this.contraption = contraption; - this.renderWorld = renderWorld; + this.renderWorld = setupRenderWorld(level, contraption); } - public int getEntityId() { - return contraption.entity.getId(); + public static ContraptionRenderInfo get(Contraption contraption) { + return ContraptionRenderInfoManager.MANAGERS.get(contraption.entity.level()).getRenderInfo(contraption); + } + + /** + * Reset a contraption's renderer. + * + * @param contraption The contraption to invalidate. + * @return true if there was a renderer associated with the given contraption. + */ + public static boolean invalidate(Contraption contraption) { + return ContraptionRenderInfoManager.MANAGERS.get(contraption.entity.level()).invalidate(contraption); } public boolean isDead() { return !contraption.entity.isAliveOrStale(); } - public void beginFrame(BeginFrameEvent event) { - matrices.clear(); - - AbstractContraptionEntity entity = contraption.entity; - - visible = event.getFrustum() - .isVisible(entity.getBoundingBoxForCulling() - .inflate(2)); + public Contraption getContraption() { + return contraption; } - public boolean isVisible() { - return visible && contraption.entity.isAliveOrStale() && contraption.entity.isReadyForRender(); + public VirtualRenderWorld getRenderWorld() { + return renderWorld; } - /** - * Need to call this during RenderLayerEvent. - */ - public void setupMatrices(PoseStack viewProjection, double camX, double camY, double camZ) { - if (!matrices.isReady()) { - AbstractContraptionEntity entity = contraption.entity; - - viewProjection.pushPose(); - - double x = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.xOld, entity.getX()) - camX; - double y = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.yOld, entity.getY()) - camY; - double z = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.zOld, entity.getZ()) - camZ; - - viewProjection.translate(x, y, z); - - matrices.setup(viewProjection, entity); - - viewProjection.popPose(); - } - } - - /** - * If #setupMatrices is called correctly, the returned matrices will be ready - */ public ContraptionMatrices getMatrices() { return matrices; } - public void invalidate() { + public SuperByteBuffer getBuffer(RenderType renderType) { + return CreateClient.BUFFER_CACHE.get(CONTRAPTION, Pair.of(contraption, renderType), () -> buildStructureBuffer(renderType)); + } + public void invalidate() { + for (RenderType renderType : RenderType.chunkBufferLayers()) { + CreateClient.BUFFER_CACHE.invalidate(CONTRAPTION, Pair.of(contraption, renderType)); + } + } + + public static VirtualRenderWorld setupRenderWorld(Level level, Contraption c) { + ContraptionWorld contraptionWorld = c.getContraptionWorld(); + + BlockPos origin = c.anchor; + int minBuildHeight = contraptionWorld.getMinBuildHeight(); + int height = contraptionWorld.getHeight(); + VirtualRenderWorld renderWorld = new VirtualRenderWorld(level, minBuildHeight, height, origin) { + @Override + public boolean supportsVisualization() { + return VisualizationManager.supportsVisualization(level); + } + }; + + renderWorld.setBlockEntities(c.presentBlockEntities.values()); + for (StructureTemplate.StructureBlockInfo info : c.getBlocks() + .values()) + renderWorld.setBlock(info.pos(), info.state(), 0); + + renderWorld.runLightEngine(); + return renderWorld; + } + + private SuperByteBuffer buildStructureBuffer(RenderType layer) { + BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER; + ModelBlockRenderer renderer = dispatcher.getModelRenderer(); + ThreadLocalObjects objects = THREAD_LOCAL_OBJECTS.get(); + + PoseStack poseStack = objects.poseStack; + RandomSource random = objects.random; + RenderedBlocks blocks = contraption.getRenderedBlocks(); + + ShadedBlockSbbBuilder sbbBuilder = objects.sbbBuilder; + sbbBuilder.begin(); + + ModelBlockRenderer.enableCaching(); + for (BlockPos pos : blocks.positions()) { + BlockState state = blocks.lookup().apply(pos); + if (state.getRenderShape() == RenderShape.MODEL) { + BakedModel model = dispatcher.getBlockModel(state); + ModelData modelData = contraption.modelData.getOrDefault(pos, ModelData.EMPTY); + modelData = model.getModelData(renderWorld, pos, state, modelData); + long randomSeed = state.getSeed(pos); + random.setSeed(randomSeed); + if (model.getRenderTypes(state, random, modelData).contains(layer)) { + poseStack.pushPose(); + poseStack.translate(pos.getX(), pos.getY(), pos.getZ()); + renderer.tesselateBlock(renderWorld, model, state, pos, poseStack, sbbBuilder, true, random, randomSeed, OverlayTexture.NO_OVERLAY, modelData, layer); + poseStack.popPose(); + } + } + } + ModelBlockRenderer.clearCache(); + + return sbbBuilder.end(); + } + + private static class ThreadLocalObjects { + public final PoseStack poseStack = new PoseStack(); + public final RandomSource random = RandomSource.createNewThreadLocalInstance(); + public final ShadedBlockSbbBuilder sbbBuilder = new ShadedBlockSbbBuilder(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderInfoManager.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderInfoManager.java new file mode 100644 index 0000000000..81ab6c4b36 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderInfoManager.java @@ -0,0 +1,84 @@ +package com.simibubi.create.content.contraptions.render; + +import com.simibubi.create.content.contraptions.Contraption; +import com.simibubi.create.foundation.utility.WorldAttached; + +import dev.engine_room.flywheel.api.event.ReloadLevelRendererEvent; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import net.minecraft.client.Minecraft; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; + +@EventBusSubscriber(Dist.CLIENT) +public class ContraptionRenderInfoManager { + static final WorldAttached MANAGERS = new WorldAttached<>(ContraptionRenderInfoManager::new); + + private final Level level; + private final Int2ObjectMap renderInfos = new Int2ObjectOpenHashMap<>(); + private int removalTimer; + + private ContraptionRenderInfoManager(LevelAccessor level) { + this.level = (Level) level; + } + + public static void tickFor(Level level) { + if (Minecraft.getInstance() + .isPaused()) + return; + + MANAGERS.get(level) + .tick(); + } + + public static void resetAll() { + MANAGERS.empty(ContraptionRenderInfoManager::delete); + } + + @SubscribeEvent + public static void onReloadLevelRenderer(ReloadLevelRendererEvent event) { + resetAll(); + } + + ContraptionRenderInfo getRenderInfo(Contraption contraption) { + int entityId = contraption.entity.getId(); + ContraptionRenderInfo renderInfo = renderInfos.get(entityId); + + if (renderInfo == null) { + renderInfo = new ContraptionRenderInfo(level, contraption); + renderInfos.put(entityId, renderInfo); + } + + return renderInfo; + } + + boolean invalidate(Contraption contraption) { + int entityId = contraption.entity.getId(); + ContraptionRenderInfo renderInfo = renderInfos.remove(entityId); + + if (renderInfo != null) { + renderInfo.invalidate(); + return true; + } + + return false; + } + + private void tick() { + if (removalTimer >= 20) { + renderInfos.values().removeIf(ContraptionRenderInfo::isDead); + removalTimer = 0; + } + removalTimer++; + } + + private void delete() { + for (ContraptionRenderInfo renderer : renderInfos.values()) { + renderer.invalidate(); + } + renderInfos.clear(); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderingWorld.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderingWorld.java deleted file mode 100644 index de71b0d941..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionRenderingWorld.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import java.lang.ref.Reference; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import com.jozufozu.flywheel.event.BeginFrameEvent; -import com.jozufozu.flywheel.event.RenderLayerEvent; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.contraptions.ContraptionHandler; - -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; - -public abstract class ContraptionRenderingWorld { - protected final Level world; - - private int removalTimer; - - protected final Int2ObjectMap renderInfos = new Int2ObjectOpenHashMap<>(); - protected final List visible = new ObjectArrayList<>(); - - public ContraptionRenderingWorld(LevelAccessor world) { - this.world = (Level) world; - } - - public boolean invalidate(Contraption contraption) { - int entityId = contraption.entity.getId(); - - C removed = renderInfos.remove(entityId); - - if (removed != null) { - removed.invalidate(); - visible.remove(removed); - return true; - } - - return false; - } - - public void renderLayer(RenderLayerEvent event) { - for (C c : visible) { - c.setupMatrices(event.stack, event.camX, event.camY, event.camZ); - } - } - - protected abstract C create(Contraption c); - - public void tick() { - removalTimer++; - if (removalTimer >= 20) { - removeDeadRenderers(); - removalTimer = 0; - } - - ContraptionHandler.loadedContraptions.get(world) - .values() - .stream() - .map(Reference::get) - .filter(Objects::nonNull) - .map(AbstractContraptionEntity::getContraption) - .filter(Objects::nonNull) // contraptions that are too large will not be synced, and un-synced contraptions will be null - .forEach(this::getRenderInfo); - } - - public void beginFrame(BeginFrameEvent event) { - - renderInfos.int2ObjectEntrySet() - .stream() - .map(Map.Entry::getValue) - .forEach(renderInfo -> renderInfo.beginFrame(event)); - - collectVisible(); - } - - protected void collectVisible() { - visible.clear(); - renderInfos.int2ObjectEntrySet() - .stream() - .map(Map.Entry::getValue) - .filter(ContraptionRenderInfo::isVisible) - .forEach(visible::add); - } - - public C getRenderInfo(Contraption c) { - int entityId = c.entity.getId(); - C renderInfo = renderInfos.get(entityId); - - if (renderInfo == null) { - renderInfo = create(c); - renderInfos.put(entityId, renderInfo); - } - - return renderInfo; - } - - public void delete() { - for (C renderer : renderInfos.values()) { - renderer.invalidate(); - } - renderInfos.clear(); - } - - /** - * Remove all render infos associated with dead/removed contraptions. - */ - public void removeDeadRenderers() { - renderInfos.values().removeIf(ContraptionRenderInfo::isDead); - } - -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionVisual.java b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionVisual.java new file mode 100644 index 0000000000..6b3a038c98 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/render/ContraptionVisual.java @@ -0,0 +1,282 @@ +package com.simibubi.create.content.contraptions.render; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.tuple.MutablePair; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.AllMovementBehaviours; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.Contraption; +import com.simibubi.create.content.contraptions.Contraption.RenderedBlocks; +import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.foundation.utility.worldWrappers.WrappedBlockAndTintGetter; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.task.Plan; +import dev.engine_room.flywheel.api.visual.BlockEntityVisual; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visual.LightUpdatedVisual; +import dev.engine_room.flywheel.api.visual.ShaderLightVisual; +import dev.engine_room.flywheel.api.visual.TickableVisual; +import dev.engine_room.flywheel.api.visualization.BlockEntityVisualizer; +import dev.engine_room.flywheel.api.visualization.VisualEmbedding; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.api.visualization.VisualizerRegistry; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.baked.ForgeMultiBlockModelBuilder; +import dev.engine_room.flywheel.lib.task.ForEachPlan; +import dev.engine_room.flywheel.lib.task.NestedPlan; +import dev.engine_room.flywheel.lib.task.PlanMap; +import dev.engine_room.flywheel.lib.task.RunnablePlan; +import dev.engine_room.flywheel.lib.visual.AbstractEntityVisual; +import it.unimi.dsi.fastutil.longs.LongArraySet; +import it.unimi.dsi.fastutil.longs.LongSet; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.core.Vec3i; +import net.minecraft.util.Mth; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; +import net.minecraftforge.client.model.data.ModelData; + +public class ContraptionVisual extends AbstractEntityVisual implements DynamicVisual, TickableVisual, LightUpdatedVisual, ShaderLightVisual { + protected static final int LIGHT_PADDING = 1; + + protected final VisualEmbedding embedding; + protected final List> children = new ArrayList<>(); + protected final List actors = new ArrayList<>(); + protected final PlanMap dynamicVisuals = new PlanMap<>(); + protected final PlanMap tickableVisuals = new PlanMap<>(); + protected VirtualRenderWorld virtualRenderWorld; + protected Model model; + protected TransformedInstance structure; + protected SectionCollector sectionCollector; + protected long minSection, maxSection; + protected long minBlock, maxBlock; + + private final PoseStack contraptionMatrix = new PoseStack(); + + public ContraptionVisual(VisualizationContext ctx, E entity, float partialTick) { + super(ctx, entity, partialTick); + embedding = ctx.createEmbedding(Vec3i.ZERO); + + init(partialTick); + } + + protected void init(float partialTick) { + setEmbeddingMatrices(partialTick); + + Contraption contraption = entity.getContraption(); + virtualRenderWorld = ContraptionRenderInfo.setupRenderWorld(level, contraption); + + RenderedBlocks blocks = contraption.getRenderedBlocks(); + BlockAndTintGetter modelWorld = new WrappedBlockAndTintGetter(virtualRenderWorld) { + @Override + public BlockState getBlockState(BlockPos pos) { + return blocks.lookup().apply(pos); + } + }; + + model = new ForgeMultiBlockModelBuilder(modelWorld, blocks.positions()) + .modelDataLookup(pos -> contraption.modelData.getOrDefault(pos, ModelData.EMPTY)) + .build(); + + structure = embedding.instancerProvider() + .instancer(InstanceTypes.TRANSFORMED, model) + .createInstance(); + + for (BlockEntity be : contraption.getRenderedBEs()) { + setupVisualizer(be, partialTick); + } + + for (var actor : contraption.getActors()) { + setupActor(actor, partialTick); + } + } + + @SuppressWarnings("unchecked") + protected void setupVisualizer(T be, float partialTicks) { + BlockEntityVisualizer visualizer = (BlockEntityVisualizer) VisualizerRegistry.getVisualizer(be.getType()); + if (visualizer == null) { + return; + } + + Level level = be.getLevel(); + be.setLevel(virtualRenderWorld); + BlockEntityVisual visual = visualizer.createVisual(this.embedding, be, partialTicks); + + children.add(visual); + + if (visual instanceof DynamicVisual dynamic) { + dynamicVisuals.add(dynamic, dynamic.planFrame()); + } + + if (visual instanceof TickableVisual tickable) { + tickableVisuals.add(tickable, tickable.planTick()); + } + + be.setLevel(level); + } + + private void setupActor(MutablePair actor, float partialTick) { + MovementContext context = actor.getRight(); + if (context == null) { + return; + } + if (context.world == null) { + context.world = level; + } + + StructureTemplate.StructureBlockInfo blockInfo = actor.getLeft(); + + MovementBehaviour movementBehaviour = AllMovementBehaviours.getBehaviour(blockInfo.state()); + if (movementBehaviour == null) { + return; + } + var visual = movementBehaviour.createVisual(this.embedding, virtualRenderWorld, context); + + if (visual == null) { + return; + } + + actors.add(visual); + } + + @Override + public Plan planTick() { + return NestedPlan.of( + ForEachPlan.of(() -> actors, ActorVisual::tick), + tickableVisuals + ); + } + + @Override + public Plan planFrame() { + return NestedPlan.of( + RunnablePlan.of(this::beginFrame), + ForEachPlan.of(() -> actors, ActorVisual::beginFrame), + dynamicVisuals + ); + } + + protected void beginFrame(DynamicVisual.Context context) { + var partialTick = context.partialTick(); + setEmbeddingMatrices(partialTick); + + if (hasMovedSections()) { + sectionCollector.sections(collectLightSections()); + } + + if (hasMovedBlocks()) { + updateLight(partialTick); + } + } + + private void setEmbeddingMatrices(float partialTick) { + double x = Mth.lerp(partialTick, entity.xOld, entity.getX()); + double y = Mth.lerp(partialTick, entity.yOld, entity.getY()); + double z = Mth.lerp(partialTick, entity.zOld, entity.getZ()); + + contraptionMatrix.setIdentity(); + contraptionMatrix.translate(x, y, z); + entity.applyLocalTransforms(contraptionMatrix, partialTick); + + embedding.transforms(contraptionMatrix.last().pose(), contraptionMatrix.last().normal()); + } + + @Override + public void updateLight(float partialTick) { + } + + public LongSet collectLightSections() { + var boundingBox = entity.getBoundingBox(); + + var minSectionX = minLightSection(boundingBox.minX); + var minSectionY = minLightSection(boundingBox.minY); + var minSectionZ = minLightSection(boundingBox.minZ); + int maxSectionX = maxLightSection(boundingBox.maxX); + int maxSectionY = maxLightSection(boundingBox.maxY); + int maxSectionZ = maxLightSection(boundingBox.maxZ); + + minSection = SectionPos.asLong(minSectionX, minSectionY, minSectionZ); + maxSection = SectionPos.asLong(maxSectionX, maxSectionY, maxSectionZ); + + LongSet longSet = new LongArraySet(); + + for (int x = 0; x <= maxSectionX - minSectionX; x++) { + for (int y = 0; y <= maxSectionY - minSectionY; y++) { + for (int z = 0; z <= maxSectionZ - minSectionZ; z++) { + longSet.add(SectionPos.offset(minSection, x, y, z)); + } + } + } + + return longSet; + } + + protected boolean hasMovedBlocks() { + var boundingBox = entity.getBoundingBox(); + + int minX = minLight(boundingBox.minX); + int minY = minLight(boundingBox.minY); + int minZ = minLight(boundingBox.minZ); + int maxX = maxLight(boundingBox.maxX); + int maxY = maxLight(boundingBox.maxY); + int maxZ = maxLight(boundingBox.maxZ); + + return minBlock != BlockPos.asLong(minX, minY, minZ) || maxBlock != BlockPos.asLong(maxX, maxY, maxZ); + } + + protected boolean hasMovedSections() { + var boundingBox = entity.getBoundingBox(); + + var minSectionX = minLightSection(boundingBox.minX); + var minSectionY = minLightSection(boundingBox.minY); + var minSectionZ = minLightSection(boundingBox.minZ); + int maxSectionX = maxLightSection(boundingBox.maxX); + int maxSectionY = maxLightSection(boundingBox.maxY); + int maxSectionZ = maxLightSection(boundingBox.maxZ); + + return minSection != SectionPos.asLong(minSectionX, minSectionY, minSectionZ) || maxSection != SectionPos.asLong(maxSectionX, maxSectionY, maxSectionZ); + } + + @Override + public void setSectionCollector(SectionCollector collector) { + this.sectionCollector = collector; + } + + @Override + protected void _delete() { + children.forEach(BlockEntityVisual::delete); + + actors.forEach(ActorVisual::delete); + + if (structure != null) { + structure.delete(); + } + } + + public static int minLight(double aabbPos) { + return Mth.floor(aabbPos) - LIGHT_PADDING; + } + + public static int maxLight(double aabbPos) { + return Mth.ceil(aabbPos) + LIGHT_PADDING; + } + + public static int minLightSection(double aabbPos) { + return SectionPos.blockToSectionCoord(minLight(aabbPos)); + } + + public static int maxLightSection(double aabbPos) { + return SectionPos.blockToSectionCoord(maxLight(aabbPos)); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/EmptyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/render/EmptyLighter.java deleted file mode 100644 index 6ff1e1bd8e..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/EmptyLighter.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.simibubi.create.content.contraptions.Contraption; - -// so other contraptions don't crash before they have a lighter -public class EmptyLighter extends ContraptionLighter { - public EmptyLighter(Contraption contraption) { - super(contraption); - } - - @Override - public GridAlignedBB getContraptionBounds() { - return new GridAlignedBB(0, 0, 0, 1, 1, 1); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/FlwContraption.java b/src/main/java/com/simibubi/create/content/contraptions/render/FlwContraption.java deleted file mode 100644 index 07dbd512cb..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/FlwContraption.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.joml.Matrix4f; - -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.gl.GlStateTracker; -import com.jozufozu.flywheel.backend.instancing.Engine; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; -import com.jozufozu.flywheel.backend.instancing.SerialTaskEngine; -import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine; -import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; -import com.jozufozu.flywheel.backend.model.ArrayModelRenderer; -import com.jozufozu.flywheel.core.model.Model; -import com.jozufozu.flywheel.core.model.WorldModelBuilder; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.event.BeginFrameEvent; -import com.jozufozu.flywheel.event.RenderLayerEvent; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.foundation.render.CreateContexts; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.client.renderer.RenderType; -import net.minecraft.util.Mth; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; - -public class FlwContraption extends ContraptionRenderInfo { - - private final ContraptionLighter lighter; - - private final Map renderLayers = new HashMap<>(); - - private final Matrix4f modelViewPartial = new Matrix4f(); - private final ContraptionInstanceWorld instanceWorld; - private boolean modelViewPartialReady; - // floats because we upload this to the gpu - private AABB lightBox; - - public FlwContraption(Contraption contraption, VirtualRenderWorld renderWorld) { - super(contraption, renderWorld); - this.lighter = contraption.makeLighter(); - - instanceWorld = new ContraptionInstanceWorld(this); - - var restoreState = GlStateTracker.getRestoreState(); - buildLayers(); - if (ContraptionRenderDispatcher.canInstance()) { - buildInstancedBlockEntities(); - buildActors(); - } - restoreState.restore(); - } - - public ContraptionLighter getLighter() { - return lighter; - } - - public void renderStructureLayer(RenderType layer, ContraptionProgram shader) { - ArrayModelRenderer structure = renderLayers.get(layer); - if (structure != null) { - setup(shader); - structure.draw(); - } - } - - public void renderInstanceLayer(RenderLayerEvent event) { - - event.stack.pushPose(); - float partialTicks = AnimationTickHolder.getPartialTicks(); - AbstractContraptionEntity entity = contraption.entity; - double x = Mth.lerp(partialTicks, entity.xOld, entity.getX()); - double y = Mth.lerp(partialTicks, entity.yOld, entity.getY()); - double z = Mth.lerp(partialTicks, entity.zOld, entity.getZ()); - event.stack.translate(x - event.camX, y - event.camY, z - event.camZ); - ContraptionMatrices.transform(event.stack, getMatrices().getModel()); - instanceWorld.engine.render(SerialTaskEngine.INSTANCE, event); - - event.stack.popPose(); - } - - public void beginFrame(BeginFrameEvent event) { - super.beginFrame(event); - - modelViewPartial.identity(); - modelViewPartialReady = false; - - if (!isVisible()) return; - - instanceWorld.blockEntityInstanceManager.beginFrame(SerialTaskEngine.INSTANCE, event.getCamera()); - - Vec3 cameraPos = event.getCameraPos(); - - lightBox = lighter.lightVolume.toAABB() - .move(-cameraPos.x, -cameraPos.y, -cameraPos.z); - } - - @Override - public void setupMatrices(PoseStack viewProjection, double camX, double camY, double camZ) { - super.setupMatrices(viewProjection, camX, camY, camZ); - - if (!modelViewPartialReady) { - setupModelViewPartial(modelViewPartial, getMatrices().getModel().last().pose(), contraption.entity, camX, camY, camZ, AnimationTickHolder.getPartialTicks()); - modelViewPartialReady = true; - } - } - - void setup(ContraptionProgram shader) { - if (!modelViewPartialReady || lightBox == null) return; - shader.bind(modelViewPartial, lightBox); - lighter.lightVolume.bind(); - } - - public void invalidate() { - for (ArrayModelRenderer renderer : renderLayers.values()) { - renderer.delete(); - renderer.getModel().delete(); - } - renderLayers.clear(); - - lighter.delete(); - - instanceWorld.delete(); - } - - private void buildLayers() { - for (ArrayModelRenderer renderer : renderLayers.values()) { - renderer.delete(); - renderer.getModel().delete(); - } - - renderLayers.clear(); - - List blockLayers = RenderType.chunkBufferLayers(); - Collection renderedBlocks = contraption.getRenderedBlocks(); - - for (RenderType layer : blockLayers) { - Model layerModel = new WorldModelBuilder(layer).withRenderWorld(renderWorld) - .withModelData(contraption.modelData) - .withBlocks(renderedBlocks) - .toModel(layer + "_" + contraption.entity.getId()); - renderLayers.put(layer, new ArrayModelRenderer(layerModel)); - } - } - - private void buildInstancedBlockEntities() { - for (BlockEntity be : contraption.maybeInstancedBlockEntities) { - if (!InstancedRenderRegistry.canInstance(be.getType())) { - continue; - } - - Level world = be.getLevel(); - be.setLevel(renderWorld); - instanceWorld.blockEntityInstanceManager.add(be); - be.setLevel(world); - } - } - - private void buildActors() { - contraption.getActors().forEach(instanceWorld.blockEntityInstanceManager::createActor); - } - - public static void setupModelViewPartial(Matrix4f matrix, Matrix4f modelMatrix, AbstractContraptionEntity entity, double camX, double camY, double camZ, float pt) { - float x = (float) (Mth.lerp(pt, entity.xOld, entity.getX()) - camX); - float y = (float) (Mth.lerp(pt, entity.yOld, entity.getY()) - camY); - float z = (float) (Mth.lerp(pt, entity.zOld, entity.getZ()) - camZ); - matrix.setTranslation(x, y, z); - matrix.mul(modelMatrix); - } - - public void tick() { - instanceWorld.blockEntityInstanceManager.tick(); - } - - public static class ContraptionInstanceWorld { - - private final Engine engine; - private final ContraptionInstanceManager blockEntityInstanceManager; - - public ContraptionInstanceWorld(FlwContraption parent) { - switch (Backend.getBackendType()) { - case INSTANCING -> { - InstancingEngine engine = InstancingEngine.builder(CreateContexts.CWORLD) - .setGroupFactory(ContraptionGroup.forContraption(parent)) - .setIgnoreOriginCoordinate(true) - .build(); - blockEntityInstanceManager = new ContraptionInstanceManager(engine, parent.renderWorld, parent.contraption); - engine.addListener(blockEntityInstanceManager); - - this.engine = engine; - } - case BATCHING -> { - engine = new BatchingEngine(); - blockEntityInstanceManager = new ContraptionInstanceManager(engine, parent.renderWorld, parent.contraption); - } - default -> throw new IllegalArgumentException("Unknown engine type"); - } - } - - public void delete() { - engine.delete(); - blockEntityInstanceManager.invalidate(); - } - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/render/FlwContraptionManager.java deleted file mode 100644 index 47a58f3802..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/FlwContraptionManager.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import static org.lwjgl.opengl.GL11.glBindTexture; -import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D; - -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.RenderLayer; -import com.jozufozu.flywheel.backend.gl.GlStateTracker; -import com.jozufozu.flywheel.backend.gl.GlTextureUnit; -import com.jozufozu.flywheel.config.BackendType; -import com.jozufozu.flywheel.core.Formats; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.compile.ProgramContext; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.event.RenderLayerEvent; -import com.jozufozu.flywheel.util.Textures; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.foundation.render.CreateContexts; - -import net.minecraft.world.level.LevelAccessor; - -public class FlwContraptionManager extends ContraptionRenderingWorld { - - public FlwContraptionManager(LevelAccessor world) { - super(world); - } - - @Override - public void tick() { - super.tick(); - - for (FlwContraption contraption : visible) { - contraption.tick(); - } - } - - @Override - public void renderLayer(RenderLayerEvent event) { - super.renderLayer(event); - - if (visible.isEmpty()) return; - - GlStateTracker.State restoreState = GlStateTracker.getRestoreState(); - GlTextureUnit active = GlTextureUnit.getActive(); - - var backendType = Backend.getBackendType(); - if (backendType != BackendType.OFF) { - renderStructures(event); - } - - if (backendType != BackendType.BATCHING && event.getLayer() != null) { - for (FlwContraption renderer : visible) { - renderer.renderInstanceLayer(event); - } - } - - // clear the light volume state - GlTextureUnit.T4.makeActive(); - glBindTexture(GL_TEXTURE_3D, 0); - - event.type.clearRenderState(); - active.makeActive(); - restoreState.restore(); - } - - private void renderStructures(RenderLayerEvent event) { - - event.type.setupRenderState(); - Textures.bindActiveTextures(); - - ContraptionProgram structureShader = CreateContexts.STRUCTURE.getProgram(ProgramContext.create(Materials.Names.PASSTHRU, Formats.BLOCK, RenderLayer.getLayer(event.type))); - - structureShader.bind(); - structureShader.uploadViewProjection(event.viewProjection); - structureShader.uploadCameraPos(event.camX, event.camY, event.camZ); - - for (FlwContraption flwContraption : visible) { - flwContraption.renderStructureLayer(event.type, structureShader); - } - } - - @Override - protected FlwContraption create(Contraption c) { - VirtualRenderWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c); - return new FlwContraption(c, renderWorld); - } - - @Override - public void removeDeadRenderers() { - boolean removed = renderInfos.values() - .removeIf(renderer -> { - if (renderer.isDead()) { - renderer.invalidate(); - return true; - } - return false; - }); - - // we use visible in #tick() so we have to re-evaluate it if any were removed - if (removed) collectVisible(); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/NonStationaryLighter.java b/src/main/java/com/simibubi/create/content/contraptions/render/NonStationaryLighter.java deleted file mode 100644 index d339258fdc..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/NonStationaryLighter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import com.jozufozu.flywheel.light.TickingLightListener; -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.jozufozu.flywheel.util.box.ImmutableBox; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.infrastructure.config.AllConfigs; - -public class NonStationaryLighter extends ContraptionLighter implements TickingLightListener { - public NonStationaryLighter(C contraption) { - super(contraption); - } - - @Override - public boolean tickLightListener() { - if (getVolume().volume() > AllConfigs.client().maxContraptionLightVolume.get()) - return false; - - ImmutableBox contraptionBounds = getContraptionBounds(); - - if (bounds.sameAs(contraptionBounds, 2)) { - return false; - } - bounds.assign(contraptionBounds); - growBoundsForEdgeData(bounds); - - lightVolume.move(bounds); - - return true; - } - - @Override - public GridAlignedBB getContraptionBounds() { - GridAlignedBB bb = GridAlignedBB.from(contraption.bounds); - - bb.translate(contraption.entity.blockPosition()); - - return bb; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/OrientedContraptionEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/render/OrientedContraptionEntityRenderer.java index 53b8e89af2..5451f9ff18 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/render/OrientedContraptionEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/render/OrientedContraptionEntityRenderer.java @@ -7,20 +7,18 @@ import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.entity.EntityRendererProvider; public class OrientedContraptionEntityRenderer extends ContraptionEntityRenderer { - public OrientedContraptionEntityRenderer(EntityRendererProvider.Context context) { super(context); } @Override - public boolean shouldRender(OrientedContraptionEntity entity, Frustum p_225626_2_, double p_225626_3_, - double p_225626_5_, double p_225626_7_) { - if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_)) + public boolean shouldRender(OrientedContraptionEntity entity, Frustum frustum, double cameraX, double cameraY, + double cameraZ) { + if (!super.shouldRender(entity, frustum, cameraX, cameraY, cameraZ)) return false; if (entity.getContraption() .getType() == ContraptionType.MOUNTED && entity.getVehicle() == null) return false; return true; } - } diff --git a/src/main/java/com/simibubi/create/content/contraptions/render/SBBContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/render/SBBContraptionManager.java deleted file mode 100644 index 2a779d7aa1..0000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/render/SBBContraptionManager.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.simibubi.create.content.contraptions.render; - -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.event.RenderLayerEvent; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.simibubi.create.CreateClient; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.SuperByteBufferCache; -import com.simibubi.create.foundation.utility.Pair; - -import net.minecraft.client.renderer.RenderType; -import net.minecraft.world.level.LevelAccessor; - -public class SBBContraptionManager extends ContraptionRenderingWorld { - public static final SuperByteBufferCache.Compartment> CONTRAPTION = new SuperByteBufferCache.Compartment<>(); - - public SBBContraptionManager(LevelAccessor world) { - super(world); - } - - @Override - public void renderLayer(RenderLayerEvent event) { - super.renderLayer(event); - RenderType type = event.getType(); - VertexConsumer consumer = event.buffers.bufferSource() - .getBuffer(type); - visible.forEach(info -> renderContraptionLayerSBB(info, type, consumer)); - - event.buffers.bufferSource().endBatch(type); - } - - @Override - public boolean invalidate(Contraption contraption) { - for (RenderType chunkBufferLayer : RenderType.chunkBufferLayers()) { - CreateClient.BUFFER_CACHE.invalidate(CONTRAPTION, Pair.of(contraption, chunkBufferLayer)); - } - return super.invalidate(contraption); - } - - @Override - protected ContraptionRenderInfo create(Contraption c) { - VirtualRenderWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c); - return new ContraptionRenderInfo(c, renderWorld); - } - - private void renderContraptionLayerSBB(ContraptionRenderInfo renderInfo, RenderType layer, VertexConsumer consumer) { - if (!renderInfo.isVisible()) return; - - SuperByteBuffer contraptionBuffer = CreateClient.BUFFER_CACHE.get(CONTRAPTION, Pair.of(renderInfo.contraption, layer), () -> ContraptionRenderDispatcher.buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer)); - - if (!contraptionBuffer.isEmpty()) { - ContraptionMatrices matrices = renderInfo.getMatrices(); - - contraptionBuffer.transform(matrices.getModel()) - .light(matrices.getWorld()) - .hybridLight() - .renderInto(matrices.getViewProjection(), consumer); - } - - } -} diff --git a/src/main/java/com/simibubi/create/content/decoration/placard/PlacardRenderer.java b/src/main/java/com/simibubi/create/content/decoration/placard/PlacardRenderer.java index f67250f702..8784eeb0ca 100644 --- a/src/main/java/com/simibubi/create/content/decoration/placard/PlacardRenderer.java +++ b/src/main/java/com/simibubi/create/content/decoration/placard/PlacardRenderer.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.decoration.placard; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -38,12 +38,12 @@ public class PlacardRenderer extends SafeBlockEntityRenderer boolean blockItem = bakedModel.isGui3d(); ms.pushPose(); - TransformStack.cast(ms) - .centre() - .rotate(Direction.UP, - (face == AttachFace.CEILING ? Mth.PI : 0) + AngleHelper.rad(180 + AngleHelper.horizontalAngle(facing))) - .rotate(Direction.EAST, - face == AttachFace.CEILING ? -Mth.PI / 2 : face == AttachFace.FLOOR ? Mth.PI / 2 : 0) + TransformStack.of(ms) + .center() + .rotate((face == AttachFace.CEILING ? Mth.PI : 0) + AngleHelper.rad(180 + AngleHelper.horizontalAngle(facing)), + Direction.UP) + .rotate(face == AttachFace.CEILING ? -Mth.PI / 2 : face == AttachFace.FLOOR ? Mth.PI / 2 : 0, + Direction.EAST) .translate(0, 0, 4.5 / 16f) .scale(blockItem ? .5f : .375f); diff --git a/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorMovementBehaviour.java b/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorMovementBehaviour.java index 9c8c7193d5..2115fe0f8c 100644 --- a/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorMovementBehaviour.java @@ -32,12 +32,6 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp import net.minecraft.world.phys.Vec3; public class SlidingDoorMovementBehaviour implements MovementBehaviour { - - @Override - public boolean renderAsNormalBlockEntity() { - return true; - } - @Override public boolean mustTickWhileDisabled() { return true; diff --git a/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorRenderer.java b/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorRenderer.java index 5d1338066d..d98af77ecc 100644 --- a/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorRenderer.java +++ b/src/main/java/com/simibubi/create/content/decoration/slidingDoor/SlidingDoorRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.decoration.slidingDoor; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context; @@ -61,16 +61,16 @@ public class SlidingDoorRenderer extends SafeBlockEntityRenderer } CachedBufferer.partial(mouth, blockState) - .centre() - .rotateY(AngleHelper.horizontalAngle(direction)) - .unCentre() + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(direction)) + .uncenter() .translate(0, offset * 4 / 16f, 0) .light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); diff --git a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankArmorLayer.java b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankArmorLayer.java index 11bc6e2dd1..2d3441ae48 100644 --- a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankArmorLayer.java +++ b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankArmorLayer.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.equipment.armor; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -9,7 +10,6 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.client.renderer.entity.EntityRenderer; @@ -43,7 +43,7 @@ public class BacktankArmorLayer return; HumanoidModel model = (HumanoidModel) entityModel; - RenderType renderType = Sheets.cutoutBlockSheet(); + VertexConsumer vc = buffer.getBuffer(Sheets.cutoutBlockSheet()); BlockState renderedState = item.getBlock().defaultBlockState() .setValue(BacktankBlock.HORIZONTAL_FACING, Direction.SOUTH); SuperByteBuffer backtank = CachedBufferer.block(renderedState); @@ -55,20 +55,20 @@ public class BacktankArmorLayer ms.translate(-1 / 2f, 10 / 16f, 1f); ms.scale(1, -1, -1); - backtank.forEntityRender() + backtank.disableDiffuse() .light(light) - .renderInto(ms, buffer.getBuffer(renderType)); + .renderInto(ms, vc); - cogs.centre() - .rotateY(180) - .unCentre() + cogs.center() + .rotateYDegrees(180) + .uncenter() .translate(0, 6.5f / 16, 11f / 16) - .rotate(Direction.EAST, AngleHelper.rad(2 * AnimationTickHolder.getRenderTime(entity.level()) % 360)) + .rotate(AngleHelper.rad(2 * AnimationTickHolder.getRenderTime(entity.level()) % 360), Direction.EAST) .translate(0, -6.5f / 16, -11f / 16); - cogs.forEntityRender() + cogs.disableDiffuse() .light(light) - .renderInto(ms, buffer.getBuffer(renderType)); + .renderInto(ms, vc); ms.popPose(); } @@ -90,5 +90,5 @@ public class BacktankArmorLayer BacktankArmorLayer layer = new BacktankArmorLayer<>(livingRenderer); livingRenderer.addLayer((BacktankArmorLayer) layer); } - + } diff --git a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankInstance.java b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankInstance.java deleted file mode 100644 index c382e3ff5c..0000000000 --- a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankInstance.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.simibubi.create.content.equipment.armor; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -public class BacktankInstance extends SingleRotatingInstance { - - public BacktankInstance(MaterialManager materialManager, BacktankBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getModel() { - return getRotatingMaterial().getModel(BacktankRenderer.getShaftModel(blockState), blockState); - } - -} diff --git a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankRenderer.java b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankRenderer.java index 11f52aab59..9ab3170c55 100644 --- a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.equipment.armor; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -28,12 +28,12 @@ public class BacktankRenderer extends KineticBlockEntityRenderer { + + public BacktankVisual(VisualizationContext context, BacktankBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + return Models.partial(BacktankRenderer.getShaftModel(blockState)); + } +} diff --git a/src/main/java/com/simibubi/create/content/equipment/bell/AbstractBellBlockEntity.java b/src/main/java/com/simibubi/create/content/equipment/bell/AbstractBellBlockEntity.java index f5ecc5a1a0..7b6283af09 100644 --- a/src/main/java/com/simibubi/create/content/equipment/bell/AbstractBellBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/equipment/bell/AbstractBellBlockEntity.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.equipment.bell; import java.util.List; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import com.simibubi.create.foundation.utility.NBTHelper; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -52,7 +52,7 @@ public abstract class AbstractBellBlockEntity extends SmartBlockEntity { ringingTicks = 0; } } - + @Override protected void write(CompoundTag tag, boolean clientPacket) { super.write(tag, clientPacket); @@ -60,7 +60,7 @@ public abstract class AbstractBellBlockEntity extends SmartBlockEntity { return; NBTHelper.writeEnum(tag, "Ringing", ringDirection); } - + @Override protected void read(CompoundTag tag, boolean clientPacket) { super.read(tag, clientPacket); diff --git a/src/main/java/com/simibubi/create/content/equipment/bell/BellRenderer.java b/src/main/java/com/simibubi/create/content/equipment/bell/BellRenderer.java index 9816e4f4f6..2257497b6c 100644 --- a/src/main/java/com/simibubi/create/content/equipment/bell/BellRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/bell/BellRenderer.java @@ -29,12 +29,12 @@ public class BellRenderer extends SafeBlockE SuperByteBuffer bell = CachedBufferer.partial(be.getBellModel(), state); if (be.isRinging) - bell.rotateCentered(be.ringDirection.getCounterClockWise(), getSwingAngle(be.ringingTicks + partialTicks)); + bell.rotateCentered(getSwingAngle(be.ringingTicks + partialTicks), be.ringDirection.getCounterClockWise()); float rY = AngleHelper.horizontalAngle(facing); if (attachment == BellAttachType.SINGLE_WALL || attachment == BellAttachType.DOUBLE_WALL) rY += 90; - bell.rotateCentered(Direction.UP, AngleHelper.rad(rY)); + bell.rotateCentered(AngleHelper.rad(rY), Direction.UP); bell.light(light) .renderInto(ms, buffer.getBuffer(RenderType.cutout())); diff --git a/src/main/java/com/simibubi/create/content/equipment/bell/CustomRotationParticle.java b/src/main/java/com/simibubi/create/content/equipment/bell/CustomRotationParticle.java index 8de532da47..227b68f7e0 100644 --- a/src/main/java/com/simibubi/create/content/equipment/bell/CustomRotationParticle.java +++ b/src/main/java/com/simibubi/create/content/equipment/bell/CustomRotationParticle.java @@ -3,10 +3,10 @@ package com.simibubi.create.content.equipment.bell; import org.joml.Quaternionf; import org.joml.Vector3f; -import com.jozufozu.flywheel.backend.ShadersModHandler; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; +import dev.engine_room.flywheel.lib.util.ShadersModHandler; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.SimpleAnimatedParticle; diff --git a/src/main/java/com/simibubi/create/content/equipment/bell/HauntedBellBlockEntity.java b/src/main/java/com/simibubi/create/content/equipment/bell/HauntedBellBlockEntity.java index 0784107b82..7a1242b4e3 100644 --- a/src/main/java/com/simibubi/create/content/equipment/bell/HauntedBellBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/equipment/bell/HauntedBellBlockEntity.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.equipment.bell; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllPartialModels; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; @@ -33,7 +33,7 @@ public class HauntedBellBlockEntity extends AbstractBellBlockEntity { public PartialModel getBellModel() { return AllPartialModels.HAUNTED_BELL; } - + @Override public boolean ring(Level world, BlockPos pos, Direction direction) { if (isRinging && ringingTicks < RECHARGE_TICKS) diff --git a/src/main/java/com/simibubi/create/content/equipment/bell/PeculiarBellBlockEntity.java b/src/main/java/com/simibubi/create/content/equipment/bell/PeculiarBellBlockEntity.java index 6cb81e2572..8a0259fe91 100644 --- a/src/main/java/com/simibubi/create/content/equipment/bell/PeculiarBellBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/equipment/bell/PeculiarBellBlockEntity.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.equipment.bell; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllPartialModels; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintRenderer.java b/src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintRenderer.java index aec4876ac7..041ff5a5e7 100644 --- a/src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/blueprint/BlueprintRenderer.java @@ -2,8 +2,6 @@ package com.simibubi.create.content.equipment.blueprint; import org.joml.Matrix3f; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.equipment.blueprint.BlueprintEntity.BlueprintSection; @@ -11,6 +9,8 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.Couple; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.Sheets; @@ -35,13 +35,13 @@ public class BlueprintRenderer extends EntityRenderer { PartialModel partialModel = entity.size == 3 ? AllPartialModels.CRAFTING_BLUEPRINT_3x3 : entity.size == 2 ? AllPartialModels.CRAFTING_BLUEPRINT_2x2 : AllPartialModels.CRAFTING_BLUEPRINT_1x1; SuperByteBuffer sbb = CachedBufferer.partial(partialModel, Blocks.AIR.defaultBlockState()); - sbb.rotateY(-yaw) - .rotateX(90.0F + entity.getXRot()) + sbb.rotateYDegrees(-yaw) + .rotateXDegrees(90.0F + entity.getXRot()) .translate(-.5, -1 / 32f, -.5); if (entity.size == 2) sbb.translate(.5, 0, -.5); - sbb.forEntityRender() + sbb.disableDiffuse() .light(light) .renderInto(ms, buffer.getBuffer(Sheets.solidBlockSheet())); super.render(entity, yaw, pt, ms, buffer, light); @@ -60,18 +60,18 @@ public class BlueprintRenderer extends EntityRenderer { } int itemLight = Mth.floor(sl + .5) << 20 | (Mth.floor(bl + .5) & 0xf) << 4; - TransformStack.cast(ms) - .rotateY(vertical ? 0 : -yaw) - .rotateX(fakeNormalXRotation); + TransformStack.of(ms) + .rotateYDegrees(vertical ? 0 : -yaw) + .rotateXDegrees(fakeNormalXRotation); Matrix3f copy = new Matrix3f(ms.last() .normal()); ms.popPose(); ms.pushPose(); - TransformStack.cast(ms) - .rotateY(-yaw) - .rotateX(entity.getXRot()) + TransformStack.of(ms) + .rotateYDegrees(-yaw) + .rotateXDegrees(entity.getXRot()) .translate(0, 0, 1 / 32f + .001); if (entity.size == 3) diff --git a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItemRenderer.java b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItemRenderer.java index 72d638afd7..d1a928e199 100644 --- a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItemRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.equipment.extendoGrip; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.Create; @@ -10,6 +8,8 @@ import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRendere import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemDisplayContext; @@ -18,11 +18,11 @@ import net.minecraft.world.phys.Vec3; public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer { - protected static final PartialModel COG = new PartialModel(Create.asResource("item/extendo_grip/cog")); - protected static final PartialModel THIN_SHORT = new PartialModel(Create.asResource("item/extendo_grip/thin_short")); - protected static final PartialModel WIDE_SHORT = new PartialModel(Create.asResource("item/extendo_grip/wide_short")); - protected static final PartialModel THIN_LONG = new PartialModel(Create.asResource("item/extendo_grip/thin_long")); - protected static final PartialModel WIDE_LONG = new PartialModel(Create.asResource("item/extendo_grip/wide_long")); + protected static final PartialModel COG = PartialModel.of(Create.asResource("item/extendo_grip/cog")); + protected static final PartialModel THIN_SHORT = PartialModel.of(Create.asResource("item/extendo_grip/thin_short")); + protected static final PartialModel WIDE_SHORT = PartialModel.of(Create.asResource("item/extendo_grip/wide_short")); + protected static final PartialModel THIN_LONG = PartialModel.of(Create.asResource("item/extendo_grip/thin_long")); + protected static final PartialModel WIDE_LONG = PartialModel.of(Create.asResource("item/extendo_grip/wide_long")); private static final Vec3 ROTATION_OFFSET = new Vec3(0, 1 / 2f, 1 / 2f); private static final Vec3 COG_ROTATION_OFFSET = new Vec3(0, 1 / 16f, 0); @@ -30,7 +30,7 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer { @Override protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, ItemDisplayContext transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - TransformStack stacker = TransformStack.cast(ms); + var stacker = TransformStack.of(ms); float animation = 0.25f; boolean leftHand = transformType == ItemDisplayContext.FIRST_PERSON_LEFT_HAND; boolean rightHand = transformType == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND; @@ -52,19 +52,19 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer { ms.translate(0, 1 / 16f, -7 / 16f); ms.scale(1, 1, 1 + animation); ms.pushPose(); - stacker.rotateX(-halfAngle) + stacker.rotateXDegrees(-halfAngle) .translate(ROTATION_OFFSET); renderer.renderSolid(THIN_SHORT.get(), light); stacker.translateBack(ROTATION_OFFSET); ms.translate(0, 5.5f / 16f, 0); - stacker.rotateX(-oppositeAngle) + stacker.rotateXDegrees(-oppositeAngle) .translate(ROTATION_OFFSET); renderer.renderSolid(WIDE_LONG.get(), light); stacker.translateBack(ROTATION_OFFSET); ms.translate(0, 11 / 16f, 0); - stacker.rotateX(oppositeAngle) + stacker.rotateXDegrees(oppositeAngle) .translate(ROTATION_OFFSET); ms.translate(0, 0.5f / 16f, 0); renderer.renderSolid(THIN_SHORT.get(), light); @@ -73,19 +73,19 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer { ms.popPose(); ms.pushPose(); - stacker.rotateX(-180 + halfAngle) + stacker.rotateXDegrees(-180 + halfAngle) .translate(ROTATION_OFFSET); renderer.renderSolid(WIDE_SHORT.get(), light); stacker.translateBack(ROTATION_OFFSET); ms.translate(0, 5.5f / 16f, 0); - stacker.rotateX(oppositeAngle) + stacker.rotateXDegrees(oppositeAngle) .translate(ROTATION_OFFSET); renderer.renderSolid(THIN_LONG.get(), light); stacker.translateBack(ROTATION_OFFSET); ms.translate(0, 11 / 16f, 0); - stacker.rotateX(-oppositeAngle) + stacker.rotateXDegrees(-oppositeAngle) .translate(ROTATION_OFFSET); ms.translate(0, 0.5f / 16f, 0); renderer.renderSolid(WIDE_SHORT.get(), light); @@ -93,8 +93,8 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer { // hand ms.translate(0, 5.5f / 16f, 0); - stacker.rotateX(180 - halfAngle) - .rotateY(180); + stacker.rotateXDegrees(180 - halfAngle) + .rotateYDegrees(180); ms.translate(0, 0, -4 / 16f); ms.scale(1, 1, 1 / (1 + animation)); renderer.renderSolid((leftHand || rightHand) ? ExtendoGripRenderHandler.pose.get() @@ -110,7 +110,7 @@ public class ExtendoGripItemRenderer extends CustomRenderedItemModelRenderer { angle += 360 * animation; angle %= 360; stacker.translate(COG_ROTATION_OFFSET) - .rotateZ(angle) + .rotateZDegrees(angle) .translateBack(COG_ROTATION_OFFSET); renderer.renderSolid(COG.get(), light); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripRenderHandler.java b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripRenderHandler.java index 150c32019e..37b8952726 100644 --- a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripRenderHandler.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.equipment.extendoGrip; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.player.LocalPlayer; @@ -65,7 +65,7 @@ public class ExtendoGripRenderHandler { return; PoseStack ms = event.getPoseStack(); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); AbstractClientPlayer abstractclientplayerentity = mc.player; RenderSystem.setShaderTexture(0, abstractclientplayerentity.getSkinTextureLocation()); @@ -87,13 +87,13 @@ public class ExtendoGripRenderHandler { ms.translate(flip * (0.64000005F - .1f), -0.4F + equipProgress * -0.6F, -0.71999997F + .3f); ms.pushPose(); - msr.rotateY(flip * 75.0F); + msr.rotateYDegrees(flip * 75.0F); ms.translate(flip * -1.0F, 3.6F, 3.5F); - msr.rotateZ(flip * 120) - .rotateX(200) - .rotateY(flip * -135.0F); + msr.rotateZDegrees(flip * 120) + .rotateXDegrees(200) + .rotateYDegrees(flip * -135.0F); ms.translate(flip * 5.6F, 0.0F, 0.0F); - msr.rotateY(flip * 40.0F); + msr.rotateYDegrees(flip * 40.0F); ms.translate(flip * 0.05f, -0.3f, -0.3f); PlayerRenderer playerrenderer = (PlayerRenderer) mc.getEntityRenderDispatcher() @@ -123,7 +123,7 @@ public class ExtendoGripRenderHandler { if (blockItem && mc.getItemRenderer() .getModel(heldItem, null, null, 0) .isGui3d()) { - msr.rotateY(flip * 45); + msr.rotateYDegrees(flip * 45); ms.translate(flip * 0.15f, -0.15f, -.05f); ms.scale(1.25f, 1.25f, 1.25f); } diff --git a/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonItemRenderer.java b/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonItemRenderer.java index 76a309f036..22983f9366 100644 --- a/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonItemRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.equipment.potatoCannon; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.simibubi.create.Create; @@ -11,6 +9,8 @@ import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRendere import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.MultiBufferSource; @@ -23,7 +23,7 @@ import net.minecraft.world.item.ItemStack; public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer { - protected static final PartialModel COG = new PartialModel(Create.asResource("item/potato_cannon/cog")); + protected static final PartialModel COG = PartialModel.of(Create.asResource("item/potato_cannon/cog")); @Override protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, @@ -59,8 +59,8 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer { PoseStack localMs = new PoseStack(); localMs.translate(-1 / 4f, -1 / 4f, 1); localMs.scale(.5f, .5f, .5f); - TransformStack.cast(localMs) - .rotateY(-34); + TransformStack.of(localMs) + .rotateYDegrees(-34); itemRenderer.renderStatic(ammo, ItemDisplayContext.GUI, light, OverlayTexture.NO_OVERLAY, localMs, buffer, mc.level, 0); }); diff --git a/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonRenderHandler.java b/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonRenderHandler.java index 4e437fdab5..34821232fc 100644 --- a/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoCannonRenderHandler.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.equipment.potatoCannon; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllItems; import com.simibubi.create.content.equipment.zapper.ShootableGadgetRenderHandler; import com.simibubi.create.foundation.particle.AirParticleData; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.particles.ItemParticleOption; @@ -49,15 +49,15 @@ public class PotatoCannonRenderHandler extends ShootableGadgetRenderHandler { protected void transformTool(PoseStack ms, float flip, float equipProgress, float recoil, float pt) { ms.translate(flip * -.1f, 0, .14f); ms.scale(.75f, .75f, .75f); - TransformStack.cast(ms) - .rotateX(recoil * 80); + TransformStack.of(ms) + .rotateXDegrees(recoil * 80); } @Override protected void transformHand(PoseStack ms, float flip, float equipProgress, float recoil, float pt) { ms.translate(flip * -.09, -.275, -.25); - TransformStack.cast(ms) - .rotateZ(flip * -10); + TransformStack.of(ms) + .rotateZDegrees(flip * -10); } } diff --git a/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoProjectileRenderMode.java b/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoProjectileRenderMode.java index 99d301c532..a71ff17bd6 100644 --- a/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoProjectileRenderMode.java +++ b/src/main/java/com/simibubi/create/content/equipment/potatoCannon/PotatoProjectileRenderMode.java @@ -2,10 +2,10 @@ package com.simibubi.create.content.equipment.potatoCannon; import static com.simibubi.create.content.equipment.potatoCannon.PotatoProjectileRenderMode.entityRandom; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; @@ -32,9 +32,9 @@ public interface PotatoProjectileRenderMode { .getCenter() .subtract(p1); - TransformStack.cast(ms) - .rotateY(AngleHelper.deg(Mth.atan2(diff.x, diff.z)) + 180) - .rotateX(AngleHelper.deg(Mth.atan2(diff.y, Mth.sqrt((float) (diff.x * diff.x + diff.z * diff.z))))); + TransformStack.of(ms) + .rotateYDegrees(AngleHelper.deg(Mth.atan2(diff.x, diff.z)) + 180) + .rotateXDegrees(AngleHelper.deg(Mth.atan2(diff.y, Mth.sqrt((float) (diff.x * diff.x + diff.z * diff.z))))); } } @@ -47,9 +47,9 @@ public interface PotatoProjectileRenderMode { @OnlyIn(Dist.CLIENT) public void transform(PoseStack ms, PotatoProjectileEntity entity, float pt) { super.transform(ms, entity, pt); - TransformStack.cast(ms) - .rotateZ((entity.tickCount + pt) * 2 * entityRandom(entity, 16)) - .rotateX((entity.tickCount + pt) * entityRandom(entity, 32)); + TransformStack.of(ms) + .rotateZDegrees((entity.tickCount + pt) * 2 * entityRandom(entity, 16)) + .rotateXDegrees((entity.tickCount + pt) * entityRandom(entity, 32)); } } @@ -68,13 +68,13 @@ public interface PotatoProjectileRenderMode { @OnlyIn(Dist.CLIENT) public void transform(PoseStack ms, PotatoProjectileEntity entity, float pt) { Vec3 diff = entity.getDeltaMovement(); - TransformStack.cast(ms) - .rotateY(AngleHelper.deg(Mth.atan2(diff.x, diff.z))) - .rotateX(270 + TransformStack.of(ms) + .rotateYDegrees(AngleHelper.deg(Mth.atan2(diff.x, diff.z))) + .rotateXDegrees(270 + AngleHelper.deg(Mth.atan2(diff.y, -Mth.sqrt((float) (diff.x * diff.x + diff.z * diff.z))))); - TransformStack.cast(ms) - .rotateY((entity.tickCount + pt) * 20 * spin + entityRandom(entity, 360)) - .rotateZ(-spriteAngleOffset); + TransformStack.of(ms) + .rotateYDegrees((entity.tickCount + pt) * 20 * spin + entityRandom(entity, 360)) + .rotateZDegrees(-spriteAngleOffset); } } @@ -90,7 +90,7 @@ public interface PotatoProjectileRenderMode { @Override @OnlyIn(Dist.CLIENT) public void transform(PoseStack ms, PotatoProjectileEntity entity, float pt) { - TransformStack.cast(ms).rotateY(AngleHelper.deg(Mth.atan2(offset.x, offset.z))); + TransformStack.of(ms).rotateYDegrees(AngleHelper.deg(Mth.atan2(offset.x, offset.z))); } } diff --git a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/SymmetryWandItemRenderer.java b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/SymmetryWandItemRenderer.java index 2379f2a3e6..90b3a321da 100644 --- a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/SymmetryWandItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/SymmetryWandItemRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.equipment.symmetryWand; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.simibubi.create.Create; @@ -9,6 +8,7 @@ import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRendere import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.util.Mth; @@ -17,9 +17,9 @@ import net.minecraft.world.item.ItemStack; public class SymmetryWandItemRenderer extends CustomRenderedItemModelRenderer { - protected static final PartialModel BITS = new PartialModel(Create.asResource("item/wand_of_symmetry/bits")); - protected static final PartialModel CORE = new PartialModel(Create.asResource("item/wand_of_symmetry/core")); - protected static final PartialModel CORE_GLOW = new PartialModel(Create.asResource("item/wand_of_symmetry/core_glow")); + protected static final PartialModel BITS = PartialModel.of(Create.asResource("item/wand_of_symmetry/bits")); + protected static final PartialModel CORE = PartialModel.of(Create.asResource("item/wand_of_symmetry/core")); + protected static final PartialModel CORE_GLOW = PartialModel.of(Create.asResource("item/wand_of_symmetry/core_glow")); @Override protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, ItemDisplayContext transformType, diff --git a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/CrossPlaneMirror.java b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/CrossPlaneMirror.java index 9a9172cca1..96fce78468 100644 --- a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/CrossPlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/CrossPlaneMirror.java @@ -5,12 +5,12 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.util.StringRepresentable; @@ -97,10 +97,10 @@ public class CrossPlaneMirror extends SymmetryMirror { @Override public void applyModelTransform(PoseStack ms) { super.applyModelTransform(ms); - TransformStack.cast(ms) - .centre() - .rotateY(((Align) orientation) == Align.Y ? 0 : 45) - .unCentre(); + TransformStack.of(ms) + .center() + .rotateYDegrees(((Align) orientation) == Align.Y ? 0 : 45) + .uncenter(); } @Override diff --git a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/EmptyMirror.java b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/EmptyMirror.java index cf30a04fdb..85d79136af 100644 --- a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/EmptyMirror.java +++ b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/EmptyMirror.java @@ -5,8 +5,8 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; -import com.jozufozu.flywheel.core.PartialModel; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.util.StringRepresentable; diff --git a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/PlaneMirror.java b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/PlaneMirror.java index b68cda9e76..84589b5261 100644 --- a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/PlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/PlaneMirror.java @@ -5,12 +5,12 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.util.StringRepresentable; @@ -93,10 +93,10 @@ public class PlaneMirror extends SymmetryMirror { @Override public void applyModelTransform(PoseStack ms) { super.applyModelTransform(ms); - TransformStack.cast(ms) - .centre() - .rotateY(((Align) orientation) == Align.XY ? 0 : 90) - .unCentre(); + TransformStack.of(ms) + .center() + .rotateYDegrees(((Align) orientation) == Align.XY ? 0 : 90) + .uncenter(); } @Override diff --git a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/SymmetryMirror.java b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/SymmetryMirror.java index a61430c791..a90fb724ca 100644 --- a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/SymmetryMirror.java +++ b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/SymmetryMirror.java @@ -5,10 +5,10 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/TriplePlaneMirror.java b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/TriplePlaneMirror.java index 73ea306f43..3dd228eadd 100644 --- a/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/TriplePlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/equipment/symmetryWand/mirror/TriplePlaneMirror.java @@ -5,10 +5,10 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.util.StringRepresentable; diff --git a/src/main/java/com/simibubi/create/content/equipment/toolbox/RadialToolboxMenu.java b/src/main/java/com/simibubi/create/content/equipment/toolbox/RadialToolboxMenu.java index 612651fe58..cccb3b102d 100644 --- a/src/main/java/com/simibubi/create/content/equipment/toolbox/RadialToolboxMenu.java +++ b/src/main/java/com/simibubi/create/content/equipment/toolbox/RadialToolboxMenu.java @@ -6,7 +6,6 @@ import java.util.List; import javax.annotation.Nullable; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; @@ -22,6 +21,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.ChatFormatting; import net.minecraft.client.KeyMapping; import net.minecraft.client.gui.GuiGraphics; @@ -126,10 +126,10 @@ public class RadialToolboxMenu extends AbstractSimiScreen { for (int slot = 0; slot < 8; slot++) { ms.pushPose(); - TransformStack.cast(ms) - .rotateZ(slot * 45 - 45) + TransformStack.of(ms) + .rotateZDegrees(slot * 45 - 45) .translate(0, -40 + (10 * (1 - fade) * (1 - fade)), 0) - .rotateZ(-slot * 45 + 45); + .rotateZDegrees(-slot * 45 + 45); ms.translate(-12, -12, 0); if (state == State.SELECT_ITEM || state == State.SELECT_ITEM_UNEQUIP) { diff --git a/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolBoxInstance.java b/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolBoxInstance.java deleted file mode 100644 index 375c63cf0c..0000000000 --- a/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolBoxInstance.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.simibubi.create.content.equipment.toolbox; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.Iterate; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; - -public class ToolBoxInstance extends BlockEntityInstance implements DynamicInstance { - - private final Direction facing; - private ModelData lid; - private ModelData[] drawers; - - public ToolBoxInstance(MaterialManager materialManager, ToolboxBlockEntity blockEntity) { - super(materialManager, blockEntity); - - facing = blockState.getValue(ToolboxBlock.FACING) - .getOpposite(); - } - - @Override - public void init() { - BlockState blockState = blockEntity.getBlockState(); - - Instancer drawerModel = materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(AllPartialModels.TOOLBOX_DRAWER, blockState); - - drawers = new ModelData[]{drawerModel.createInstance(), drawerModel.createInstance()}; - lid = materialManager.defaultCutout() - .material(Materials.TRANSFORMED) - .getModel(AllPartialModels.TOOLBOX_LIDS.get(blockEntity.getColor()), blockState) - .createInstance(); - - } - - @Override - public void remove() { - lid.delete(); - - for (ModelData drawer : drawers) { - drawer.delete(); - } - } - - @Override - public void beginFrame() { - - float partialTicks = AnimationTickHolder.getPartialTicks(); - - float lidAngle = blockEntity.lid.getValue(partialTicks); - float drawerOffset = blockEntity.drawers.getValue(partialTicks); - - lid.loadIdentity() - .translate(instancePos) - .centre() - .rotateY(-facing.toYRot()) - .unCentre() - .translate(0, 6 / 16f, 12 / 16f) - .rotateX(135 * lidAngle) - .translateBack(0, 6 / 16f, 12 / 16f); - - for (int offset : Iterate.zeroAndOne) { - drawers[offset].loadIdentity() - .translate(instancePos) - .centre() - .rotateY(-facing.toYRot()) - .unCentre() - .translate(0, offset * 1 / 8f, -drawerOffset * .175f * (2 - offset)); - } - } - - @Override - public void updateLight() { - relight(pos, drawers); - relight(pos, lid); - } -} diff --git a/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolBoxVisual.java b/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolBoxVisual.java new file mode 100644 index 0000000000..c3d3557403 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolBoxVisual.java @@ -0,0 +1,88 @@ +package com.simibubi.create.content.equipment.toolbox; + +import java.util.function.Consumer; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.foundation.utility.Iterate; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import net.minecraft.core.Direction; + +public class ToolBoxVisual extends AbstractBlockEntityVisual implements SimpleDynamicVisual { + + private final Direction facing; + private final TransformedInstance lid; + private final TransformedInstance[] drawers; + + public ToolBoxVisual(VisualizationContext context, ToolboxBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + facing = blockState.getValue(ToolboxBlock.FACING) + .getOpposite(); + + Instancer drawerModel = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.TOOLBOX_DRAWER)); + + drawers = new TransformedInstance[]{drawerModel.createInstance(), drawerModel.createInstance()}; + lid = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.TOOLBOX_LIDS.get(blockEntity.getColor()))) + .createInstance(); + } + + @Override + protected void _delete() { + lid.delete(); + + for (var drawer : drawers) { + drawer.delete(); + } + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + float partialTicks = ctx.partialTick(); + + float lidAngle = blockEntity.lid.getValue(partialTicks); + float drawerOffset = blockEntity.drawers.getValue(partialTicks); + + lid.setIdentityTransform() + .translate(getVisualPosition()) + .center() + .rotateYDegrees(-facing.toYRot()) + .uncenter() + .translate(0, 6 / 16f, 12 / 16f) + .rotateXDegrees(135 * lidAngle) + .translateBack(0, 6 / 16f, 12 / 16f) + .setChanged(); + + for (int offset : Iterate.zeroAndOne) { + drawers[offset].setIdentityTransform() + .translate(getVisualPosition()) + .center() + .rotateYDegrees(-facing.toYRot()) + .uncenter() + .translate(0, offset * 1 / 8f, -drawerOffset * .175f * (2 - offset)) + .setChanged(); + } + } + + @Override + public void updateLight(float partialTick) { + relight(drawers); + relight(lid); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(lid); + for (var drawer : drawers) { + consumer.accept(drawer); + } + } +} diff --git a/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxRenderer.java b/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxRenderer.java index df2a4cf680..01f64202fb 100644 --- a/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxRenderer.java @@ -35,19 +35,19 @@ public class ToolboxRenderer extends SmartBlockEntityRenderer { private void renderToolbox(GuiGraphics graphics, int x, int y, float partialTicks) { PoseStack ms = graphics.pose(); - TransformStack.cast(ms) + TransformStack.of(ms) .pushPose() .translate(x, y, 100) .scale(50) - .rotateX(-22) - .rotateY(-202); + .rotateXDegrees(-22) + .rotateYDegrees(-202); GuiGameElement.of(AllBlocks.TOOLBOXES.get(color) .getDefaultState()) .render(graphics); - TransformStack.cast(ms) + TransformStack.of(ms) .pushPose() .translate(0, -6 / 16f, 12 / 16f) - .rotateX(-105 * menu.contentHolder.lid.getValue(partialTicks)) + .rotateXDegrees(-105 * menu.contentHolder.lid.getValue(partialTicks)) .translate(0, 6 / 16f, -12 / 16f); GuiGameElement.of(AllPartialModels.TOOLBOX_LIDS.get(color)) .render(graphics); diff --git a/src/main/java/com/simibubi/create/content/equipment/wrench/WrenchItemRenderer.java b/src/main/java/com/simibubi/create/content/equipment/wrench/WrenchItemRenderer.java index c988b45ce6..f5863190e3 100644 --- a/src/main/java/com/simibubi/create/content/equipment/wrench/WrenchItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/wrench/WrenchItemRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.equipment.wrench; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.simibubi.create.Create; @@ -10,13 +9,14 @@ import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRendere import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; public class WrenchItemRenderer extends CustomRenderedItemModelRenderer { - protected static final PartialModel GEAR = new PartialModel(Create.asResource("item/wrench/gear")); + protected static final PartialModel GEAR = PartialModel.of(Create.asResource("item/wrench/gear")); @Override protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, ItemDisplayContext transformType, diff --git a/src/main/java/com/simibubi/create/content/equipment/zapper/terrainzapper/WorldshaperItemRenderer.java b/src/main/java/com/simibubi/create/content/equipment/zapper/terrainzapper/WorldshaperItemRenderer.java index ce66cee736..3074f12773 100644 --- a/src/main/java/com/simibubi/create/content/equipment/zapper/terrainzapper/WorldshaperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/equipment/zapper/terrainzapper/WorldshaperItemRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.equipment.zapper.terrainzapper; import static java.lang.Math.max; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.simibubi.create.Create; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.item.render.CustomRenderedItemModel; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.LightTexture; @@ -22,9 +22,9 @@ import net.minecraft.world.item.ItemStack; public class WorldshaperItemRenderer extends ZapperItemRenderer { - protected static final PartialModel CORE = new PartialModel(Create.asResource("item/handheld_worldshaper/core")); - protected static final PartialModel CORE_GLOW = new PartialModel(Create.asResource("item/handheld_worldshaper/core_glow")); - protected static final PartialModel ACCELERATOR = new PartialModel(Create.asResource("item/handheld_worldshaper/accelerator")); + protected static final PartialModel CORE = PartialModel.of(Create.asResource("item/handheld_worldshaper/core")); + protected static final PartialModel CORE_GLOW = PartialModel.of(Create.asResource("item/handheld_worldshaper/core_glow")); + protected static final PartialModel ACCELERATOR = PartialModel.of(Create.asResource("item/handheld_worldshaper/accelerator")); @Override protected void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, ItemDisplayContext transformType, @@ -44,7 +44,7 @@ public class WorldshaperItemRenderer extends ZapperItemRenderer { // Core glows float multiplier; - if (mainHand || offHand) + if (mainHand || offHand) multiplier = animation; else multiplier = Mth.sin(worldTime * 5); diff --git a/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainRenderer.java b/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainRenderer.java index d15835b1e7..d3d0c89fce 100644 --- a/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainRenderer.java +++ b/src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.fluids.drain; import java.util.Random; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.simibubi.create.content.fluids.transfer.GenericItemEmptying; @@ -14,6 +13,7 @@ import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRende import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -48,7 +48,7 @@ public class ItemDrainRenderer extends SmartBlockEntityRenderer implements DynamicInstance { - - protected ModelData pointer; - protected boolean settled; - - protected final double xRot; - protected final double yRot; - protected final int pointerRotationOffset; - - public FluidValveInstance(MaterialManager dispatcher, FluidValveBlockEntity blockEntity) { - super(dispatcher, blockEntity); - - Direction facing = blockState.getValue(FluidValveBlock.FACING); - - yRot = AngleHelper.horizontalAngle(facing); - xRot = facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90; - - Direction.Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState); - Direction.Axis shaftAxis = KineticBlockEntityRenderer.getRotationAxisOf(blockEntity); - - boolean twist = pipeAxis.isHorizontal() && shaftAxis == Direction.Axis.X || pipeAxis.isVertical(); - pointerRotationOffset = twist ? 90 : 0; - settled = false; - - pointer = materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(AllPartialModels.FLUID_VALVE_POINTER, blockState).createInstance(); - - transformPointer(); - } - - @Override - public void beginFrame() { - if (blockEntity.pointer.settled() && settled) - return; - - transformPointer(); - } - - private void transformPointer() { - float value = blockEntity.pointer.getValue(AnimationTickHolder.getPartialTicks()); - float pointerRotation = Mth.lerp(value, 0, -90); - settled = (value == 0 || value == 1) && blockEntity.pointer.settled(); - - pointer.loadIdentity() - .translate(getInstancePosition()) - .centre() - .rotateY(yRot) - .rotateX(xRot) - .rotateY(pointerRotationOffset + pointerRotation) - .unCentre(); - } - - @Override - public void updateLight() { - super.updateLight(); - relight(pos, pointer); - } - - @Override - public void remove() { - super.remove(); - pointer.delete(); - } -} diff --git a/src/main/java/com/simibubi/create/content/fluids/pipes/valve/FluidValveRenderer.java b/src/main/java/com/simibubi/create/content/fluids/pipes/valve/FluidValveRenderer.java index 70e0735735..9cf7f99f19 100644 --- a/src/main/java/com/simibubi/create/content/fluids/pipes/valve/FluidValveRenderer.java +++ b/src/main/java/com/simibubi/create/content/fluids/pipes/valve/FluidValveRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.fluids.pipes.valve; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; @@ -8,6 +7,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -26,7 +26,7 @@ public class FluidValveRenderer extends KineticBlockEntityRenderer implements SimpleDynamicVisual { + + protected TransformedInstance pointer; + protected boolean settled; + + protected final double xRot; + protected final double yRot; + protected final int pointerRotationOffset; + + public FluidValveVisual(VisualizationContext dispatcher, FluidValveBlockEntity blockEntity, float partialTick) { + super(dispatcher, blockEntity, partialTick); + + Direction facing = blockState.getValue(FluidValveBlock.FACING); + + yRot = AngleHelper.horizontalAngle(facing); + xRot = facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90; + + Direction.Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState); + Direction.Axis shaftAxis = KineticBlockEntityRenderer.getRotationAxisOf(blockEntity); + + boolean twist = pipeAxis.isHorizontal() && shaftAxis == Direction.Axis.X || pipeAxis.isVertical(); + pointerRotationOffset = twist ? 90 : 0; + settled = false; + + pointer = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.FLUID_VALVE_POINTER)).createInstance(); + + transformPointer(partialTick); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + if (blockEntity.pointer.settled() && settled) + return; + + transformPointer(ctx.partialTick()); + } + + private void transformPointer(float partialTick) { + float value = blockEntity.pointer.getValue(partialTick); + float pointerRotation = Mth.lerp(value, 0, -90); + settled = (value == 0 || value == 1) && blockEntity.pointer.settled(); + + pointer.setIdentityTransform() + .translate(getVisualPosition()) + .center() + .rotateYDegrees((float) yRot) + .rotateXDegrees((float) xRot) + .rotateYDegrees(pointerRotationOffset + pointerRotation) + .uncenter() + .setChanged(); + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + relight(pointer); + } + + @Override + protected void _delete() { + super._delete(); + pointer.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(pointer); + } +} diff --git a/src/main/java/com/simibubi/create/content/fluids/pump/PumpCogInstance.java b/src/main/java/com/simibubi/create/content/fluids/pump/PumpCogInstance.java deleted file mode 100644 index 629ec754a1..0000000000 --- a/src/main/java/com/simibubi/create/content/fluids/pump/PumpCogInstance.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.simibubi.create.content.fluids.pump; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class PumpCogInstance extends SingleRotatingInstance implements DynamicInstance { - - public PumpCogInstance(MaterialManager materialManager, PumpBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - public void beginFrame() {} - - @Override - protected Instancer getModel() { - BlockState referenceState = blockEntity.getBlockState(); - Direction facing = referenceState.getValue(BlockStateProperties.FACING); - return getRotatingMaterial().getModel(AllPartialModels.MECHANICAL_PUMP_COG, referenceState, facing); - } - -} diff --git a/src/main/java/com/simibubi/create/content/fluids/pump/PumpCogVisual.java b/src/main/java/com/simibubi/create/content/fluids/pump/PumpCogVisual.java new file mode 100644 index 0000000000..c94099d615 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/fluids/pump/PumpCogVisual.java @@ -0,0 +1,25 @@ +package com.simibubi.create.content.fluids.pump; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class PumpCogVisual extends SingleRotatingVisual { + + public PumpCogVisual(VisualizationContext context, PumpBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + BlockState referenceState = blockEntity.getBlockState(); + Direction facing = referenceState.getValue(BlockStateProperties.FACING); + return Models.partial(AllPartialModels.MECHANICAL_PUMP_COG, facing); + } +} diff --git a/src/main/java/com/simibubi/create/content/fluids/spout/SpoutRenderer.java b/src/main/java/com/simibubi/create/content/fluids/spout/SpoutRenderer.java index 9c103dd94a..c4502024c3 100644 --- a/src/main/java/com/simibubi/create/content/fluids/spout/SpoutRenderer.java +++ b/src/main/java/com/simibubi/create/content/fluids/spout/SpoutRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.fluids.spout; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour; @@ -9,6 +8,7 @@ import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRender import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.render.CachedBufferer; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; diff --git a/src/main/java/com/simibubi/create/content/fluids/tank/FluidTankRenderer.java b/src/main/java/com/simibubi/create/content/fluids/tank/FluidTankRenderer.java index e1acc93ad6..28ce39b00d 100644 --- a/src/main/java/com/simibubi/create/content/fluids/tank/FluidTankRenderer.java +++ b/src/main/java/com/simibubi/create/content/fluids/tank/FluidTankRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.fluids.tank; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -82,7 +82,7 @@ public class FluidTankRenderer extends SafeBlockEntityRenderer extends HalfShaftInstance { - public BackHalfShaftInstance(MaterialManager materialManager, T blockEntity) { - super(materialManager, blockEntity); +public class BackHalfShaftVisual extends HalfShaftVisual { + public BackHalfShaftVisual(VisualizationContext context, T blockEntity, float partialTick) { + super(context, blockEntity, partialTick); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/CutoutRotatingInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/CutoutRotatingInstance.java deleted file mode 100644 index 72b3767bea..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/CutoutRotatingInstance.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.simibubi.create.content.kinetics.base; - -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.foundation.render.AllMaterialSpecs; - -public class CutoutRotatingInstance extends SingleRotatingInstance { - public CutoutRotatingInstance(MaterialManager materialManager, T blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Material getRotatingMaterial() { - return materialManager.defaultCutout() - .material(AllMaterialSpecs.ROTATING); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/HalfShaftInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/HalfShaftInstance.java deleted file mode 100644 index ce0b1f33df..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/HalfShaftInstance.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.simibubi.create.content.kinetics.base; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class HalfShaftInstance extends SingleRotatingInstance { - public HalfShaftInstance(MaterialManager materialManager, T blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getModel() { - Direction dir = getShaftDirection(); - return getRotatingMaterial().getModel(AllPartialModels.SHAFT_HALF, blockState, dir); - } - - protected Direction getShaftDirection() { - return blockState.getValue(BlockStateProperties.FACING); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/HalfShaftVisual.java b/src/main/java/com/simibubi/create/content/kinetics/base/HalfShaftVisual.java new file mode 100644 index 0000000000..d20ec91a9d --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/base/HalfShaftVisual.java @@ -0,0 +1,24 @@ +package com.simibubi.create.content.kinetics.base; + +import com.simibubi.create.AllPartialModels; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class HalfShaftVisual extends SingleRotatingVisual { + public HalfShaftVisual(VisualizationContext context, T blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + return Models.partial(AllPartialModels.SHAFT_HALF, getShaftDirection()); + } + + protected Direction getShaftDirection() { + return blockState.getValue(BlockStateProperties.FACING); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/HorizontalHalfShaftInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/HorizontalHalfShaftVisual.java similarity index 50% rename from src/main/java/com/simibubi/create/content/kinetics/base/HorizontalHalfShaftInstance.java rename to src/main/java/com/simibubi/create/content/kinetics/base/HorizontalHalfShaftVisual.java index 297807d337..48effc0247 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/HorizontalHalfShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/HorizontalHalfShaftVisual.java @@ -1,14 +1,13 @@ package com.simibubi.create.content.kinetics.base; -import com.jozufozu.flywheel.api.MaterialManager; - +import dev.engine_room.flywheel.api.visualization.VisualizationContext; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.properties.BlockStateProperties; -public class HorizontalHalfShaftInstance extends HalfShaftInstance { +public class HorizontalHalfShaftVisual extends HalfShaftVisual { - public HorizontalHalfShaftInstance(MaterialManager materialManager, T blockEntity) { - super(materialManager, blockEntity); + public HorizontalHalfShaftVisual(VisualizationContext context, T blockEntity, float partialTick) { + super(context, blockEntity, partialTick); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntity.java index 09fe0c834d..f5bae223eb 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntity.java @@ -7,7 +7,6 @@ import java.util.List; import javax.annotation.Nullable; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.simibubi.create.Create; import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation; import com.simibubi.create.content.equipment.goggles.IHaveHoveringInformation; @@ -28,6 +27,7 @@ import com.simibubi.create.foundation.sound.SoundScapes.AmbienceGroup; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.minecraft.ChatFormatting; import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; @@ -68,7 +68,7 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI private int validationCountdown; protected float lastStressApplied; protected float lastCapacityProvided; - + public SequenceContext sequenceContext; public KineticBlockEntity(BlockEntityType typeIn, BlockPos pos, BlockState state) { @@ -265,7 +265,7 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI effects.triggerOverStressedEffect(); if (clientPacket) - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> VisualizationHelper.queueUpdate(this)); } public float getGeneratedSpeed() { @@ -578,7 +578,7 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI public void requestModelDataUpdate() { super.requestModelDataUpdate(); if (!this.remove) - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> VisualizationHelper.queueUpdate(this)); } @OnlyIn(Dist.CLIENT) @@ -603,7 +603,7 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI public int getRotationAngleOffset(Axis axis) { return 0; } - + protected boolean syncSequenceContext() { return false; } diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityRenderer.java index b5d8b9196b..312087cc6c 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.kinetics.base; import org.apache.commons.lang3.ArrayUtils; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; @@ -15,6 +14,7 @@ import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -46,12 +46,11 @@ public class KineticBlockEntityRenderer extends Sa @Override protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.canUseInstancing(be.getLevel())) return; + if (VisualizationManager.supportsVisualization(be.getLevel())) return; BlockState state = getRenderedBlockState(be); RenderType type = getRenderType(be, state); - if (type != null) - renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light); + renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light); } protected BlockState getRenderedBlockState(T be) { @@ -66,7 +65,7 @@ public class KineticBlockEntityRenderer extends Sa for (RenderType type : REVERSED_CHUNK_BUFFER_LAYERS) if (typeSet.contains(type)) return type; - return null; + return RenderType.cutoutMipped(); } protected SuperByteBuffer getRotatedModel(T be, BlockState state) { @@ -84,7 +83,7 @@ public class KineticBlockEntityRenderer extends Sa standardKineticRotationTransform(superBuffer, be, light).renderInto(ms, buffer); } - public static float getAngleForTe(KineticBlockEntity be, final BlockPos pos, Axis axis) { + public static float getAngleForBe(KineticBlockEntity be, final BlockPos pos, Axis axis) { float time = AnimationTickHolder.getRenderTime(be.getLevel()); float offset = getRotationOffsetForPosition(be, pos, axis); float angle = ((time * be.getSpeed() * 3f / 10 + offset) % 360) / 180 * (float) Math.PI; @@ -96,13 +95,13 @@ public class KineticBlockEntityRenderer extends Sa final BlockPos pos = be.getBlockPos(); Axis axis = ((IRotate) be.getBlockState() .getBlock()).getRotationAxis(be.getBlockState()); - return kineticRotationTransform(buffer, be, axis, getAngleForTe(be, pos, axis), light); + return kineticRotationTransform(buffer, be, axis, getAngleForBe(be, pos, axis), light); } public static SuperByteBuffer kineticRotationTransform(SuperByteBuffer buffer, KineticBlockEntity be, Axis axis, float angle, int light) { buffer.light(light); - buffer.rotateCentered(Direction.get(AxisDirection.POSITIVE, axis), angle); + buffer.rotateCentered(angle, Direction.get(AxisDirection.POSITIVE, axis)); if (KineticDebugger.isActive()) { rainbowMode = true; diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityVisual.java similarity index 57% rename from src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityInstance.java rename to src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityVisual.java index 0cec4b1eca..da80dd7943 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityVisual.java @@ -1,64 +1,63 @@ package com.simibubi.create.content.kinetics.base; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; import com.simibubi.create.content.kinetics.simpleRelays.ICogWheel; import com.simibubi.create.content.kinetics.simpleRelays.ShaftBlock; -import com.simibubi.create.foundation.render.AllMaterialSpecs; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.world.level.block.state.BlockState; -public abstract class KineticBlockEntityInstance extends BlockEntityInstance { +public abstract class KineticBlockEntityVisual extends AbstractBlockEntityVisual { protected final Direction.Axis axis; - public KineticBlockEntityInstance(MaterialManager materialManager, T blockEntity) { - super(materialManager, blockEntity); + public KineticBlockEntityVisual(VisualizationContext context, T blockEntity, float partialTick) { + super(context, blockEntity, partialTick); axis = (blockState.getBlock() instanceof IRotate irotate) ? irotate.getRotationAxis(blockState) : Axis.Y; } - protected final void updateRotation(RotatingData instance) { + protected final void updateRotation(RotatingInstance instance) { updateRotation(instance, getRotationAxis(), getBlockEntitySpeed()); } - protected final void updateRotation(RotatingData instance, Direction.Axis axis) { + protected final void updateRotation(RotatingInstance instance, Direction.Axis axis) { updateRotation(instance, axis, getBlockEntitySpeed()); } - protected final void updateRotation(RotatingData instance, float speed) { + protected final void updateRotation(RotatingInstance instance, float speed) { updateRotation(instance, getRotationAxis(), speed); } - protected final void updateRotation(RotatingData instance, Direction.Axis axis, float speed) { + protected final void updateRotation(RotatingInstance instance, Direction.Axis axis, float speed) { instance.setRotationAxis(axis) .setRotationOffset(getRotationOffset(axis)) .setRotationalSpeed(speed) - .setColor(blockEntity); + .setColor(blockEntity) + .setChanged(); } - protected final RotatingData setup(RotatingData key) { + protected final RotatingInstance setup(RotatingInstance key) { return setup(key, getRotationAxis(), getBlockEntitySpeed()); } - protected final RotatingData setup(RotatingData key, Direction.Axis axis) { + protected final RotatingInstance setup(RotatingInstance key, Direction.Axis axis) { return setup(key, axis, getBlockEntitySpeed()); } - protected final RotatingData setup(RotatingData key, float speed) { + protected final RotatingInstance setup(RotatingInstance key, float speed) { return setup(key, getRotationAxis(), speed); } - protected final RotatingData setup(RotatingData key, Direction.Axis axis, float speed) { + protected final RotatingInstance setup(RotatingInstance key, Direction.Axis axis, float speed) { key.setRotationAxis(axis) .setRotationalSpeed(speed) .setRotationOffset(getRotationOffset(axis)) .setColor(blockEntity) - .setPosition(getInstancePosition()); + .setPosition(getVisualPosition()) + .setChanged(); return key; } @@ -85,11 +84,6 @@ public abstract class KineticBlockEntityInstance e return shaft(getRotationAxis()); } - protected Material getRotatingMaterial() { - return materialManager.defaultSolid() - .material(AllMaterialSpecs.ROTATING); - } - public static BlockState shaft(Direction.Axis axis) { return AllBlocks.SHAFT.getDefaultState() .setValue(ShaftBlock.AXIS, axis); diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/KineticInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/KineticInstance.java new file mode 100644 index 0000000000..f8b716dc82 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/base/KineticInstance.java @@ -0,0 +1,69 @@ +package com.simibubi.create.content.kinetics.base; + +import org.joml.Vector3f; + +import com.simibubi.create.foundation.utility.Color; + +import dev.engine_room.flywheel.api.instance.InstanceHandle; +import dev.engine_room.flywheel.api.instance.InstanceType; +import dev.engine_room.flywheel.lib.instance.ColoredLitInstance; +import net.minecraft.core.BlockPos; + +public class KineticInstance extends ColoredLitInstance { + public float x; + public float y; + public float z; + public float rotationalSpeed; + public float rotationOffset; + + protected KineticInstance(InstanceType type, InstanceHandle handle) { + super(type, handle); + } + + public KineticInstance setPosition(BlockPos pos) { + return setPosition(pos.getX(), pos.getY(), pos.getZ()); + } + + public KineticInstance setPosition(Vector3f pos) { + return setPosition(pos.x(), pos.y(), pos.z()); + } + + public KineticInstance setPosition(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + return this; + } + + public KineticInstance nudge(float x, float y, float z) { + this.x += x; + this.y += y; + this.z += z; + return this; + } + + public KineticInstance setColor(KineticBlockEntity blockEntity) { + if (blockEntity.hasNetwork()) { + setColor(Color.generateFromLong(blockEntity.network)); + }else { + color(0xFF, 0xFF, 0xFF); + } + return this; + } + + public KineticInstance setColor(Color c) { + color(c.getRed(), c.getGreen(), c.getBlue()); + return this; + } + + public KineticInstance setRotationalSpeed(float rotationalSpeed) { + this.rotationalSpeed = rotationalSpeed; + return this; + } + + public KineticInstance setRotationOffset(float rotationOffset) { + this.rotationOffset = rotationOffset; + return this; + } + +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/RotatingInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/RotatingInstance.java new file mode 100644 index 0000000000..56d998c008 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/base/RotatingInstance.java @@ -0,0 +1,34 @@ +package com.simibubi.create.content.kinetics.base; + +import org.joml.Vector3f; + +import dev.engine_room.flywheel.api.instance.InstanceHandle; +import dev.engine_room.flywheel.api.instance.InstanceType; +import net.minecraft.core.Direction; + +public class RotatingInstance extends KineticInstance { + public byte rotationAxisX; + public byte rotationAxisY; + public byte rotationAxisZ; + + public RotatingInstance(InstanceType type, InstanceHandle handle) { + super(type, handle); + } + + public RotatingInstance setRotationAxis(Direction.Axis axis) { + Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis); + return setRotationAxis(orientation.step()); + } + + public RotatingInstance setRotationAxis(Vector3f axis) { + return setRotationAxis(axis.x(), axis.y(), axis.z()); + } + + public RotatingInstance setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) { + this.rotationAxisX = (byte) (rotationAxisX * 127); + this.rotationAxisY = (byte) (rotationAxisY * 127); + this.rotationAxisZ = (byte) (rotationAxisZ * 127); + return this; + } + +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/ShaftInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/ShaftInstance.java deleted file mode 100644 index 6649249bb3..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/ShaftInstance.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.simibubi.create.content.kinetics.base; - -import com.jozufozu.flywheel.api.MaterialManager; - -import net.minecraft.world.level.block.state.BlockState; - -public class ShaftInstance extends SingleRotatingInstance { - - public ShaftInstance(MaterialManager materialManager, T blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected BlockState getRenderedBlockState() { - return shaft(); - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/ShaftVisual.java b/src/main/java/com/simibubi/create/content/kinetics/base/ShaftVisual.java new file mode 100644 index 0000000000..1c4666886e --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/base/ShaftVisual.java @@ -0,0 +1,18 @@ +package com.simibubi.create.content.kinetics.base; + +import com.simibubi.create.foundation.render.VirtualRenderHelper; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; + +public class ShaftVisual extends SingleRotatingVisual { + + public ShaftVisual(VisualizationContext context, T blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + return VirtualRenderHelper.blockModel(shaft()); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java deleted file mode 100644 index 1a38e762a7..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.simibubi.create.content.kinetics.base; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -import net.minecraft.world.level.block.state.BlockState; - -public class SingleRotatingInstance extends KineticBlockEntityInstance { - - protected RotatingData rotatingModel; - - public SingleRotatingInstance(MaterialManager materialManager, T blockEntity) { - super(materialManager, blockEntity); - } - - @Override - public void init() { - rotatingModel = setup(getModel().createInstance()); - } - - @Override - public void update() { - updateRotation(rotatingModel); - } - - @Override - public void updateLight() { - relight(pos, rotatingModel); - } - - @Override - public void remove() { - rotatingModel.delete(); - } - - protected BlockState getRenderedBlockState() { - return blockState; - } - - protected Instancer getModel() { - return getRotatingMaterial().getModel(getRenderedBlockState()); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingVisual.java b/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingVisual.java new file mode 100644 index 0000000000..ba5ec60ec3 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingVisual.java @@ -0,0 +1,46 @@ +package com.simibubi.create.content.kinetics.base; + +import java.util.function.Consumer; + +import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.render.VirtualRenderHelper; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; + +public class SingleRotatingVisual extends KineticBlockEntityVisual { + + protected RotatingInstance rotatingModel; + + public SingleRotatingVisual(VisualizationContext context, T blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + rotatingModel = instancerProvider.instancer(AllInstanceTypes.ROTATING, model()) + .createInstance(); + setup(rotatingModel); + } + + @Override + public void update(float pt) { + updateRotation(rotatingModel); + } + + @Override + public void updateLight(float partialTick) { + relight(rotatingModel); + } + + @Override + protected void _delete() { + rotatingModel.delete(); + } + + protected Model model() { + return VirtualRenderHelper.blockModel(blockState); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(rotatingModel); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltData.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltData.java deleted file mode 100644 index e00e96fe7f..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltData.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.joml.Quaternionf; - -import com.simibubi.create.foundation.block.render.SpriteShiftEntry; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; - -public class BeltData extends KineticData { - float qX; - float qY; - float qZ; - float qW; - float sourceU; - float sourceV; - float minU; - float minV; - float maxU; - float maxV; - byte scrollMult; - - public BeltData setRotation(Quaternionf q) { - this.qX = q.x(); - this.qY = q.y(); - this.qZ = q.z(); - this.qW = q.w(); - markDirty(); - return this; - } - - public BeltData setScrollTexture(SpriteShiftEntry spriteShift) { - TextureAtlasSprite source = spriteShift.getOriginal(); - TextureAtlasSprite target = spriteShift.getTarget(); - - this.sourceU = source.getU0(); - this.sourceV = source.getV0(); - this.minU = target.getU0(); - this.minV = target.getV0(); - this.maxU = target.getU1(); - this.maxV = target.getV1(); - markDirty(); - - return this; - } - - public BeltData setScrollMult(float scrollMult) { - this.scrollMult = (byte) (scrollMult * 127); - markDirty(); - return this; - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltType.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltType.java deleted file mode 100644 index 6be331b8c3..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltType.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.joml.Quaternionf; - -import com.jozufozu.flywheel.api.struct.Batched; -import com.jozufozu.flywheel.api.struct.Instanced; -import com.jozufozu.flywheel.api.struct.StructWriter; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.layout.BufferLayout; -import com.jozufozu.flywheel.core.model.ModelTransformer; -import com.jozufozu.flywheel.util.RenderMath; -import com.simibubi.create.content.kinetics.KineticDebugger; -import com.simibubi.create.foundation.render.AllInstanceFormats; -import com.simibubi.create.foundation.render.AllProgramSpecs; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.resources.ResourceLocation; - -public class BeltType implements Instanced, Batched { - @Override - public BeltData create() { - return new BeltData(); - } - - @Override - public BufferLayout getLayout() { - return AllInstanceFormats.BELT; - } - - @Override - public StructWriter getWriter(VecBuffer backing) { - return new BeltWriterUnsafe(backing, this); - } - - @Override - public ResourceLocation getProgramSpec() { - return AllProgramSpecs.BELT; - } - - @Override - public void transform(BeltData d, ModelTransformer.Params b) { - float spriteHeight = d.maxV - d.minV; - double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset; - scroll = scroll - Math.floor(scroll); - scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult); - - float finalScroll = (float) scroll; - b.shiftUV((builder, u, v) -> { - float targetU = u - d.sourceU + d.minU; - float targetV = v - d.sourceV + d.minV - + finalScroll; - builder.uv(targetU, targetV); - }); - - b.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) - .multiply(new Quaternionf(d.qX, d.qY, d.qZ, d.qW)) - .unCentre() - .light(d.getPackedLight()); - if (KineticDebugger.isActive()) { - b.color(d.r, d.g, d.b, d.a); - } - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltWriterUnsafe.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltWriterUnsafe.java deleted file mode 100644 index 002e25e3ab..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltWriterUnsafe.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.api.struct.StructType; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; - -public class BeltWriterUnsafe extends KineticWriterUnsafe { - public BeltWriterUnsafe(VecBuffer backingBuffer, StructType vertexType) { - super(backingBuffer, vertexType); - } - - @Override - protected void writeInternal(BeltData d) { - super.writeInternal(d); - long addr = writePointer; - MemoryUtil.memPutFloat(addr + 26, d.qX); - MemoryUtil.memPutFloat(addr + 30, d.qY); - MemoryUtil.memPutFloat(addr + 34, d.qZ); - MemoryUtil.memPutFloat(addr + 38, d.qW); - MemoryUtil.memPutFloat(addr + 42, d.sourceU); - MemoryUtil.memPutFloat(addr + 46, d.sourceV); - MemoryUtil.memPutFloat(addr + 50, d.minU); - MemoryUtil.memPutFloat(addr + 54, d.minV); - MemoryUtil.memPutFloat(addr + 58, d.maxU); - MemoryUtil.memPutFloat(addr + 62, d.maxV); - MemoryUtil.memPutByte(addr + 66, d.scrollMult); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticData.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticData.java deleted file mode 100644 index d305fffd69..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticData.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.joml.Vector3f; - -import com.jozufozu.flywheel.core.materials.BasicData; -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; -import com.simibubi.create.foundation.utility.Color; - -import net.minecraft.core.BlockPos; - -public class KineticData extends BasicData { - float x; - float y; - float z; - float rotationalSpeed; - float rotationOffset; - - public KineticData setPosition(BlockPos pos) { - return setPosition(pos.getX(), pos.getY(), pos.getZ()); - } - - public KineticData setPosition(Vector3f pos) { - return setPosition(pos.x(), pos.y(), pos.z()); - } - - public KineticData setPosition(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; - markDirty(); - return this; - } - - public KineticData nudge(float x, float y, float z) { - this.x += x; - this.y += y; - this.z += z; - markDirty(); - return this; - } - - public KineticData setColor(KineticBlockEntity blockEntity) { - if (blockEntity.hasNetwork()) { - setColor(Color.generateFromLong(blockEntity.network)); - }else { - setColor(0xFF, 0xFF, 0xFF); - } - return this; - } - - public KineticData setColor(Color c) { - setColor(c.getRed(), c.getGreen(), c.getBlue()); - return this; - } - - public KineticData setRotationalSpeed(float rotationalSpeed) { - this.rotationalSpeed = rotationalSpeed; - return this; - } - - public KineticData setRotationOffset(float rotationOffset) { - this.rotationOffset = rotationOffset; - return this; - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticWriterUnsafe.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticWriterUnsafe.java deleted file mode 100644 index 3787e73d79..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticWriterUnsafe.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.api.struct.StructType; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.materials.BasicWriterUnsafe; - -public abstract class KineticWriterUnsafe extends BasicWriterUnsafe { - public KineticWriterUnsafe(VecBuffer backingBuffer, StructType vertexType) { - super(backingBuffer, vertexType); - } - - @Override - protected void writeInternal(D d) { - super.writeInternal(d); - long addr = writePointer; - MemoryUtil.memPutFloat(addr + 6, d.x); - MemoryUtil.memPutFloat(addr + 10, d.y); - MemoryUtil.memPutFloat(addr + 14, d.z); - MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed); - MemoryUtil.memPutFloat(addr + 22, d.rotationOffset); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingData.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingData.java deleted file mode 100644 index 5d1db80701..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingData.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.joml.Vector3f; - -import net.minecraft.core.Direction; - -public class RotatingData extends KineticData { - byte rotationAxisX; - byte rotationAxisY; - byte rotationAxisZ; - - public RotatingData setRotationAxis(Direction.Axis axis) { - Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis); - return setRotationAxis(orientation.step()); - } - - public RotatingData setRotationAxis(Vector3f axis) { - return setRotationAxis(axis.x(), axis.y(), axis.z()); - } - - public RotatingData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) { - this.rotationAxisX = (byte) (rotationAxisX * 127); - this.rotationAxisY = (byte) (rotationAxisY * 127); - this.rotationAxisZ = (byte) (rotationAxisZ * 127); - markDirty(); - return this; - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingType.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingType.java deleted file mode 100644 index c0d444c2e9..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingType.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.joml.Vector3f; - -import com.jozufozu.flywheel.api.struct.Batched; -import com.jozufozu.flywheel.api.struct.Instanced; -import com.jozufozu.flywheel.api.struct.StructWriter; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.layout.BufferLayout; -import com.jozufozu.flywheel.core.model.ModelTransformer; -import com.jozufozu.flywheel.util.RenderMath; -import com.mojang.math.Axis; -import com.simibubi.create.content.kinetics.KineticDebugger; -import com.simibubi.create.foundation.render.AllInstanceFormats; -import com.simibubi.create.foundation.render.AllProgramSpecs; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.resources.ResourceLocation; - -public class RotatingType implements Instanced, Batched { - @Override - public RotatingData create() { - return new RotatingData(); - } - - @Override - public BufferLayout getLayout() { - return AllInstanceFormats.ROTATING; - } - - @Override - public StructWriter getWriter(VecBuffer backing) { - return new RotatingWriterUnsafe(backing, this); - } - - @Override - public ResourceLocation getProgramSpec() { - return AllProgramSpecs.ROTATING; - } - - @Override - public void transform(RotatingData d, ModelTransformer.Params b) { - float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360); - - Axis axis = Axis.of(new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ))); - b.light(d.getPackedLight()) - .translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) - .multiply(axis.rotationDegrees(angle)) - .unCentre(); - - if (KineticDebugger.isActive()) { - b.color(d.r, d.g, d.b, d.a); - } - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingWriterUnsafe.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingWriterUnsafe.java deleted file mode 100644 index 8b043be7a4..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingWriterUnsafe.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.api.struct.StructType; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; - -public class RotatingWriterUnsafe extends KineticWriterUnsafe { - public RotatingWriterUnsafe(VecBuffer backingBuffer, StructType vertexType) { - super(backingBuffer, vertexType); - } - - @Override - protected void writeInternal(RotatingData d) { - super.writeInternal(d); - long addr = writePointer; - MemoryUtil.memPutByte(addr + 26, d.rotationAxisX); - MemoryUtil.memPutByte(addr + 27, d.rotationAxisY); - MemoryUtil.memPutByte(addr + 28, d.rotationAxisZ); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/package-info.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/package-info.java deleted file mode 100644 index 9e9a5554f1..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -package com.simibubi.create.content.kinetics.base.flwdata; - -import javax.annotation.ParametersAreNonnullByDefault; - -import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java index 1bd8d96286..fc6156d558 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java @@ -12,10 +12,6 @@ import java.util.Map; import java.util.Optional; import java.util.function.Function; -import com.jozufozu.flywheel.light.LightListener; -import com.jozufozu.flywheel.light.LightUpdater; -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.jozufozu.flywheel.util.box.ImmutableBox; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.kinetics.base.IRotate; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; @@ -33,9 +29,7 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour import com.simibubi.create.foundation.blockEntity.behaviour.inventory.VersionedInventoryTrackerBehaviour; import com.simibubi.create.foundation.utility.NBTHelper; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.core.BlockPos; -import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.core.Vec3i; @@ -44,7 +38,6 @@ import net.minecraft.nbt.NbtUtils; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -52,16 +45,12 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.items.IItemHandler; public class BeltBlockEntity extends KineticBlockEntity { - public Map passengers; public Optional color; public int beltLength; @@ -77,9 +66,6 @@ public class BeltBlockEntity extends KineticBlockEntity { public CompoundTag trackerUpdateTag; - @OnlyIn(Dist.CLIENT) - public BeltLighter lighter; - public static enum CasingType { NONE, ANDESITE, BRASS; } @@ -119,11 +105,6 @@ public class BeltBlockEntity extends KineticBlockEntity { if (!isController()) return; - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { - if (beltLength > 0 && lighter == null) { - lighter = new BeltLighter(); - } - }); invalidateRenderBoundingBox(); getInventory().tick(); @@ -200,7 +181,7 @@ public class BeltBlockEntity extends KineticBlockEntity { if (isController()) getInventory().ejectAll(); } - + @Override public void invalidate() { super.invalidate(); @@ -227,7 +208,6 @@ public class BeltBlockEntity extends KineticBlockEntity { @Override protected void read(CompoundTag compound, boolean clientPacket) { - int prevBeltLength = beltLength; super.read(compound, clientPacket); if (compound.getBoolean("IsController")) @@ -242,13 +222,6 @@ public class BeltBlockEntity extends KineticBlockEntity { trackerUpdateTag = compound; index = compound.getInt("Index"); beltLength = compound.getInt("Length"); - if (prevBeltLength != beltLength) { - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { - if (lighter != null) { - lighter.initializeLight(); - } - }); - } } if (isController()) @@ -287,7 +260,7 @@ public class BeltBlockEntity extends KineticBlockEntity { return false; if (level.isClientSide()) return true; - + for (BlockPos blockPos : BeltBlock.getBeltChain(level, getController())) { BeltBlockEntity belt = BeltHelper.getSegmentBE(level, blockPos); if (belt == null) @@ -296,7 +269,7 @@ public class BeltBlockEntity extends KineticBlockEntity { belt.setChanged(); belt.sendData(); } - + return true; } @@ -435,7 +408,7 @@ public class BeltBlockEntity extends KineticBlockEntity { public void setCasingType(CasingType type) { if (casing == type) return; - + BlockState blockState = getBlockState(); boolean shouldBlockHaveCasing = type != CasingType.NONE; @@ -446,7 +419,7 @@ public class BeltBlockEntity extends KineticBlockEntity { level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 16); return; } - + if (casing != CasingType.NONE) level.levelEvent(2001, worldPosition, Block.getId(casing == CasingType.ANDESITE ? AllBlocks.ANDESITE_CASING.getDefaultState() @@ -468,7 +441,7 @@ public class BeltBlockEntity extends KineticBlockEntity { return false; return getMovementFacing() != side.getOpposite(); } - + private boolean isOccupied(Direction side) { BeltBlockEntity nextBeltController = getControllerBE(); if (nextBeltController == null) @@ -581,109 +554,6 @@ public class BeltBlockEntity extends KineticBlockEntity { return state != null && state.hasProperty(BeltBlock.PART) && state.getValue(BeltBlock.PART) == BeltPart.START; } - /** - * Hide this behavior in an inner class to avoid loading LightListener on servers. - */ - @OnlyIn(Dist.CLIENT) - class BeltLighter implements LightListener { - private byte[] light; - - public BeltLighter() { - initializeLight(); - LightUpdater.get(level) - .addListener(this); - } - - /** - * Get the number of belt segments represented by the lighter. - * @return The number of segments. - */ - public int lightSegments() { - return light == null ? 0 : light.length / 2; - } - - /** - * Get the light value for a given segment. - * @param segment The segment to get the light value for. - * @return The light value. - */ - public int getPackedLight(int segment) { - return light == null ? 0 : LightTexture.pack(light[segment * 2], light[segment * 2 + 1]); - } - - @Override - public GridAlignedBB getVolume() { - BlockPos endPos = BeltHelper.getPositionForOffset(BeltBlockEntity.this, beltLength - 1); - GridAlignedBB bb = GridAlignedBB.from(worldPosition, endPos); - bb.fixMinMax(); - return bb; - } - - @Override - public boolean isListenerInvalid() { - return remove; - } - - @Override - public void onLightUpdate(LightLayer type, ImmutableBox changed) { - if (remove) - return; - if (level == null) - return; - - GridAlignedBB beltVolume = getVolume(); - - if (beltVolume.intersects(changed)) { - if (type == LightLayer.BLOCK) - updateBlockLight(); - - if (type == LightLayer.SKY) - updateSkyLight(); - } - } - - private void initializeLight() { - light = new byte[beltLength * 2]; - - Vec3i vec = getBeltFacing().getNormal(); - BeltSlope slope = getBlockState().getValue(BeltBlock.SLOPE); - int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; - - MutableBlockPos pos = new MutableBlockPos(controller.getX(), controller.getY(), controller.getZ()); - for (int i = 0; i < beltLength * 2; i += 2) { - light[i] = (byte) level.getBrightness(LightLayer.BLOCK, pos); - light[i + 1] = (byte) level.getBrightness(LightLayer.SKY, pos); - pos.move(vec.getX(), verticality, vec.getZ()); - } - } - - private void updateBlockLight() { - Vec3i vec = getBeltFacing().getNormal(); - BeltSlope slope = getBlockState().getValue(BeltBlock.SLOPE); - int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; - - MutableBlockPos pos = new MutableBlockPos(controller.getX(), controller.getY(), controller.getZ()); - for (int i = 0; i < beltLength * 2; i += 2) { - light[i] = (byte) level.getBrightness(LightLayer.BLOCK, pos); - - pos.move(vec.getX(), verticality, vec.getZ()); - } - } - - private void updateSkyLight() { - Vec3i vec = getBeltFacing().getNormal(); - BeltSlope slope = getBlockState().getValue(BeltBlock.SLOPE); - int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; - - MutableBlockPos pos = new MutableBlockPos(controller.getX(), controller.getY(), controller.getZ()); - for (int i = 1; i < beltLength * 2; i += 2) { - light[i] = (byte) level.getBrightness(LightLayer.SKY, pos); - - pos.move(vec.getX(), verticality, vec.getZ()); - } - } - } - public void setCovered(boolean blockCoveringBelt) { if (blockCoveringBelt == covered) return; diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java index f241e25bab..1359862b63 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java @@ -1,181 +1,50 @@ package com.simibubi.create.content.kinetics.belt; -import java.util.ArrayList; -import java.util.function.Supplier; - import org.joml.Quaternionf; +import org.joml.Quaternionfc; -import com.jozufozu.flywheel.api.InstanceData; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.AllBlocks; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.BeltData; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; +import com.simibubi.create.content.kinetics.base.KineticInstance; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; -import com.simibubi.create.foundation.render.AllMaterialSpecs; -import com.simibubi.create.foundation.utility.Iterate; -import net.minecraft.core.Direction; -import net.minecraft.util.Mth; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.LightLayer; +import dev.engine_room.flywheel.api.instance.InstanceHandle; +import dev.engine_room.flywheel.api.instance.InstanceType; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; -public class BeltInstance extends KineticBlockEntityInstance { +public class BeltInstance extends KineticInstance { + public final Quaternionf rotation = new Quaternionf(); + public float sourceU; + public float sourceV; + public float minU; + public float minV; + public float maxU; + public float maxV; + public float scrollMult; - boolean upward; - boolean diagonal; - boolean sideways; - boolean vertical; - boolean alongX; - boolean alongZ; - BeltSlope beltSlope; - Direction facing; - protected ArrayList keys; - protected RotatingData pulleyKey; + public BeltInstance(InstanceType type, InstanceHandle handle) { + super(type, handle); + } - public BeltInstance(MaterialManager materialManager, BeltBlockEntity blockEntity) { - super(materialManager, blockEntity); - - if (!AllBlocks.BELT.has(blockState)) - return; - - keys = new ArrayList<>(2); - - beltSlope = blockState.getValue(BeltBlock.SLOPE); - facing = blockState.getValue(BeltBlock.HORIZONTAL_FACING); - upward = beltSlope == BeltSlope.UPWARD; - diagonal = beltSlope.isDiagonal(); - sideways = beltSlope == BeltSlope.SIDEWAYS; - vertical = beltSlope == BeltSlope.VERTICAL; - alongX = facing.getAxis() == Direction.Axis.X; - alongZ = facing.getAxis() == Direction.Axis.Z; - - BeltPart part = blockState.getValue(BeltBlock.PART); - boolean start = part == BeltPart.START; - boolean end = part == BeltPart.END; - DyeColor color = blockEntity.color.orElse(null); - - for (boolean bottom : Iterate.trueAndFalse) { - PartialModel beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom); - SpriteShiftEntry spriteShift = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom); - - Instancer beltModel = materialManager.defaultSolid() - .material(AllMaterialSpecs.BELTS) - .getModel(beltPartial, blockState); - - keys.add(setup(beltModel.createInstance(), bottom, spriteShift)); - - if (diagonal) break; - } - - if (blockEntity.hasPulley()) { - Instancer pulleyModel = getPulleyModel(); - - pulleyKey = setup(pulleyModel.createInstance()); - } + public BeltInstance setRotation(Quaternionfc q) { + this.rotation.set(q); + return this; } - @Override - public void update() { - DyeColor color = blockEntity.color.orElse(null); + public BeltInstance setScrollTexture(SpriteShiftEntry spriteShift) { + TextureAtlasSprite source = spriteShift.getOriginal(); + TextureAtlasSprite target = spriteShift.getTarget(); - boolean bottom = true; - for (BeltData key : keys) { + this.sourceU = source.getU0(); + this.sourceV = source.getV0(); + this.minU = target.getU0(); + this.minV = target.getV0(); + this.maxU = target.getU1(); + this.maxV = target.getV1(); - SpriteShiftEntry spriteShiftEntry = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom); - key.setScrollTexture(spriteShiftEntry) - .setColor(blockEntity) - .setRotationalSpeed(getScrollSpeed()); - bottom = false; - } - - if (pulleyKey != null) { - updateRotation(pulleyKey); - } - } - - @Override - public void updateLight() { - relight(pos, keys.stream()); - - if (pulleyKey != null) relight(pos, pulleyKey); - } - - @Override - public void remove() { - keys.forEach(InstanceData::delete); - keys.clear(); - if (pulleyKey != null) pulleyKey.delete(); - pulleyKey = null; - } - - private float getScrollSpeed() { - float speed = blockEntity.getSpeed(); - if (((facing.getAxisDirection() == Direction.AxisDirection.NEGATIVE) ^ upward) ^ - ((alongX && !diagonal) || (alongZ && diagonal))) { - speed = -speed; - } - if (sideways && (facing == Direction.SOUTH || facing == Direction.WEST) || (vertical && facing == Direction.EAST)) - speed = -speed; - - return speed; - } - - private Instancer getPulleyModel() { - Direction dir = getOrientation(); - - Direction.Axis axis = dir.getAxis(); - - Supplier ms = () -> { - PoseStack modelTransform = new PoseStack(); - TransformStack msr = TransformStack.cast(modelTransform); - msr.centre(); - if (axis == Direction.Axis.X) - msr.rotateY(90); - if (axis == Direction.Axis.Y) - msr.rotateX(90); - msr.rotateX(90); - msr.unCentre(); - - return modelTransform; - }; - - return getRotatingMaterial().getModel(AllPartialModels.BELT_PULLEY, blockState, dir, ms); - } - - private Direction getOrientation() { - Direction dir = blockState.getValue(BeltBlock.HORIZONTAL_FACING) - .getClockWise(); - if (beltSlope == BeltSlope.SIDEWAYS) - dir = Direction.UP; - - return dir; - } - - private BeltData setup(BeltData key, boolean bottom, SpriteShiftEntry spriteShift) { - boolean downward = beltSlope == BeltSlope.DOWNWARD; - float rotX = (!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0) + (downward ? 180 : 0) + (sideways ? 90 : 0) + (vertical && alongZ ? 180 : 0); - float rotY = facing.toYRot() + ((diagonal ^ alongX) && !downward ? 180 : 0) + (sideways && alongZ ? 180 : 0) + (vertical && alongX ? 90 : 0); - float rotZ = (sideways ? 90 : 0) + (vertical && alongX ? 90 : 0); - - Quaternionf q = new Quaternionf().rotationXYZ(rotX * Mth.DEG_TO_RAD, rotY * Mth.DEG_TO_RAD, rotZ * Mth.DEG_TO_RAD); - - key.setScrollTexture(spriteShift) - .setScrollMult(diagonal ? 3f / 8f : 0.5f) - .setRotation(q) - .setRotationalSpeed(getScrollSpeed()) - .setRotationOffset(bottom ? 0.5f : 0f) - .setColor(blockEntity) - .setPosition(getInstancePosition()) - .setBlockLight(world.getBrightness(LightLayer.BLOCK, pos)) - .setSkyLight(world.getBrightness(LightLayer.SKY, pos)); - - return key; - } + return this; + } + public BeltInstance setScrollMult(float scrollMult) { + this.scrollMult = scrollMult; + return this; + } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java index bf401e7f45..edadb36a3a 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltRenderer.java @@ -3,9 +3,6 @@ package com.simibubi.create.content.kinetics.belt; import java.util.Random; import java.util.function.Supplier; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; @@ -24,11 +21,16 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; import net.minecraft.core.Direction.AxisDirection; @@ -54,7 +56,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer { protected void renderSafe(BeltBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (!Backend.canUseInstancing(be.getLevel())) { + if (!VisualizationManager.supportsVisualization(be.getLevel())) { BlockState blockState = be.getBlockState(); if (!AllBlocks.BELT.has(blockState)) return; @@ -73,15 +75,15 @@ public class BeltRenderer extends SafeBlockEntityRenderer { boolean alongX = facing.getAxis() == Direction.Axis.X; PoseStack localTransforms = new PoseStack(); - TransformStack msr = TransformStack.cast(localTransforms); + var msr = TransformStack.of(localTransforms); VertexConsumer vb = buffer.getBuffer(RenderType.solid()); float renderTick = AnimationTickHolder.getRenderTime(be.getLevel()); - msr.centre() - .rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0)) - .rotateZ(sideways ? 90 : 0) - .rotateX(!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0) - .unCentre(); + msr.center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0)) + .rotateZDegrees(sideways ? 90 : 0) + .rotateXDegrees(!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0) + .uncenter(); if (downward || beltSlope == BeltSlope.VERTICAL && axisDirection == AxisDirection.POSITIVE) { boolean b = start; @@ -119,7 +121,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer { } beltBuffer - .transform(localTransforms) + .transform(localTransforms) .renderInto(ms, vb); // Diagonal belt do not have a separate bottom model @@ -131,12 +133,12 @@ public class BeltRenderer extends SafeBlockEntityRenderer { Supplier matrixStackSupplier = () -> { PoseStack stack = new PoseStack(); - TransformStack stacker = TransformStack.cast(stack); - stacker.centre(); - if (dir.getAxis() == Direction.Axis.X) stacker.rotateY(90); - if (dir.getAxis() == Direction.Axis.Y) stacker.rotateX(90); - stacker.rotateX(90); - stacker.unCentre(); + var stacker = TransformStack.of(stack); + stacker.center(); + if (dir.getAxis() == Direction.Axis.X) stacker.rotateYDegrees(90); + if (dir.getAxis() == Direction.Axis.Y) stacker.rotateXDegrees(90); + stacker.rotateXDegrees(90); + stacker.uncenter(); return stack; }; @@ -193,6 +195,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer { int verticality = slope == BeltSlope.DOWNWARD ? -1 : slope == BeltSlope.UPWARD ? 1 : 0; boolean slopeAlongX = beltFacing .getAxis() == Direction.Axis.X; + MutableBlockPos mutablePos = new MutableBlockPos(); Minecraft mc = Minecraft.getInstance(); ItemRenderer itemRenderer = mc.getItemRenderer(); @@ -200,6 +203,10 @@ public class BeltRenderer extends SafeBlockEntityRenderer { for (TransportedItemStack transported : be.getInventory() .getTransportedItems()) { + ms.pushPose(); + TransformStack.of(ms) + .nudge(transported.angle); + float offset; float sideOffset; float verticalMovement; @@ -237,7 +244,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer { } ms.pushPose(); - TransformStack.cast(ms).nudge(transported.angle); + TransformStack.of(ms).nudge(transported.angle); ms.translate(offsetVec.x, offsetVec.y, offsetVec.z); boolean alongX = beltFacing @@ -247,7 +254,14 @@ public class BeltRenderer extends SafeBlockEntityRenderer { sideOffset *= -1; ms.translate(alongX ? sideOffset : 0, 0, alongX ? 0 : sideOffset); - int stackLight = onContraption ? light : getPackedLight(be, offset); + int stackLight; + if (onContraption) { + stackLight = light; + } else { + int segment = (int) Math.floor(offset); + mutablePos.set(be.getBlockPos()).move(directionVec.getX() * segment, verticality * segment, directionVec.getZ() * segment); + stackLight = LevelRenderer.getLightColor(be.getLevel(), mutablePos); + } boolean renderUpright = BeltHelper.isItemUpright(transported.stack); BakedModel bakedModel = itemRenderer.getModel(transported.stack, be.getLevel(), null, 0); @@ -318,13 +332,4 @@ public class BeltRenderer extends SafeBlockEntityRenderer { } ms.popPose(); } - - protected int getPackedLight(BeltBlockEntity controller, float beltPos) { - int segment = (int) Math.floor(beltPos); - if (controller.lighter == null || segment >= controller.lighter.lightSegments() || segment < 0) - return 0; - - return controller.lighter.getPackedLight(segment); - } - } diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltVisual.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltVisual.java new file mode 100644 index 0000000000..625c790927 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltVisual.java @@ -0,0 +1,181 @@ +package com.simibubi.create.content.kinetics.belt; + +import java.util.ArrayList; +import java.util.function.Consumer; + +import org.joml.Quaternionf; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.KineticBlockEntityVisual; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.foundation.block.render.SpriteShiftEntry; +import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.utility.Iterate; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.AbstractInstance; +import dev.engine_room.flywheel.lib.instance.FlatLit; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.LightLayer; + +public class BeltVisual extends KineticBlockEntityVisual { + + boolean upward; + boolean diagonal; + boolean sideways; + boolean vertical; + boolean alongX; + boolean alongZ; + BeltSlope beltSlope; + Direction facing; + protected ArrayList keys; + protected RotatingInstance pulleyKey; + + public BeltVisual(VisualizationContext context, BeltBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + if (!AllBlocks.BELT.has(blockState)) + return; + + keys = new ArrayList<>(2); + + beltSlope = blockState.getValue(BeltBlock.SLOPE); + facing = blockState.getValue(BeltBlock.HORIZONTAL_FACING); + upward = beltSlope == BeltSlope.UPWARD; + diagonal = beltSlope.isDiagonal(); + sideways = beltSlope == BeltSlope.SIDEWAYS; + vertical = beltSlope == BeltSlope.VERTICAL; + alongX = facing.getAxis() == Direction.Axis.X; + alongZ = facing.getAxis() == Direction.Axis.Z; + + BeltPart part = blockState.getValue(BeltBlock.PART); + boolean start = part == BeltPart.START; + boolean end = part == BeltPart.END; + DyeColor color = blockEntity.color.orElse(null); + + for (boolean bottom : Iterate.trueAndFalse) { + PartialModel beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom); + SpriteShiftEntry spriteShift = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom); + + Instancer beltModel = instancerProvider.instancer(AllInstanceTypes.BELT, Models.partial(beltPartial)); + + keys.add(setup(beltModel.createInstance(), bottom, spriteShift)); + + if (diagonal) break; + } + + if (blockEntity.hasPulley()) { + Instancer pulleyModel = getPulleyModel(); + + pulleyKey = setup(pulleyModel.createInstance()); + } + } + + @Override + public void update(float pt) { + DyeColor color = blockEntity.color.orElse(null); + + boolean bottom = true; + for (BeltInstance key : keys) { + + SpriteShiftEntry spriteShiftEntry = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom); + key.setScrollTexture(spriteShiftEntry) + .setColor(blockEntity) + .setRotationalSpeed(getScrollSpeed()) + .setChanged(); + bottom = false; + } + + if (pulleyKey != null) { + updateRotation(pulleyKey); + } + } + + @Override + public void updateLight(float partialTick) { + relight(keys.toArray(FlatLit[]::new)); + + if (pulleyKey != null) relight(pulleyKey); + } + + @Override + protected void _delete() { + keys.forEach(AbstractInstance::delete); + keys.clear(); + if (pulleyKey != null) pulleyKey.delete(); + pulleyKey = null; + } + + private float getScrollSpeed() { + float speed = blockEntity.getSpeed(); + if (((facing.getAxisDirection() == Direction.AxisDirection.NEGATIVE) ^ upward) ^ + ((alongX && !diagonal) || (alongZ && diagonal))) { + speed = -speed; + } + if (sideways && (facing == Direction.SOUTH || facing == Direction.WEST) || (vertical && facing == Direction.EAST)) + speed = -speed; + + return speed; + } + + private Instancer getPulleyModel() { + Direction dir = getOrientation(); + + var model = Models.partial(AllPartialModels.BELT_PULLEY, dir.getAxis(), (axis11, modelTransform1) -> { + var msr = TransformStack.of(modelTransform1); + msr.center(); + if (axis11 == Direction.Axis.X) msr.rotateYDegrees(90); + if (axis11 == Direction.Axis.Y) msr.rotateXDegrees(90); + msr.rotateXDegrees(90); + msr.uncenter(); + }); + + return instancerProvider.instancer(AllInstanceTypes.ROTATING, model); + } + + private Direction getOrientation() { + Direction dir = blockState.getValue(BeltBlock.HORIZONTAL_FACING) + .getClockWise(); + if (beltSlope == BeltSlope.SIDEWAYS) + dir = Direction.UP; + + return dir; + } + + private BeltInstance setup(BeltInstance key, boolean bottom, SpriteShiftEntry spriteShift) { + boolean downward = beltSlope == BeltSlope.DOWNWARD; + float rotX = (!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0) + (downward ? 180 : 0) + (sideways ? 90 : 0) + (vertical && alongZ ? 180 : 0); + float rotY = facing.toYRot() + ((diagonal ^ alongX) && !downward ? 180 : 0) + (sideways && alongZ ? 180 : 0) + (vertical && alongX ? 90 : 0); + float rotZ = (sideways ? 90 : 0) + (vertical && alongX ? 90 : 0); + + Quaternionf q = new Quaternionf().rotationXYZ(rotX * Mth.DEG_TO_RAD, rotY * Mth.DEG_TO_RAD, rotZ * Mth.DEG_TO_RAD); + + key.setScrollTexture(spriteShift) + .setScrollMult(diagonal ? 3f / 8f : 0.5f) + .setRotation(q) + .setRotationalSpeed(getScrollSpeed()) + .setRotationOffset(bottom ? 0.5f : 0f) + .setColor(blockEntity) + .setPosition(getVisualPosition()) + .light(level.getBrightness(LightLayer.BLOCK, pos), level.getBrightness(LightLayer.SKY, pos)) + .setChanged(); + + return key; + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + if (pulleyKey != null) { + consumer.accept(pulleyKey); + } + keys.forEach(consumer); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/clock/CuckooClockRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/clock/CuckooClockRenderer.java index 65dbffb310..985e3989d4 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/clock/CuckooClockRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/clock/CuckooClockRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.kinetics.clock; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -79,7 +79,7 @@ public class CuckooClockRenderer extends KineticBlockEntityRenderer { - - public ShaftlessCogwheelInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getModel() { - Direction facing = blockState.getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); - - return getRotatingMaterial().getModel(AllPartialModels.SHAFTLESS_COGWHEEL, blockState, facing, rotateToFace(facing)); - } - - private Supplier rotateToFace(Direction facing) { - return () -> { - PoseStack stack = new PoseStack(); - TransformStack stacker = TransformStack.cast(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; - }; - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/crafter/ShaftlessCogwheelVisual.java b/src/main/java/com/simibubi/create/content/kinetics/crafter/ShaftlessCogwheelVisual.java new file mode 100644 index 0000000000..2707f3795e --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/crafter/ShaftlessCogwheelVisual.java @@ -0,0 +1,36 @@ +package com.simibubi.create.content.kinetics.crafter; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.KineticBlockEntity; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import net.minecraft.core.Direction; + +public class ShaftlessCogwheelVisual extends SingleRotatingVisual { + + public ShaftlessCogwheelVisual(VisualizationContext context, KineticBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + Direction facing = blockState.getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); + + return Models.partial(AllPartialModels.SHAFTLESS_COGWHEEL, facing, ShaftlessCogwheelVisual::rotateToFace); + } + + private static void rotateToFace(Direction facing, PoseStack stack) { + var stacker = TransformStack.of(stack) + .center(); + + if (facing.getAxis() == Direction.Axis.X) stacker.rotateZDegrees(90); + else if (facing.getAxis() == Direction.Axis.Z) stacker.rotateXDegrees(90); + + stacker.uncenter(); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankBlockEntity.java index e4c3f902a1..3e9bab1353 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankBlockEntity.java @@ -1,8 +1,5 @@ package com.simibubi.create.content.kinetics.crank; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.core.materials.model.ModelData; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.AllSoundEvents; @@ -11,6 +8,8 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.lib.model.Models; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -102,11 +101,11 @@ public class HandCrankBlockEntity extends GeneratingKineticBlockEntity { } @OnlyIn(Dist.CLIENT) - public Instancer getRenderedHandleInstance(Material material) { + public Model getRenderedHandleInstance() { BlockState blockState = getBlockState(); Direction facing = blockState.getOptionalValue(HandCrankBlock.FACING) .orElse(Direction.UP); - return material.getModel(AllPartialModels.HAND_CRANK_HANDLE, blockState, facing.getOpposite()); + return Models.partial(AllPartialModels.HAND_CRANK_HANDLE, facing.getOpposite()); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankInstance.java b/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankInstance.java deleted file mode 100644 index 93b9c83aee..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankInstance.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.simibubi.create.content.kinetics.crank; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class HandCrankInstance extends SingleRotatingInstance implements DynamicInstance { - - private ModelData crank; - private Direction facing; - - public HandCrankInstance(MaterialManager modelManager, HandCrankBlockEntity blockEntity) { - super(modelManager, blockEntity); - facing = blockState.getValue(BlockStateProperties.FACING); - Instancer model = blockEntity.getRenderedHandleInstance(getTransformMaterial()); - crank = model.createInstance(); - rotateCrank(); - } - - @Override - public void beginFrame() { - if (crank == null) - return; - - rotateCrank(); - } - - private void rotateCrank() { - Direction.Axis axis = facing.getAxis(); - float angle = blockEntity.getIndependentAngle(AnimationTickHolder.getPartialTicks()); - - crank.loadIdentity() - .translate(getInstancePosition()) - .centre() - .rotate(Direction.get(Direction.AxisDirection.POSITIVE, axis), angle) - .unCentre(); - } - - @Override - public void init() { - if (blockEntity.shouldRenderShaft()) - super.init(); - } - - @Override - public void remove() { - if (blockEntity.shouldRenderShaft()) - super.remove(); - if (crank != null) - crank.delete(); - } - - @Override - public void update() { - if (blockEntity.shouldRenderShaft()) - super.update(); - } - - @Override - public void updateLight() { - if (blockEntity.shouldRenderShaft()) - super.updateLight(); - if (crank != null) - relight(pos, crank); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankRenderer.java index bfea5c3c24..7dbfdad3be 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/crank/HandCrankRenderer.java @@ -2,10 +2,10 @@ package com.simibubi.create.content.kinetics.crank; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -23,7 +23,7 @@ public class HandCrankRenderer extends KineticBlockEntityRenderer implements SimpleDynamicVisual { + protected RotatingInstance rotatingModel; + private final TransformedInstance crank; + private final Direction facing; + + public HandCrankVisual(VisualizationContext modelManager, HandCrankBlockEntity blockEntity, float partialTick) { + super(modelManager, blockEntity, partialTick); + facing = blockState.getValue(BlockStateProperties.FACING); + Model model = blockEntity.getRenderedHandleInstance(); + + crank = instancerProvider.instancer(InstanceTypes.TRANSFORMED, model) + .createInstance(); + + rotateCrank(partialTick); + + if (blockEntity.shouldRenderShaft()) { + rotatingModel = instancerProvider.instancer(AllInstanceTypes.ROTATING, VirtualRenderHelper.blockModel(blockState)) + .createInstance(); + setup(rotatingModel); + } + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + rotateCrank(ctx.partialTick()); + } + + private void rotateCrank(float pt) { + Direction.Axis axis = facing.getAxis(); + float angle = blockEntity.getIndependentAngle(pt); + + crank.setIdentityTransform() + .translate(getVisualPosition()) + .center() + .rotate(angle, Direction.get(Direction.AxisDirection.POSITIVE, axis)) + .uncenter() + .setChanged(); + } + + @Override + protected void _delete() { + crank.delete(); + + if (rotatingModel != null) { + rotatingModel.delete(); + } + } + + @Override + public void update(float pt) { + if (rotatingModel != null) + updateRotation(rotatingModel); + } + + @Override + public void updateLight(float partialTick) { + relight(crank, rotatingModel); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(crank); + consumer.accept(rotatingModel); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java index f504471a0e..0ad67c5d61 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java @@ -3,9 +3,6 @@ package com.simibubi.create.content.kinetics.crank; import java.util.List; import com.google.common.collect.ImmutableList; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.core.materials.model.ModelData; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; @@ -19,10 +16,12 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsFormatt import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.Components; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.api.model.Model; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -92,7 +91,7 @@ public class ValveHandleBlockEntity extends HandCrankBlockEntity { @Override public float getIndependentAngle(float partialTicks) { if (inUse == 0 && source != null && getSpeed() != 0) - return KineticBlockEntityRenderer.getAngleForTe(this, worldPosition, + return KineticBlockEntityRenderer.getAngleForBe(this, worldPosition, KineticBlockEntityRenderer.getRotationAxisOf(this)); int step = getBlockState().getOptionalValue(ValveHandleBlock.FACING) @@ -149,8 +148,8 @@ public class ValveHandleBlockEntity extends HandCrankBlockEntity { @Override @OnlyIn(Dist.CLIENT) - public Instancer getRenderedHandleInstance(Material material) { - return material.getModel(getBlockState()); + public Model getRenderedHandleInstance() { + return VirtualRenderHelper.blockModel(getBlockState()); } @Override @@ -215,7 +214,7 @@ public class ValveHandleBlockEntity extends HandCrankBlockEntity { protected Vec3 getSouthLocation() { return VecHelper.voxelSpace(8, 8, 4.5); } - + @Override public boolean testHit(BlockState state, Vec3 localHit) { Vec3 offset = getLocalOffset(state); diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorVisual.java similarity index 59% rename from src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java rename to src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorVisual.java index d7f10491e1..f63a4372d3 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorVisual.java @@ -3,33 +3,34 @@ package com.simibubi.create.content.kinetics.deployer; import static com.simibubi.create.content.kinetics.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.kinetics.base.DirectionalKineticBlock.FACING; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.kinetics.base.IRotate; -import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.foundation.render.AllMaterialSpecs; +import com.simibubi.create.content.kinetics.base.KineticBlockEntityVisual; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.util.Mth; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -public class DeployerActorInstance extends ActorInstance { +public class DeployerActorVisual extends ActorVisual { private final PoseStack stack = new PoseStack(); Direction facing; @@ -39,16 +40,12 @@ public class DeployerActorInstance extends ActorInstance { float xRot; float zRot; - ModelData pole; - ModelData hand; - RotatingData shaft; - - public DeployerActorInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) { - super(materialManager, simulationWorld, context); - - Material mat = materialManager.defaultSolid() - .material(Materials.TRANSFORMED); + TransformedInstance pole; + TransformedInstance hand; + RotatingInstance shaft; + public DeployerActorVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, MovementContext context) { + super(visualizationContext, simulationWorld, context); BlockState state = context.state; DeployerBlockEntity.Mode mode = NBTHelper.readEnum(context.blockEntityData, "Mode", DeployerBlockEntity.Mode.class); PartialModel handPose = DeployerRenderer.getHandPose(mode); @@ -61,23 +58,21 @@ public class DeployerActorInstance extends ActorInstance { xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; zRot = rotatePole ? 90 : 0; - pole = mat.getModel(AllPartialModels.DEPLOYER_POLE, state).createInstance(); - hand = mat.getModel(handPose, state).createInstance(); + pole = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.DEPLOYER_POLE)).createInstance(); + hand = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(handPose)).createInstance(); Direction.Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state); - shaft = materialManager.defaultSolid() - .material(AllMaterialSpecs.ROTATING) - .getModel(KineticBlockEntityInstance.shaft(axis)) + shaft = instancerProvider.instancer(AllInstanceTypes.ROTATING, VirtualRenderHelper.blockModel(KineticBlockEntityVisual.shaft(axis))) .createInstance(); int blockLight = localBlockLight(); shaft.setRotationAxis(axis) .setPosition(context.localPos) - .setBlockLight(blockLight); + .light(blockLight, 0); - pole.setBlockLight(blockLight); - hand.setBlockLight(blockLight); + pole.light(blockLight, 0); + hand.light(blockLight, 0); } @Override @@ -97,7 +92,7 @@ public class DeployerActorInstance extends ActorInstance { Vec3 offset = Vec3.atLowerCornerOf(facing.getNormal()).scale(factor); - TransformStack tstack = TransformStack.cast(stack); + var tstack = TransformStack.of(stack); stack.setIdentity(); tstack.translate(context.localPos) .translate(offset); @@ -105,21 +100,28 @@ public class DeployerActorInstance extends ActorInstance { transformModel(stack, pole, hand, yRot, xRot, zRot); } - static void transformModel(PoseStack stack, ModelData pole, ModelData hand, float yRot, float xRot, float zRot) { - TransformStack tstack = TransformStack.cast(stack); + static void transformModel(PoseStack stack, TransformedInstance pole, TransformedInstance hand, float yRot, float xRot, float zRot) { + var tstack = TransformStack.of(stack); - tstack.centre(); - tstack.rotate(Direction.UP, (float) ((yRot) / 180 * Math.PI)); - tstack.rotate(Direction.EAST, (float) ((xRot) / 180 * Math.PI)); + tstack.center(); + tstack.rotate((float) ((yRot) / 180 * Math.PI), Direction.UP); + tstack.rotate((float) ((xRot) / 180 * Math.PI), Direction.EAST); stack.pushPose(); - tstack.rotate(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI)); - tstack.unCentre(); + tstack.rotate((float) ((zRot) / 180 * Math.PI), Direction.SOUTH); + tstack.uncenter(); pole.setTransform(stack); stack.popPose(); - tstack.unCentre(); + tstack.uncenter(); hand.setTransform(stack); } + + @Override + protected void _delete() { + pole.delete(); + hand.delete(); + shaft.delete(); + } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java index 38f9ba6e67..df4f3a30b7 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java @@ -10,7 +10,6 @@ import java.util.UUID; import javax.annotation.Nullable; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.AllRecipeTypes; @@ -31,6 +30,7 @@ import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerFilterSlot.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerFilterSlot.java index 758d14d8a2..3c238eb794 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerFilterSlot.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerFilterSlot.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.kinetics.deployer; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.world.level.block.state.BlockState; @@ -43,12 +43,12 @@ public class DeployerFilterSlot extends ValueBoxTransform.Sided { float yRot = AngleHelper.horizontalAngle(facing) + 180; if (facing.getAxis() == Axis.Y) - TransformStack.cast(ms) - .rotateY(180 + AngleHelper.horizontalAngle(state.getValue(DeployerBlock.FACING))); + TransformStack.of(ms) + .rotateYDegrees(180 + AngleHelper.horizontalAngle(state.getValue(DeployerBlock.FACING))); - TransformStack.cast(ms) - .rotateY(yRot) - .rotateX(xRot); + TransformStack.of(ms) + .rotateYDegrees(yRot) + .rotateXDegrees(xRot); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerMovementBehaviour.java index 8387c16310..f86cf76375 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerMovementBehaviour.java @@ -8,8 +8,6 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; @@ -17,9 +15,8 @@ import com.simibubi.create.content.contraptions.OrientedContraptionEntity; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.mounted.MountedContraption; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.content.kinetics.deployer.DeployerBlockEntity.Mode; import com.simibubi.create.content.logistics.filter.FilterItemStack; import com.simibubi.create.content.schematics.SchematicInstances; @@ -33,7 +30,10 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -291,21 +291,21 @@ public class DeployerMovementBehaviour implements MovementBehaviour { } @Override - public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, - ContraptionMatrices matrices, MultiBufferSource buffers) { - if (!ContraptionRenderDispatcher.canInstance()) - DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers); + public boolean disableBlockEntityRendering() { + return true; } @Override - public boolean hasSpecialInstancedRendering() { - return true; + public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, + ContraptionMatrices matrices, MultiBufferSource buffers) { + if (!VisualizationManager.supportsVisualization(context.world)) + DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers); } @Nullable @Override - public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, - MovementContext context) { - return new DeployerActorInstance(materialManager, simulationWorld, context); + public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, + MovementContext movementContext) { + return new DeployerActorVisual(visualizationContext, simulationWorld, movementContext); } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerRenderer.java index ec73908a3b..d3f4e012be 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerRenderer.java @@ -3,10 +3,6 @@ package com.simibubi.create.content.kinetics.deployer; import static com.simibubi.create.content.kinetics.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.kinetics.base.DirectionalKineticBlock.FACING; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; @@ -14,7 +10,6 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.content.kinetics.base.IRotate; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; @@ -27,8 +22,13 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -54,7 +54,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer implements DynamicInstance, TickableInstance { +public class DeployerVisual extends ShaftVisual implements SimpleDynamicVisual, SimpleTickableVisual { final Direction facing; final float yRot; final float xRot; final float zRot; - protected final OrientedData pole; + protected final OrientedInstance pole; - protected OrientedData hand; + protected OrientedInstance hand; PartialModel currentHand; float progress; - public DeployerInstance(MaterialManager materialManager, DeployerBlockEntity blockEntity) { - super(materialManager, blockEntity); + public DeployerVisual(VisualizationContext context, DeployerBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); facing = blockState.getValue(FACING); @@ -46,32 +52,31 @@ public class DeployerInstance extends ShaftInstance impleme xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; zRot = rotatePole ? 90 : 0; - pole = getOrientedMaterial().getModel(AllPartialModels.DEPLOYER_POLE, blockState).createInstance(); + pole = instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.DEPLOYER_POLE)).createInstance(); currentHand = this.blockEntity.getHandPose(); - hand = getOrientedMaterial().getModel(currentHand, blockState).createInstance(); + hand = instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(currentHand)).createInstance(); - progress = getProgress(AnimationTickHolder.getPartialTicks()); - updateRotation(pole, hand, yRot, xRot, zRot); - updatePosition(); + progress = getProgress(partialTick); + updateRotation(pole, hand, yRot, xRot, zRot); + updatePosition(); } - @Override - public void tick() { + @Override + public void tick(TickableVisual.Context context) { PartialModel handPose = blockEntity.getHandPose(); if (currentHand != handPose) { currentHand = handPose; - getOrientedMaterial().getModel(currentHand, blockState) + instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(currentHand)) .stealInstance(hand); } } @Override - public void beginFrame() { - - float newProgress = getProgress(AnimationTickHolder.getPartialTicks()); + public void beginFrame(DynamicVisual.Context ctx) { + float newProgress = getProgress(ctx.partialTick()); if (Mth.equal(newProgress, progress)) return; @@ -81,14 +86,14 @@ public class DeployerInstance extends ShaftInstance impleme } @Override - public void updateLight() { - super.updateLight(); - relight(pos, hand, pole); + public void updateLight(float partialTick) { + super.updateLight(partialTick); + relight(hand, pole); } @Override - public void remove() { - super.remove(); + protected void _delete() { + super._delete(); hand.delete(); pole.delete(); } @@ -110,25 +115,34 @@ public class DeployerInstance extends ShaftInstance impleme : currentHand == AllPartialModels.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f; float distance = Math.min(Mth.clamp(progress, 0, 1) * (blockEntity.reach + handLength), 21 / 16f); Vec3i facingVec = facing.getNormal(); - BlockPos blockPos = getInstancePosition(); + BlockPos blockPos = getVisualPosition(); float x = blockPos.getX() + ((float) facingVec.getX()) * distance; float y = blockPos.getY() + ((float) facingVec.getY()) * distance; float z = blockPos.getZ() + ((float) facingVec.getZ()) * distance; - pole.setPosition(x, y, z); - hand.setPosition(x, y, z); + pole.position(x, y, z).setChanged(); + hand.position(x, y, z).setChanged(); } - static void updateRotation(OrientedData pole, OrientedData hand, float yRot, float xRot, float zRot) { + static void updateRotation(OrientedInstance pole, OrientedInstance hand, float yRot, float xRot, float zRot) { Quaternionf q = Axis.YP.rotationDegrees(yRot); q.mul(Axis.XP.rotationDegrees(xRot)); - hand.setRotation(q); + hand.rotation(q) + .setChanged(); q.mul(Axis.ZP.rotationDegrees(zRot)); - pole.setRotation(q); + pole.rotation(q) + .setChanged(); } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(pole); + consumer.accept(hand); + } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillActorInstance.java b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillActorVisual.java similarity index 59% rename from src/main/java/com/simibubi/create/content/kinetics/drill/DrillActorInstance.java rename to src/main/java/com/simibubi/create/content/kinetics/drill/DrillActorVisual.java index 1f22043b1a..0ebdad2e87 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillActorInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillActorVisual.java @@ -2,31 +2,28 @@ package com.simibubi.create.content.kinetics.drill; import org.joml.Quaternionf; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.contraptions.actors.flwdata.ActorData; +import com.simibubi.create.content.contraptions.actors.ActorInstance; import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; -import com.simibubi.create.foundation.render.AllMaterialSpecs; +import com.simibubi.create.content.contraptions.render.ActorVisual; +import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; import net.minecraft.core.Direction; import net.minecraft.util.Mth; import net.minecraft.world.level.block.state.BlockState; -public class DrillActorInstance extends ActorInstance { +public class DrillActorVisual extends ActorVisual { - ActorData drillHead; + ActorInstance drillHead; private final Direction facing; - public DrillActorInstance(MaterialManager materialManager, VirtualRenderWorld contraption, MovementContext context) { - super(materialManager, contraption, context); - - Material material = materialManager.defaultSolid() - .material(AllMaterialSpecs.ACTORS); + public DrillActorVisual(VisualizationContext visualizationContext, VirtualRenderWorld contraption, MovementContext context) { + super(visualizationContext, contraption, context); BlockState state = context.state; @@ -41,19 +38,22 @@ public class DrillActorInstance extends ActorInstance { else eulerY = facing.toYRot() + ((axis == Direction.Axis.X) ? 180 : 0); - drillHead = material.getModel(AllPartialModels.DRILL_HEAD, state).createInstance(); + drillHead = instancerProvider.instancer(AllInstanceTypes.ACTOR, Models.partial(AllPartialModels.DRILL_HEAD)) + .createInstance(); drillHead.setPosition(context.localPos) .setBlockLight(localBlockLight()) .setRotationOffset(0) .setRotationAxis(0, 0, 1) .setLocalRotation(new Quaternionf().rotationXYZ(eulerX * Mth.DEG_TO_RAD, eulerY * Mth.DEG_TO_RAD, 0)) - .setSpeed(getSpeed(facing)); + .setSpeed(getSpeed(facing)) + .setChanged(); } @Override public void beginFrame() { - drillHead.setSpeed(getSpeed(facing)); + drillHead.setSpeed(getSpeed(facing)) + .setChanged(); } protected float getSpeed(Direction facing) { @@ -61,4 +61,9 @@ public class DrillActorInstance extends ActorInstance { return context.getAnimationSpeed(); return 0; } + + @Override + protected void _delete() { + drillHead.delete(); + } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillInstance.java b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillInstance.java deleted file mode 100644 index 8112622bf8..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillInstance.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.simibubi.create.content.kinetics.drill; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class DrillInstance extends SingleRotatingInstance { - - public DrillInstance(MaterialManager materialManager, DrillBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getModel() { - BlockState referenceState = blockEntity.getBlockState(); - Direction facing = referenceState.getValue(BlockStateProperties.FACING); - return getRotatingMaterial().getModel(AllPartialModels.DRILL_HEAD, referenceState, facing); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillMovementBehaviour.java index b7bfc73ec8..d98bb572c2 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillMovementBehaviour.java @@ -2,17 +2,17 @@ package com.simibubi.create.content.kinetics.drill; import javax.annotation.Nullable; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.AllTags; import com.simibubi.create.content.contraptions.behaviour.MovementContext; -import com.simibubi.create.content.contraptions.render.ActorInstance; +import com.simibubi.create.content.contraptions.render.ActorVisual; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; import com.simibubi.create.foundation.damageTypes.CreateDamageSources; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.BlockPos; import net.minecraft.world.damagesource.DamageSource; @@ -38,22 +38,22 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour { } @Override - @OnlyIn(value = Dist.CLIENT) - public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, - ContraptionMatrices matrices, MultiBufferSource buffer) { - if (!ContraptionRenderDispatcher.canInstance()) - DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer); + public boolean disableBlockEntityRendering() { + return true; } @Override - public boolean hasSpecialInstancedRendering() { - return true; + @OnlyIn(value = Dist.CLIENT) + public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, + ContraptionMatrices matrices, MultiBufferSource buffer) { + if (!VisualizationManager.supportsVisualization(context.world)) + DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer); } @Nullable @Override - public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) { - return new DrillActorInstance(materialManager, simulationWorld, context); + public ActorVisual createVisual(VisualizationContext visualizationContext, VirtualRenderWorld simulationWorld, MovementContext movementContext) { + return new DrillActorVisual(visualizationContext, simulationWorld, movementContext); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillRenderer.java index d3efdbe6ea..d4f59f6227 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillRenderer.java @@ -1,17 +1,17 @@ package com.simibubi.create.content.kinetics.drill; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -43,13 +43,13 @@ public class DrillRenderer extends KineticBlockEntityRenderer superBuffer .transform(matrices.getModel()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing)) - .rotateZ(angle) - .unCentre() - .light(matrices.getWorld(), - ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing)) + .rotateXDegrees(AngleHelper.verticalAngle(facing)) + .rotateZDegrees(angle) + .uncenter() + .light(LevelRenderer.getLightColor(renderWorld, context.localPos)) + .useLevelLight(context.world, matrices.getWorld()) .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid())); } diff --git a/src/main/java/com/simibubi/create/content/kinetics/drill/DrillVisual.java b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillVisual.java new file mode 100644 index 0000000000..1d5dbb60c1 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/drill/DrillVisual.java @@ -0,0 +1,24 @@ +package com.simibubi.create.content.kinetics.drill; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class DrillVisual extends SingleRotatingVisual { + + public DrillVisual(VisualizationContext context, DrillBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + Direction facing = blockEntity.getBlockState() + .getValue(BlockStateProperties.FACING); + return Models.partial(AllPartialModels.DRILL_HEAD, facing); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/fan/EncasedFanRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/fan/EncasedFanRenderer.java index ca0c31d99a..58286df27c 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/fan/EncasedFanRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/fan/EncasedFanRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.kinetics.fan; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -27,7 +27,7 @@ public class EncasedFanRenderer extends KineticBlockEntityRenderer { +public class FanVisual extends KineticBlockEntityVisual { - protected final RotatingData shaft; - protected final RotatingData fan; + protected final RotatingInstance shaft; + protected final RotatingInstance fan; final Direction direction; private final Direction opposite; - public FanInstance(MaterialManager materialManager, EncasedFanBlockEntity blockEntity) { - super(materialManager, blockEntity); + public FanVisual(VisualizationContext context, EncasedFanBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); direction = blockState.getValue(FACING); opposite = direction.getOpposite(); - shaft = getRotatingMaterial().getModel(AllPartialModels.SHAFT_HALF, blockState, opposite).createInstance(); - fan = materialManager.defaultCutout() - .material(AllMaterialSpecs.ROTATING) - .getModel(AllPartialModels.ENCASED_FAN_INNER, blockState, opposite) + shaft = instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.SHAFT_HALF, opposite)).createInstance(); + fan = instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.ENCASED_FAN_INNER, opposite)) .createInstance(); setup(shaft); @@ -45,13 +47,13 @@ public class FanInstance extends KineticBlockEntityInstance consumer) { + consumer.accept(shaft); + consumer.accept(fan); + } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java b/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java deleted file mode 100644 index 4f97923d9d..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.simibubi.create.content.kinetics.flywheel; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.core.Direction; - -public class FlywheelInstance extends KineticBlockEntityInstance implements DynamicInstance { - - protected final RotatingData shaft; - protected final ModelData wheel; - protected float lastAngle = Float.NaN; - - public FlywheelInstance(MaterialManager materialManager, FlywheelBlockEntity blockEntity) { - super(materialManager, blockEntity); - - shaft = setup(getRotatingMaterial().getModel(shaft()) - .createInstance()); - wheel = getTransformMaterial().getModel(blockState) - .createInstance(); - - animate(blockEntity.angle); - } - - @Override - public void beginFrame() { - - float partialTicks = AnimationTickHolder.getPartialTicks(); - - float speed = blockEntity.visualSpeed.getValue(partialTicks) * 3 / 10f; - float angle = blockEntity.angle + speed * partialTicks; - - if (Math.abs(angle - lastAngle) < 0.001) - return; - - animate(angle); - - lastAngle = angle; - } - - private void animate(float angle) { - PoseStack ms = new PoseStack(); - TransformStack msr = TransformStack.cast(ms); - - msr.translate(getInstancePosition()); - msr.centre() - .rotate(Direction.get(Direction.AxisDirection.POSITIVE, axis), AngleHelper.rad(angle)) - .unCentre(); - - wheel.setTransform(ms); - } - - @Override - public void update() { - updateRotation(shaft); - } - - @Override - public void updateLight() { - relight(pos, shaft, wheel); - } - - @Override - public void remove() { - shaft.delete(); - wheel.delete(); - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelRenderer.java index f563916f34..047f649c3e 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.kinetics.flywheel; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; @@ -8,6 +7,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -24,7 +24,7 @@ public class FlywheelRenderer extends KineticBlockEntityRenderer implements SimpleDynamicVisual { + + protected final RotatingInstance shaft; + protected final TransformedInstance wheel; + protected float lastAngle = Float.NaN; + + public FlywheelVisual(VisualizationContext context, FlywheelBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + shaft = setup(instancerProvider.instancer(AllInstanceTypes.ROTATING, VirtualRenderHelper.blockModel(shaft())) + .createInstance()); + wheel = instancerProvider.instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(blockState)) + .createInstance(); + + animate(blockEntity.angle); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + + float partialTicks = ctx.partialTick(); + + float speed = blockEntity.visualSpeed.getValue(partialTicks) * 3 / 10f; + float angle = blockEntity.angle + speed * partialTicks; + + if (Math.abs(angle - lastAngle) < 0.001) + return; + + animate(angle); + + lastAngle = angle; + } + + private void animate(float angle) { + PoseStack ms = new PoseStack(); + var msr = TransformStack.of(ms); + + msr.translate(getVisualPosition()); + msr.center() + .rotate(AngleHelper.rad(angle), Direction.get(Direction.AxisDirection.POSITIVE, axis)) + .uncenter(); + + wheel.setTransform(ms) + .setChanged(); + } + + @Override + public void update(float pt) { + updateRotation(shaft); + } + + @Override + public void updateLight(float partialTick) { + relight(shaft, wheel); + } + + @Override + protected void _delete() { + shaft.delete(); + wheel.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(shaft); + consumer.accept(wheel); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeInstance.java b/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeInstance.java deleted file mode 100644 index 03d9b9dfc6..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeInstance.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.simibubi.create.content.kinetics.gauge; - -import java.util.ArrayList; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.ShaftInstance; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.Couple; -import com.simibubi.create.foundation.utility.Iterate; - -import net.minecraft.core.Direction; -import net.minecraft.util.Mth; - -public abstract class GaugeInstance extends ShaftInstance implements DynamicInstance { - - protected final ArrayList faces; - - protected PoseStack ms; - - protected GaugeInstance(MaterialManager materialManager, GaugeBlockEntity blockEntity) { - super(materialManager, blockEntity); - - faces = new ArrayList<>(2); - - GaugeBlock gaugeBlock = (GaugeBlock) blockState.getBlock(); - - Instancer dialModel = getTransformMaterial().getModel(AllPartialModels.GAUGE_DIAL, blockState); - Instancer headModel = getHeadModel(); - - ms = new PoseStack(); - TransformStack msr = TransformStack.cast(ms); - msr.translate(getInstancePosition()); - - float progress = Mth.lerp(AnimationTickHolder.getPartialTicks(), blockEntity.prevDialState, blockEntity.dialState); - - for (Direction facing : Iterate.directions) { - if (!gaugeBlock.shouldRenderHeadOnFace(world, pos, blockState, facing)) - continue; - - DialFace face = makeFace(facing, dialModel, headModel); - - faces.add(face); - - face.setupTransform(msr, progress); - } - } - - private DialFace makeFace(Direction face, Instancer dialModel, Instancer headModel) { - return new DialFace(face, dialModel.createInstance(), headModel.createInstance()); - } - - @Override - public void beginFrame() { - GaugeBlockEntity gaugeBlockEntity = (GaugeBlockEntity) blockEntity; - - if (Mth.equal(gaugeBlockEntity.prevDialState, gaugeBlockEntity.dialState)) - return; - - float progress = Mth.lerp(AnimationTickHolder.getPartialTicks(), gaugeBlockEntity.prevDialState, gaugeBlockEntity.dialState); - - TransformStack msr = TransformStack.cast(ms); - - for (DialFace faceEntry : faces) { - faceEntry.updateTransform(msr, progress); - } - } - - @Override - public void updateLight() { - super.updateLight(); - - relight(pos, faces.stream() - .flatMap(Couple::stream)); - } - - @Override - public void remove() { - super.remove(); - - faces.forEach(DialFace::delete); - } - - protected abstract Instancer getHeadModel(); - - private class DialFace extends Couple { - - Direction face; - - public DialFace(Direction face, ModelData first, ModelData second) { - super(first, second); - this.face = face; - } - - private void setupTransform(TransformStack msr, float progress) { - float dialPivot = 5.75f / 16; - - msr.pushPose(); - rotateToFace(msr); - - getSecond().setTransform(ms); - - msr.translate(0, dialPivot, dialPivot) - .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)) - .translate(0, -dialPivot, -dialPivot); - - getFirst().setTransform(ms); - - msr.popPose(); - } - - private void updateTransform(TransformStack msr, float progress) { - float dialPivot = 5.75f / 16; - - msr.pushPose(); - - rotateToFace(msr) - .translate(0, dialPivot, dialPivot) - .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)) - .translate(0, -dialPivot, -dialPivot); - - getFirst().setTransform(ms); - - msr.popPose(); - } - - protected TransformStack rotateToFace(TransformStack msr) { - return msr.centre() - .rotate(Direction.UP, (float) ((-face.toYRot() - 90) / 180 * Math.PI)) - .unCentre(); - } - - private void delete() { - getFirst().delete(); - getSecond().delete(); - } - } - - public static class Speed extends GaugeInstance { - public Speed(MaterialManager materialManager, GaugeBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getHeadModel() { - return getTransformMaterial().getModel(AllPartialModels.GAUGE_HEAD_SPEED, blockState); - } - } - - public static class Stress extends GaugeInstance { - public Stress(MaterialManager materialManager, GaugeBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getHeadModel() { - return getTransformMaterial().getModel(AllPartialModels.GAUGE_HEAD_STRESS, blockState); - } - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeRenderer.java index 404454fe88..fad7ef4125 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.kinetics.gauge; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -11,6 +9,8 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -38,20 +38,19 @@ public class GaugeRenderer extends ShaftRenderer { @Override protected void renderSafe(GaugeBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.canUseInstancing(be.getLevel())) return; + if (VisualizationManager.supportsVisualization(be.getLevel())) return; super.renderSafe(be, partialTicks, ms, buffer, light, overlay); BlockState gaugeState = be.getBlockState(); - GaugeBlockEntity gaugeBE = (GaugeBlockEntity) be; - PartialModel partialModel = (type == Type.SPEED ? AllPartialModels.GAUGE_HEAD_SPEED : AllPartialModels.GAUGE_HEAD_STRESS); + PartialModel partialModel = (type == Type.SPEED ? AllPartialModels.GAUGE_HEAD_SPEED : AllPartialModels.GAUGE_HEAD_STRESS); SuperByteBuffer headBuffer = CachedBufferer.partial(partialModel, gaugeState); SuperByteBuffer dialBuffer = CachedBufferer.partial(AllPartialModels.GAUGE_DIAL, gaugeState); float dialPivot = 5.75f / 16; - float progress = Mth.lerp(partialTicks, gaugeBE.prevDialState, gaugeBE.dialState); + float progress = Mth.lerp(partialTicks, be.prevDialState, be.dialState); for (Direction facing : Iterate.directions) { if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(be.getLevel(), be.getBlockPos(), gaugeState, @@ -60,7 +59,7 @@ public class GaugeRenderer extends ShaftRenderer { VertexConsumer vb = buffer.getBuffer(RenderType.solid()); rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot) - .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)) + .rotate((float) (Math.PI / 2 * -progress), Direction.EAST) .translate(0, -dialPivot, -dialPivot) .light(light) .renderInto(ms, vb); @@ -70,7 +69,7 @@ public class GaugeRenderer extends ShaftRenderer { } protected SuperByteBuffer rotateBufferTowards(SuperByteBuffer buffer, Direction target) { - return buffer.rotateCentered(Direction.UP, (float) ((-target.toYRot() - 90) / 180 * Math.PI)); + return buffer.rotateCentered((float) ((-target.toYRot() - 90) / 180 * Math.PI), Direction.UP); } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeVisual.java b/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeVisual.java new file mode 100644 index 0000000000..f758cd493d --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/gauge/GaugeVisual.java @@ -0,0 +1,174 @@ +package com.simibubi.create.content.kinetics.gauge; + +import java.util.ArrayList; +import java.util.function.Consumer; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.ShaftVisual; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.Couple; +import com.simibubi.create.foundation.utility.Iterate; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.FlatLit; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; + +public abstract class GaugeVisual extends ShaftVisual implements SimpleDynamicVisual { + + protected final ArrayList faces = new ArrayList<>(2); + + protected final PoseStack ms = new PoseStack(); + + protected GaugeVisual(VisualizationContext context, GaugeBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + GaugeBlock gaugeBlock = (GaugeBlock) blockState.getBlock(); + + Instancer dialModel = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.GAUGE_DIAL)); + Instancer headModel = getHeadModel(); + + var msr = TransformStack.of(ms); + msr.translate(getVisualPosition()); + + float progress = Mth.lerp(AnimationTickHolder.getPartialTicks(), blockEntity.prevDialState, blockEntity.dialState); + + for (Direction facing : Iterate.directions) { + if (!gaugeBlock.shouldRenderHeadOnFace(level, pos, blockState, facing)) + continue; + + DialFace face = makeFace(facing, dialModel, headModel); + + faces.add(face); + + face.setupTransform(msr, progress); + } + } + + private DialFace makeFace(Direction face, Instancer dialModel, Instancer headModel) { + return new DialFace(face, dialModel.createInstance(), headModel.createInstance()); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + if (Mth.equal(blockEntity.prevDialState, blockEntity.dialState)) + return; + + float progress = Mth.lerp(ctx.partialTick(), blockEntity.prevDialState, blockEntity.dialState); + + var msr = TransformStack.of(ms); + + for (DialFace faceEntry : faces) { + faceEntry.updateTransform(msr, progress); + } + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + + relight(faces.stream() + .flatMap(Couple::stream).toArray(FlatLit[]::new)); + } + + @Override + protected void _delete() { + super._delete(); + + faces.forEach(DialFace::delete); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + for (DialFace face : faces) { + face.forEach(consumer); + } + } + + protected abstract Instancer getHeadModel(); + + protected class DialFace extends Couple { + + Direction face; + + public DialFace(Direction face, TransformedInstance first, TransformedInstance second) { + super(first, second); + this.face = face; + } + + private void setupTransform(TransformStack msr, float progress) { + float dialPivot = 5.75f / 16; + + msr.pushPose(); + rotateToFace(msr); + + getSecond().setTransform(ms).setChanged(); + + msr.translate(0, dialPivot, dialPivot) + .rotate((float) (Math.PI / 2 * -progress), Direction.EAST) + .translate(0, -dialPivot, -dialPivot); + + getFirst().setTransform(ms).setChanged(); + + msr.popPose(); + } + + private void updateTransform(TransformStack msr, float progress) { + float dialPivot = 5.75f / 16; + + msr.pushPose(); + + rotateToFace(msr) + .translate(0, dialPivot, dialPivot) + .rotate((float) (Math.PI / 2 * -progress), Direction.EAST) + .translate(0, -dialPivot, -dialPivot); + + getFirst().setTransform(ms).setChanged(); + + msr.popPose(); + } + + protected TransformStack rotateToFace(TransformStack msr) { + return msr.center() + .rotate((float) ((-face.toYRot() - 90) / 180 * Math.PI), Direction.UP) + .uncenter(); + } + + private void delete() { + getFirst().delete(); + getSecond().delete(); + } + } + + public static class Speed extends GaugeVisual { + public Speed(VisualizationContext context, GaugeBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Instancer getHeadModel() { + return instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.GAUGE_HEAD_SPEED)); + } + } + + public static class Stress extends GaugeVisual { + public Stress(VisualizationContext context, GaugeBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Instancer getHeadModel() { + return instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.GAUGE_HEAD_STRESS)); + } + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxRenderer.java index 7a1260830c..4f0f4854d0 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.kinetics.gearbox; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; @@ -9,6 +8,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -26,7 +26,7 @@ public class GearboxRenderer extends KineticBlockEntityRenderer { +public class GearboxVisual extends KineticBlockEntityVisual { - protected final EnumMap keys; + protected final EnumMap keys; protected Direction sourceFacing; - public GearboxInstance(MaterialManager materialManager, GearboxBlockEntity blockEntity) { - super(materialManager, blockEntity); + public GearboxVisual(VisualizationContext context, GearboxBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); keys = new EnumMap<>(Direction.class); final Direction.Axis boxAxis = blockState.getValue(BlockStateProperties.AXIS); - int blockLight = world.getBrightness(LightLayer.BLOCK, pos); - int skyLight = world.getBrightness(LightLayer.SKY, pos); + int blockLight = level.getBrightness(LightLayer.BLOCK, pos); + int skyLight = level.getBrightness(LightLayer.SKY, pos); updateSourceFacing(); - Material rotatingMaterial = getRotatingMaterial(); - for (Direction direction : Iterate.directions) { final Direction.Axis axis = direction.getAxis(); if (boxAxis == axis) continue; - Instancer shaft = rotatingMaterial.getModel(AllPartialModels.SHAFT_HALF, blockState, direction); + RotatingInstance key = instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.SHAFT_HALF, direction)) + .createInstance(); - RotatingData key = shaft.createInstance(); - - key.setRotationAxis(Direction.get(Direction.AxisDirection.POSITIVE, axis).step()) + key.setRotationAxis(axis) .setRotationalSpeed(getSpeed(direction)) .setRotationOffset(getRotationOffset(axis)).setColor(blockEntity) - .setPosition(getInstancePosition()) - .setBlockLight(blockLight) - .setSkyLight(skyLight); + .setPosition(getVisualPosition()) + .light(blockLight, skyLight) + .setChanged(); keys.put(direction, key); } @@ -77,9 +77,9 @@ public class GearboxInstance extends KineticBlockEntityInstance key : keys.entrySet()) { + for (Map.Entry key : keys.entrySet()) { Direction direction = key.getKey(); Direction.Axis axis = direction.getAxis(); @@ -88,13 +88,19 @@ public class GearboxInstance extends KineticBlockEntityInstance consumer) { + keys.values() + .forEach(consumer); + } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmBlockEntity.java index c60d21a028..81a60f8682 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmBlockEntity.java @@ -5,7 +5,6 @@ import java.util.List; import javax.annotation.Nullable; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.ITransformableBlockEntity; import com.simibubi.create.content.contraptions.StructureTransform; @@ -26,6 +25,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.SectionPos; @@ -552,7 +552,7 @@ public class ArmBlockEntity extends KineticBlockEntity implements ITransformable return; if (hadGoggles != goggles) - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> VisualizationHelper.queueUpdate(this)); boolean ceiling = isOnCeiling(); if (interactionPointTagBefore == null || interactionPointTagBefore.size() != interactionPointTag.size()) diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInstance.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInstance.java deleted file mode 100644 index 889620fe81..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInstance.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.simibubi.create.content.kinetics.mechanicalArm; - -import java.util.ArrayList; - -import com.google.common.collect.Lists; -import com.jozufozu.flywheel.api.InstanceData; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.Color; -import com.simibubi.create.foundation.utility.Iterate; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.ItemRenderer; -import net.minecraft.util.Mth; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.ItemStack; - -public class ArmInstance extends SingleRotatingInstance implements DynamicInstance { - - final ModelData base; - final ModelData lowerBody; - final ModelData upperBody; - ModelData claw; - - private final ArrayList clawGrips; - - private final ArrayList models; - private final Boolean ceiling; - - private boolean firstRender = true; - - private float baseAngle = Float.NaN; - private float lowerArmAngle = Float.NaN; - private float upperArmAngle = Float.NaN; - private float headAngle = Float.NaN; - - public ArmInstance(MaterialManager materialManager, ArmBlockEntity blockEntity) { - super(materialManager, blockEntity); - - Material mat = getTransformMaterial(); - - base = mat.getModel(AllPartialModels.ARM_BASE, blockState) - .createInstance(); - lowerBody = mat.getModel(AllPartialModels.ARM_LOWER_BODY, blockState) - .createInstance(); - upperBody = mat.getModel(AllPartialModels.ARM_UPPER_BODY, blockState) - .createInstance(); - claw = mat - .getModel(blockEntity.goggles ? AllPartialModels.ARM_CLAW_BASE_GOGGLES : AllPartialModels.ARM_CLAW_BASE, - blockState) - .createInstance(); - - ModelData clawGrip1 = mat.getModel(AllPartialModels.ARM_CLAW_GRIP_UPPER, blockState) - .createInstance(); - ModelData clawGrip2 = mat.getModel(AllPartialModels.ARM_CLAW_GRIP_LOWER, blockState) - .createInstance(); - - clawGrips = Lists.newArrayList(clawGrip1, clawGrip2); - models = Lists.newArrayList(base, lowerBody, upperBody, claw, clawGrip1, clawGrip2); - ceiling = blockState.getValue(ArmBlock.CEILING); - - animateArm(false); - } - - @Override - public void beginFrame() { - if (blockEntity.phase == ArmBlockEntity.Phase.DANCING && blockEntity.getSpeed() != 0) { - animateArm(true); - firstRender = true; - return; - } - - float pt = AnimationTickHolder.getPartialTicks(); - - float baseAngleNow = blockEntity.baseAngle.getValue(pt); - float lowerArmAngleNow = blockEntity.lowerArmAngle.getValue(pt); - float upperArmAngleNow = blockEntity.upperArmAngle.getValue(pt); - float headAngleNow = blockEntity.headAngle.getValue(pt); - - boolean settled = Mth.equal(baseAngle, baseAngleNow) && Mth.equal(lowerArmAngle, lowerArmAngleNow) - && Mth.equal(upperArmAngle, upperArmAngleNow) && Mth.equal(headAngle, headAngleNow); - - this.baseAngle = baseAngleNow; - this.lowerArmAngle = lowerArmAngleNow; - this.upperArmAngle = upperArmAngleNow; - this.headAngle = headAngleNow; - - if (!settled || firstRender) - animateArm(false); - - if (firstRender) - firstRender = false; - } - - private void animateArm(boolean rave) { - float baseAngle; - float lowerArmAngle; - float upperArmAngle; - float headAngle; - int color; - - if (rave) { - float renderTick = - AnimationTickHolder.getRenderTime(blockEntity.getLevel()) + (blockEntity.hashCode() % 64); - baseAngle = (renderTick * 10) % 360; - lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15); - upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95); - headAngle = -lowerArmAngle; - color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100) - .getRGB(); - } else { - baseAngle = this.baseAngle; - lowerArmAngle = this.lowerArmAngle - 135; - upperArmAngle = this.upperArmAngle - 90; - headAngle = this.headAngle; - color = 0xFFFFFF; - } - - PoseStack msLocal = new PoseStack(); - TransformStack msr = TransformStack.cast(msLocal); - msr.translate(getInstancePosition()); - msr.centre(); - - if (ceiling) - msr.rotateX(180); - - ArmRenderer.transformBase(msr, baseAngle); - base.setTransform(msLocal); - - ArmRenderer.transformLowerArm(msr, lowerArmAngle); - lowerBody.setTransform(msLocal) - .setColor(color); - - ArmRenderer.transformUpperArm(msr, upperArmAngle); - upperBody.setTransform(msLocal) - .setColor(color); - - ArmRenderer.transformHead(msr, headAngle); - - if (ceiling && blockEntity.goggles) - msr.rotateZ(180); - - claw.setTransform(msLocal); - - if (ceiling && blockEntity.goggles) - msr.rotateZ(180); - - ItemStack item = blockEntity.heldItem; - ItemRenderer itemRenderer = Minecraft.getInstance() - .getItemRenderer(); - boolean hasItem = !item.isEmpty(); - boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) - && itemRenderer.getModel(item, Minecraft.getInstance().level, null, 0) - .isGui3d(); - - for (int index : Iterate.zeroAndOne) { - msLocal.pushPose(); - int flip = index * 2 - 1; - ArmRenderer.transformClawHalf(msr, hasItem, isBlockItem, flip); - clawGrips.get(index) - .setTransform(msLocal); - msLocal.popPose(); - } - } - - @Override - public void update() { - super.update(); - models.remove(claw); - claw.delete(); - claw = getTransformMaterial() - .getModel(blockEntity.goggles ? AllPartialModels.ARM_CLAW_BASE_GOGGLES : AllPartialModels.ARM_CLAW_BASE, - blockState) - .createInstance(); - models.add(claw); - updateLight(); - animateArm(false); - } - - @Override - public void updateLight() { - super.updateLight(); - - relight(pos, models.stream()); - } - - @Override - protected Instancer getModel() { - return getRotatingMaterial().getModel(AllPartialModels.ARM_COG, blockEntity.getBlockState()); - } - - @Override - public void remove() { - super.remove(); - models.forEach(InstanceData::delete); - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmRenderer.java index d8462223cf..9ddf901dc0 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.kinetics.mechanicalArm; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -13,6 +11,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -38,7 +38,7 @@ public class ArmRenderer extends KineticBlockEntityRenderer { ItemStack item = be.heldItem; boolean hasItem = !item.isEmpty(); - boolean usingFlywheel = Backend.canUseInstancing(be.getLevel()); + boolean usingFlywheel = VisualizationManager.supportsVisualization(be.getLevel()); if (usingFlywheel && !hasItem) return; @@ -53,7 +53,7 @@ public class ArmRenderer extends KineticBlockEntityRenderer { BlockState blockState = be.getBlockState(); PoseStack msLocal = new PoseStack(); - TransformStack msr = TransformStack.cast(msLocal); + var msr = TransformStack.of(msLocal); float baseAngle; float lowerArmAngle; @@ -79,10 +79,10 @@ public class ArmRenderer extends KineticBlockEntityRenderer { color = 0xFFFFFF; } - msr.centre(); + msr.center(); if (inverted) - msr.rotateX(180); + msr.rotateXDegrees(180); if (usingFlywheel) doItemTransforms(msr, baseAngle, lowerArmAngle, upperArmAngle, headAngle); @@ -93,7 +93,7 @@ public class ArmRenderer extends KineticBlockEntityRenderer { if (hasItem) { ms.pushPose(); float itemScale = isBlockItem ? .5f : .625f; - msr.rotateX(90); + msr.rotateXDegrees(90); msLocal.translate(0, isBlockItem ? -9 / 16f : -10 / 16f, 0); msLocal.scale(itemScale, itemScale, itemScale); @@ -143,13 +143,13 @@ public class ArmRenderer extends KineticBlockEntityRenderer { transformHead(msr, headAngle); if (inverted) - msr.rotateZ(180); + msr.rotateZDegrees(180); claw.transform(msLocal) .renderInto(ms, builder); if (inverted) - msr.rotateZ(180); + msr.rotateZDegrees(180); for (int flip : Iterate.positiveAndNegative) { msLocal.pushPose(); @@ -175,22 +175,22 @@ public class ArmRenderer extends KineticBlockEntityRenderer { public static void transformHead(TransformStack msr, float headAngle) { msr.translate(0, 0, -15 / 16d); - msr.rotateX(headAngle - 45f); + msr.rotateXDegrees(headAngle - 45f); } public static void transformUpperArm(TransformStack msr, float upperArmAngle) { msr.translate(0, 0, -14 / 16d); - msr.rotateX(upperArmAngle - 90); + msr.rotateXDegrees(upperArmAngle - 90); } public static void transformLowerArm(TransformStack msr, float lowerArmAngle) { msr.translate(0, 2 / 16d, 0); - msr.rotateX(lowerArmAngle + 135); + msr.rotateXDegrees(lowerArmAngle + 135); } public static void transformBase(TransformStack msr, float baseAngle) { msr.translate(0, 4 / 16d, 0); - msr.rotateY(baseAngle); + msr.rotateYDegrees(baseAngle); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmVisual.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmVisual.java new file mode 100644 index 0000000000..47e1e40e15 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmVisual.java @@ -0,0 +1,208 @@ +package com.simibubi.create.content.kinetics.mechanicalArm; + +import java.util.ArrayList; +import java.util.function.Consumer; + +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.Color; +import com.simibubi.create.foundation.utility.Iterate; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.AbstractInstance; +import dev.engine_room.flywheel.lib.instance.FlatLit; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.util.Mth; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; + +public class ArmVisual extends SingleRotatingVisual implements SimpleDynamicVisual { + + final TransformedInstance base; + final TransformedInstance lowerBody; + final TransformedInstance upperBody; + TransformedInstance claw; + + private final ArrayList clawGrips; + private final ArrayList models; + private final Boolean ceiling; + + private boolean firstRender = true; + + private float baseAngle = Float.NaN; + private float lowerArmAngle = Float.NaN; + private float upperArmAngle = Float.NaN; + private float headAngle = Float.NaN; + + public ArmVisual(VisualizationContext context, ArmBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + base = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ARM_BASE)) + .createInstance(); + lowerBody = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ARM_LOWER_BODY)) + .createInstance(); + upperBody = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ARM_UPPER_BODY)) + .createInstance(); + claw = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(blockEntity.goggles ? AllPartialModels.ARM_CLAW_BASE_GOGGLES : AllPartialModels.ARM_CLAW_BASE)) + .createInstance(); + + TransformedInstance clawGrip1 = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ARM_CLAW_GRIP_UPPER)) + .createInstance(); + TransformedInstance clawGrip2 = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ARM_CLAW_GRIP_LOWER)) + .createInstance(); + + clawGrips = Lists.newArrayList(clawGrip1, clawGrip2); + models = Lists.newArrayList(base, lowerBody, upperBody, claw, clawGrip1, clawGrip2); + ceiling = blockState.getValue(ArmBlock.CEILING); + + animateArm(); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + if (blockEntity.phase == ArmBlockEntity.Phase.DANCING && blockEntity.getSpeed() != 0) { + animateRave(ctx.partialTick()); + firstRender = true; + return; + } + + float pt = ctx.partialTick(); + + float baseAngleNow = blockEntity.baseAngle.getValue(pt); + float lowerArmAngleNow = blockEntity.lowerArmAngle.getValue(pt); + float upperArmAngleNow = blockEntity.upperArmAngle.getValue(pt); + float headAngleNow = blockEntity.headAngle.getValue(pt); + + boolean settled = Mth.equal(baseAngle, baseAngleNow) && Mth.equal(lowerArmAngle, lowerArmAngleNow) + && Mth.equal(upperArmAngle, upperArmAngleNow) && Mth.equal(headAngle, headAngleNow); + + this.baseAngle = baseAngleNow; + this.lowerArmAngle = lowerArmAngleNow; + this.upperArmAngle = upperArmAngleNow; + this.headAngle = headAngleNow; + + if (!settled || firstRender) + animateArm(); + + if (firstRender) + firstRender = false; + } + + private void animateRave(float partialTick) { + var ticks = AnimationTickHolder.getTicks(blockEntity.getLevel()); + float renderTick = ticks + partialTick + (blockEntity.hashCode() % 64); + + float baseAngle = (renderTick * 10) % 360; + float lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15); + float upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95); + float headAngle = -lowerArmAngle; + int color = Color.rainbowColor(ticks * 100) + .getRGB(); + updateAngles(baseAngle, lowerArmAngle, upperArmAngle, headAngle, color); + } + + private void animateArm() { + updateAngles(this.baseAngle, this.lowerArmAngle - 135, this.upperArmAngle - 90, this.headAngle, 0xFFFFFF); + } + + private void updateAngles(float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, int color) { + PoseStack msLocal = new PoseStack(); + var msr = TransformStack.of(msLocal); + msr.translate(getVisualPosition()); + msr.center(); + + if (ceiling) + msr.rotateXDegrees(180); + + ArmRenderer.transformBase(msr, baseAngle); + base.setTransform(msLocal) + .setChanged(); + + ArmRenderer.transformLowerArm(msr, lowerArmAngle); + lowerBody.setTransform(msLocal) + .colorRgb(color) + .setChanged(); + + ArmRenderer.transformUpperArm(msr, upperArmAngle); + upperBody.setTransform(msLocal) + .colorRgb(color) + .setChanged(); + + ArmRenderer.transformHead(msr, headAngle); + + if (ceiling && blockEntity.goggles) + msr.rotateZDegrees(180); + + claw.setTransform(msLocal) + .setChanged(); + + if (ceiling && blockEntity.goggles) + msr.rotateZDegrees(180); + + ItemStack item = blockEntity.heldItem; + ItemRenderer itemRenderer = Minecraft.getInstance() + .getItemRenderer(); + boolean hasItem = !item.isEmpty(); + boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) + && itemRenderer.getModel(item, Minecraft.getInstance().level, null, 0) + .isGui3d(); + + for (int index : Iterate.zeroAndOne) { + msLocal.pushPose(); + int flip = index * 2 - 1; + ArmRenderer.transformClawHalf(msr, hasItem, isBlockItem, flip); + clawGrips.get(index) + .setTransform(msLocal) + .setChanged(); + msLocal.popPose(); + } + } + + @Override + public void update(float pt) { + super.update(pt); + models.remove(claw); + claw.delete(); + claw = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(blockEntity.goggles ? AllPartialModels.ARM_CLAW_BASE_GOGGLES : AllPartialModels.ARM_CLAW_BASE)) + .createInstance(); + models.add(claw); + updateLight(pt); + animateArm(); + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + + relight(models.toArray(FlatLit[]::new)); + } + + @Override + protected Model model() { + return Models.partial(AllPartialModels.ARM_COG); + } + + @Override + protected void _delete() { + super._delete(); + models.forEach(AbstractInstance::delete); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + models.forEach(consumer); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/millstone/MillstoneCogInstance.java b/src/main/java/com/simibubi/create/content/kinetics/millstone/MillstoneCogInstance.java deleted file mode 100644 index 545ebe8d20..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/millstone/MillstoneCogInstance.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.simibubi.create.content.kinetics.millstone; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -public class MillstoneCogInstance extends SingleRotatingInstance { - - public MillstoneCogInstance(MaterialManager materialManager, MillstoneBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getModel() { - return getRotatingMaterial().getModel(AllPartialModels.MILLSTONE_COG, blockEntity.getBlockState()); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/millstone/MillstoneCogVisual.java b/src/main/java/com/simibubi/create/content/kinetics/millstone/MillstoneCogVisual.java new file mode 100644 index 0000000000..cc2a6aea18 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/millstone/MillstoneCogVisual.java @@ -0,0 +1,20 @@ +package com.simibubi.create.content.kinetics.millstone; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; + +public class MillstoneCogVisual extends SingleRotatingVisual { + + public MillstoneCogVisual(VisualizationContext context, MillstoneBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + return Models.partial(AllPartialModels.MILLSTONE_COG); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerRenderer.java index c5ebf0c3df..297c94024d 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.kinetics.mixer; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -9,6 +8,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -30,7 +30,7 @@ public class MechanicalMixerRenderer extends KineticBlockEntityRenderer getCogModel() { - return materialManager.defaultSolid() - .material(AllMaterialSpecs.ROTATING) - .getModel(AllPartialModels.SHAFTLESS_COGWHEEL, blockEntity.getBlockState()); - } - - @Override - public void beginFrame() { - - float renderedHeadOffset = getRenderedHeadOffset(); - - transformPole(renderedHeadOffset); - transformHead(renderedHeadOffset); - } - - private void transformHead(float renderedHeadOffset) { - float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks()); - - mixerHead.setPosition(getInstancePosition()) - .nudge(0, -renderedHeadOffset, 0) - .setRotationalSpeed(speed * 2); - } - - private void transformPole(float renderedHeadOffset) { - mixerPole.setPosition(getInstancePosition()) - .nudge(0, -renderedHeadOffset, 0); - } - - private float getRenderedHeadOffset() { - return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks()); - } - - @Override - public void updateLight() { - super.updateLight(); - - relight(pos.below(), mixerHead); - relight(pos, mixerPole); - } - - @Override - public void remove() { - super.remove(); - mixerHead.delete(); - mixerPole.delete(); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/mixer/MixerVisual.java b/src/main/java/com/simibubi/create/content/kinetics/mixer/MixerVisual.java new file mode 100644 index 0000000000..74aeb1c4e4 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/mixer/MixerVisual.java @@ -0,0 +1,94 @@ +package com.simibubi.create.content.kinetics.mixer; + +import java.util.function.Consumer; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.content.kinetics.simpleRelays.encased.EncasedCogVisual; +import com.simibubi.create.foundation.render.AllInstanceTypes; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.OrientedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import net.minecraft.core.Direction; + +public class MixerVisual extends EncasedCogVisual implements SimpleDynamicVisual { + + private final RotatingInstance mixerHead; + private final OrientedInstance mixerPole; + private final MechanicalMixerBlockEntity mixer; + + public MixerVisual(VisualizationContext context, MechanicalMixerBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, false, partialTick); + this.mixer = blockEntity; + + mixerHead = instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.MECHANICAL_MIXER_HEAD)) + .createInstance(); + + mixerHead.setRotationAxis(Direction.Axis.Y); + + mixerPole = instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.MECHANICAL_MIXER_POLE)) + .createInstance(); + + animate(partialTick); + } + + @Override + protected Model getCogModel() { + return Models.partial(AllPartialModels.SHAFTLESS_COGWHEEL); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + animate(ctx.partialTick()); + } + + private void animate(float pt) { + float renderedHeadOffset = mixer.getRenderedHeadOffset(pt); + + transformPole(renderedHeadOffset); + transformHead(renderedHeadOffset, pt); + } + + private void transformHead(float renderedHeadOffset, float pt) { + float speed = mixer.getRenderedHeadRotationSpeed(pt); + + mixerHead.setPosition(getVisualPosition()) + .nudge(0, -renderedHeadOffset, 0) + .setRotationalSpeed(speed * 2) + .setChanged(); + } + + private void transformPole(float renderedHeadOffset) { + mixerPole.position(getVisualPosition()) + .translatePosition(0, -renderedHeadOffset, 0) + .setChanged(); + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + + relight(pos.below(), mixerHead); + relight(mixerPole); + } + + @Override + protected void _delete() { + super._delete(); + mixerHead.delete(); + mixerPole.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(mixerHead); + consumer.accept(mixerPole); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/motor/CreativeMotorBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/motor/CreativeMotorBlockEntity.java index b18cf5257a..9de85be0f7 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/motor/CreativeMotorBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/motor/CreativeMotorBlockEntity.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.kinetics.motor; import java.util.List; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.kinetics.base.GeneratingKineticBlockEntity; @@ -13,6 +12,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -79,8 +79,8 @@ public class CreativeMotorBlockEntity extends GeneratingKineticBlockEntity { return; if (getSide() != Direction.UP) return; - TransformStack.cast(ms) - .rotateZ(-AngleHelper.horizontalAngle(facing) + 180); + TransformStack.of(ms) + .rotateZDegrees(-AngleHelper.horizontalAngle(facing) + 180); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/press/MechanicalPressRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/press/MechanicalPressRenderer.java index e6f1ef4ab3..8f80fe23bb 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/press/MechanicalPressRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/press/MechanicalPressRenderer.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.kinetics.press; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -30,7 +30,7 @@ public class MechanicalPressRenderer extends KineticBlockEntityRenderer implements DynamicInstance { - - private final OrientedData pressHead; - - public PressInstance(MaterialManager materialManager, MechanicalPressBlockEntity blockEntity) { - super(materialManager, blockEntity); - - pressHead = materialManager.defaultSolid() - .material(Materials.ORIENTED) - .getModel(AllPartialModels.MECHANICAL_PRESS_HEAD, blockState) - .createInstance(); - - Quaternionf q = Axis.YP - .rotationDegrees(AngleHelper.horizontalAngle(blockState.getValue(MechanicalPressBlock.HORIZONTAL_FACING))); - - pressHead.setRotation(q); - - transformModels(); - } - - @Override - public void beginFrame() { - transformModels(); - } - - private void transformModels() { - float renderedHeadOffset = getRenderedHeadOffset(blockEntity); - - pressHead.setPosition(getInstancePosition()) - .nudge(0, -renderedHeadOffset, 0); - } - - private float getRenderedHeadOffset(MechanicalPressBlockEntity press) { - PressingBehaviour pressingBehaviour = press.getPressingBehaviour(); - return pressingBehaviour.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks()) - * pressingBehaviour.mode.headOffset; - } - - @Override - public void updateLight() { - super.updateLight(); - - relight(pos, pressHead); - } - - @Override - public void remove() { - super.remove(); - pressHead.delete(); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/press/PressVisual.java b/src/main/java/com/simibubi/create/content/kinetics/press/PressVisual.java new file mode 100644 index 0000000000..e733943439 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/press/PressVisual.java @@ -0,0 +1,74 @@ +package com.simibubi.create.content.kinetics.press; + +import java.util.function.Consumer; + +import org.joml.Quaternionf; + +import com.mojang.math.Axis; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.ShaftVisual; +import com.simibubi.create.foundation.utility.AngleHelper; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.OrientedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; + +public class PressVisual extends ShaftVisual implements SimpleDynamicVisual { + + private final OrientedInstance pressHead; + + public PressVisual(VisualizationContext context, MechanicalPressBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + pressHead = instancerProvider.instancer(InstanceTypes.ORIENTED, Models.partial(AllPartialModels.MECHANICAL_PRESS_HEAD)) + .createInstance(); + + Quaternionf q = Axis.YP + .rotationDegrees(AngleHelper.horizontalAngle(blockState.getValue(MechanicalPressBlock.HORIZONTAL_FACING))); + + pressHead.rotation(q); + + transformModels(partialTick); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + transformModels(ctx.partialTick()); + } + + private void transformModels(float pt) { + float renderedHeadOffset = getRenderedHeadOffset(pt); + + pressHead.position(getVisualPosition()) + .translatePosition(0, -renderedHeadOffset, 0) + .setChanged(); + } + + private float getRenderedHeadOffset(float pt) { + PressingBehaviour pressingBehaviour = blockEntity.getPressingBehaviour(); + return pressingBehaviour.getRenderedHeadOffset(pt) + * pressingBehaviour.mode.headOffset; + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + relight(pressHead); + } + + @Override + protected void _delete() { + super._delete(); + pressHead.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(pressHead); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawFilterSlot.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawFilterSlot.java index ceb9495d3c..dfa8ed72db 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/saw/SawFilterSlot.java +++ b/src/main/java/com/simibubi/create/content/kinetics/saw/SawFilterSlot.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.kinetics.saw; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; @@ -25,9 +25,9 @@ public class SawFilterSlot extends ValueBoxTransform { public void rotate(BlockState state, PoseStack ms) { int yRot = (state.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 90 : 0) + (state.getValue(SawBlock.FLIPPED) ? 0 : 180); - TransformStack.cast(ms) - .rotateY(yRot) - .rotateX(90); + TransformStack.of(ms) + .rotateYDegrees(yRot) + .rotateXDegrees(90); } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawInstance.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawInstance.java deleted file mode 100644 index 9f0662d192..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/saw/SawInstance.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.simibubi.create.content.kinetics.saw; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class SawInstance extends SingleRotatingInstance { - - public SawInstance(MaterialManager materialManager, SawBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - protected Instancer getModel() { - if (blockState.getValue(BlockStateProperties.FACING) - .getAxis() - .isHorizontal()) { - BlockState referenceState = blockState.rotate(blockEntity.getLevel(), blockEntity.getBlockPos(), Rotation.CLOCKWISE_180); - Direction facing = referenceState.getValue(BlockStateProperties.FACING); - return getRotatingMaterial().getModel(AllPartialModels.SHAFT_HALF, referenceState, facing); - } else { - return getRotatingMaterial().getModel(shaft()); - } - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java index 746196cb29..4f47756047 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/kinetics/saw/SawMovementBehaviour.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.kinetics.saw; import java.util.Optional; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.damageTypes.CreateDamageSources; import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue; import com.simibubi.create.foundation.utility.TreeCutter; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.core.BlockPos; @@ -90,6 +90,11 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { world.addFreshEntity(entity); } + @Override + public boolean disableBlockEntityRendering() { + return true; + } + @Override @OnlyIn(value = Dist.CLIENT) public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawRenderer.java index bf999fdeb7..4b680bf0f5 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/saw/SawRenderer.java @@ -2,15 +2,11 @@ package com.simibubi.create.content.kinetics.saw; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ContraptionMatrices; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringRenderer; @@ -19,8 +15,12 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -46,7 +46,7 @@ public class SawRenderer extends SafeBlockEntityRenderer { renderItems(be, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnBlockEntity(be, partialTicks, ms, buffer, light, overlay); - if (Backend.canUseInstancing(be.getLevel())) + if (VisualizationManager.supportsVisualization(be.getLevel())) return; renderShaft(be, ms, buffer, light, overlay); @@ -81,7 +81,7 @@ public class SawRenderer extends SafeBlockEntityRenderer { SuperByteBuffer superBuffer = CachedBufferer.partialFacing(partial, blockState); if (rotate) { - superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90)); + superBuffer.rotateCentered(AngleHelper.rad(90), Direction.UP); } superBuffer.color(0xFFFFFF) .light(light) @@ -189,16 +189,17 @@ public class SawRenderer extends SafeBlockEntityRenderer { } superBuffer.transform(matrices.getModel()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing)); + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing)) + .rotateXDegrees(AngleHelper.verticalAngle(facing)); if (!SawBlock.isHorizontal(state)) { - superBuffer.rotateZ(state.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 90 : 0); + superBuffer.rotateZDegrees(state.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 90 : 0); } - superBuffer.unCentre() - .light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + superBuffer.uncenter() + .light(LevelRenderer.getLightColor(renderWorld, context.localPos)) + .useLevelLight(context.world, matrices.getWorld()) .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped())); } diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawVisual.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawVisual.java new file mode 100644 index 0000000000..fc6a29aab7 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/saw/SawVisual.java @@ -0,0 +1,33 @@ +package com.simibubi.create.content.kinetics.saw; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; +import com.simibubi.create.foundation.render.VirtualRenderHelper; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class SawVisual extends SingleRotatingVisual { + + public SawVisual(VisualizationContext context, SawBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + } + + @Override + protected Model model() { + if (blockState.getValue(BlockStateProperties.FACING) + .getAxis() + .isHorizontal()) { + BlockState referenceState = blockState.rotate(blockEntity.getLevel(), blockEntity.getBlockPos(), Rotation.CLOCKWISE_180); + Direction facing = referenceState.getValue(BlockStateProperties.FACING); + return Models.partial(AllPartialModels.SHAFT_HALF, facing); + } else { + return VirtualRenderHelper.blockModel(shaft()); + } + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityInstance.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityInstance.java deleted file mode 100644 index 7d2b580f80..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityInstance.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.simibubi.create.content.kinetics.simpleRelays; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Axis; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; -import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; - -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.Direction.AxisDirection; - -public class BracketedKineticBlockEntityInstance extends SingleRotatingInstance { - - protected RotatingData additionalShaft; - - public BracketedKineticBlockEntityInstance(MaterialManager materialManager, BracketedKineticBlockEntity blockEntity) { - super(materialManager, blockEntity); - } - - @Override - public void init() { - super.init(); - if (!ICogWheel.isLargeCog(blockEntity.getBlockState())) - return; - - // Large cogs sometimes have to offset their teeth by 11.25 degrees in order to - // mesh properly - - float speed = blockEntity.getSpeed(); - Direction.Axis axis = KineticBlockEntityRenderer.getRotationAxisOf(blockEntity); - BlockPos pos = blockEntity.getBlockPos(); - float offset = BracketedKineticBlockEntityRenderer.getShaftAngleOffset(axis, pos); - Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); - Instancer half = getRotatingMaterial().getModel(AllPartialModels.COGWHEEL_SHAFT, blockState, - facing, () -> this.rotateToAxis(axis)); - - additionalShaft = setup(half.createInstance(), speed); - additionalShaft.setRotationOffset(offset); - } - - @Override - protected Instancer getModel() { - if (!ICogWheel.isLargeCog(blockEntity.getBlockState())) - return super.getModel(); - - Direction.Axis axis = KineticBlockEntityRenderer.getRotationAxisOf(blockEntity); - Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); - return getRotatingMaterial().getModel(AllPartialModels.SHAFTLESS_LARGE_COGWHEEL, blockState, facing, - () -> this.rotateToAxis(axis)); - } - - private PoseStack rotateToAxis(Direction.Axis axis) { - Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); - PoseStack poseStack = new PoseStack(); - TransformStack.cast(poseStack) - .centre() - .rotateToFace(facing) - .multiply(Axis.XN.rotationDegrees(-90)) - .unCentre(); - return poseStack; - } - - @Override - public void update() { - super.update(); - if (additionalShaft != null) { - updateRotation(additionalShaft); - additionalShaft.setRotationOffset(BracketedKineticBlockEntityRenderer.getShaftAngleOffset(axis, pos)); - } - } - - @Override - public void updateLight() { - super.updateLight(); - if (additionalShaft != null) - relight(pos, additionalShaft); - } - - @Override - public void remove() { - super.remove(); - if (additionalShaft != null) - additionalShaft.delete(); - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityRenderer.java index cf67639507..3232a05f2d 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityRenderer.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.kinetics.simpleRelays; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; @@ -9,6 +9,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context; @@ -27,7 +28,7 @@ public class BracketedKineticBlockEntityRenderer extends KineticBlockEntityRende protected void renderSafe(BracketedKineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.canUseInstancing(be.getLevel())) + if (VisualizationManager.supportsVisualization(be.getLevel())) return; if (!AllBlocks.LARGE_COGWHEEL.has(be.getBlockState())) { @@ -38,17 +39,18 @@ public class BracketedKineticBlockEntityRenderer extends KineticBlockEntityRende // Large cogs sometimes have to offset their teeth by 11.25 degrees in order to // mesh properly + VertexConsumer vc = buffer.getBuffer(RenderType.solid()); Axis axis = getRotationAxisOf(be); Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); renderRotatingBuffer(be, CachedBufferer.partialFacingVertical(AllPartialModels.SHAFTLESS_LARGE_COGWHEEL, be.getBlockState(), facing), - ms, buffer.getBuffer(RenderType.solid()), light); + ms, vc, light); float angle = getAngleForLargeCogShaft(be, axis); SuperByteBuffer shaft = CachedBufferer.partialFacingVertical(AllPartialModels.COGWHEEL_SHAFT, be.getBlockState(), facing); kineticRotationTransform(shaft, be, axis, angle, light); - shaft.renderInto(ms, buffer.getBuffer(RenderType.solid())); + shaft.renderInto(ms, vc); } diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityVisual.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityVisual.java new file mode 100644 index 0000000000..35af391de0 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityVisual.java @@ -0,0 +1,98 @@ +package com.simibubi.create.content.kinetics.simpleRelays; + +import java.util.function.Consumer; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.content.kinetics.base.SingleRotatingVisual; +import com.simibubi.create.foundation.render.AllInstanceTypes; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; + +public class BracketedKineticBlockEntityVisual extends SingleRotatingVisual { + + protected RotatingInstance additionalShaft; + + public BracketedKineticBlockEntityVisual(VisualizationContext context, BracketedKineticBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + init(); + } + + public void init() { + if (ICogWheel.isLargeCog(blockEntity.getBlockState())) { + // Large cogs sometimes have to offset their teeth by 11.25 degrees in order to + // mesh properly + + float speed = blockEntity.getSpeed(); + Direction.Axis axis = KineticBlockEntityRenderer.getRotationAxisOf(blockEntity); + BlockPos pos = blockEntity.getBlockPos(); + float offset = BracketedKineticBlockEntityRenderer.getShaftAngleOffset(axis, pos); + var model = Models.partial(AllPartialModels.COGWHEEL_SHAFT, axis, BracketedKineticBlockEntityVisual::rotateToAxis); + Instancer half = instancerProvider.instancer(AllInstanceTypes.ROTATING, model); + + additionalShaft = setup(half.createInstance(), speed); + additionalShaft.setRotationOffset(offset) + .setChanged(); + } + } + + @Override + protected Model model() { + if (!ICogWheel.isLargeCog(blockEntity.getBlockState())) + return super.model(); + + Direction.Axis axis = KineticBlockEntityRenderer.getRotationAxisOf(blockEntity); + return Models.partial(AllPartialModels.SHAFTLESS_LARGE_COGWHEEL, axis, BracketedKineticBlockEntityVisual::rotateToAxis); + } + + private static void rotateToAxis(Direction.Axis axis, PoseStack ms) { + Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); + TransformStack.of(ms) + .center() + .rotateToFace(facing) + .rotate(Axis.XN.rotationDegrees(-90)) + .uncenter(); + } + + @Override + public void update(float pt) { + super.update(pt); + if (additionalShaft != null) { + updateRotation(additionalShaft); + additionalShaft.setRotationOffset(BracketedKineticBlockEntityRenderer.getShaftAngleOffset(axis, pos)) + .setChanged(); + } + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + if (additionalShaft != null) + relight(additionalShaft); + } + + @Override + protected void _delete() { + super._delete(); + if (additionalShaft != null) + additionalShaft.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + if (additionalShaft != null) + consumer.accept(additionalShaft); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockModel.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockModel.java index 3716bc865a..de8c36df0e 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockModel.java +++ b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockModel.java @@ -3,9 +3,9 @@ package com.simibubi.create.content.kinetics.simpleRelays; import java.util.Collections; import java.util.List; -import com.jozufozu.flywheel.core.model.ModelUtil; import com.simibubi.create.content.decoration.bracket.BracketedBlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; @@ -30,7 +30,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { @Override public ModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, ModelData blockEntityData) { - if (ModelUtil.isVirtual(blockEntityData)) + if (VirtualRenderHelper.isVirtual(blockEntityData)) return blockEntityData; BracketedModelData data = new BracketedModelData(); BracketedBlockEntityBehaviour attachmentBehaviour = @@ -43,7 +43,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { @Override public List getQuads(BlockState state, Direction side, RandomSource rand, ModelData data, RenderType renderType) { - if (!ModelUtil.isVirtual(data)) { + if (!VirtualRenderHelper.isVirtual(data)) { if (data.has(BRACKET_PROPERTY)) { BracketedModelData pipeData = data.get(BRACKET_PROPERTY); BakedModel bracket = pipeData.getBracket(); diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogInstance.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogInstance.java deleted file mode 100644 index f6633776e4..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogInstance.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.simibubi.create.content.kinetics.simpleRelays.encased; - -import java.util.Optional; - -import com.jozufozu.flywheel.api.InstanceData; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Axis; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.IRotate; -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; -import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.content.kinetics.simpleRelays.BracketedKineticBlockEntityRenderer; -import com.simibubi.create.foundation.utility.Iterate; - -import net.minecraft.core.Direction; -import net.minecraft.core.Direction.AxisDirection; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; - -public class EncasedCogInstance extends KineticBlockEntityInstance { - - private boolean large; - - protected RotatingData rotatingModel; - protected Optional rotatingTopShaft; - protected Optional rotatingBottomShaft; - - public static EncasedCogInstance small(MaterialManager modelManager, KineticBlockEntity blockEntity) { - return new EncasedCogInstance(modelManager, blockEntity, false); - } - - public static EncasedCogInstance large(MaterialManager modelManager, KineticBlockEntity blockEntity) { - return new EncasedCogInstance(modelManager, blockEntity, true); - } - - public EncasedCogInstance(MaterialManager modelManager, KineticBlockEntity blockEntity, boolean large) { - super(modelManager, blockEntity); - this.large = large; - } - - @Override - public void init() { - rotatingModel = setup(getCogModel().createInstance()); - - Block block = blockState.getBlock(); - if (!(block instanceof IRotate)) - return; - - IRotate def = (IRotate) block; - rotatingTopShaft = Optional.empty(); - rotatingBottomShaft = Optional.empty(); - - for (Direction d : Iterate.directionsInAxis(axis)) { - if (!def.hasShaftTowards(blockEntity.getLevel(), blockEntity.getBlockPos(), blockState, d)) - continue; - RotatingData data = setup(getRotatingMaterial().getModel(AllPartialModels.SHAFT_HALF, blockState, d) - .createInstance()); - if (large) - data.setRotationOffset(BracketedKineticBlockEntityRenderer.getShaftAngleOffset(axis, pos)); - if (d.getAxisDirection() == AxisDirection.POSITIVE) - rotatingTopShaft = Optional.of(data); - else - rotatingBottomShaft = Optional.of(data); - } - } - - @Override - public void update() { - updateRotation(rotatingModel); - rotatingTopShaft.ifPresent(this::updateRotation); - rotatingBottomShaft.ifPresent(this::updateRotation); - } - - @Override - public void updateLight() { - relight(pos, rotatingModel); - rotatingTopShaft.ifPresent(d -> relight(pos, d)); - rotatingBottomShaft.ifPresent(d -> relight(pos, d)); - } - - @Override - public void remove() { - rotatingModel.delete(); - rotatingTopShaft.ifPresent(InstanceData::delete); - rotatingBottomShaft.ifPresent(InstanceData::delete); - } - - protected Instancer getCogModel() { - BlockState referenceState = blockEntity.getBlockState(); - Direction facing = - Direction.fromAxisAndDirection(referenceState.getValue(BlockStateProperties.AXIS), AxisDirection.POSITIVE); - PartialModel partial = large ? AllPartialModels.SHAFTLESS_LARGE_COGWHEEL : AllPartialModels.SHAFTLESS_COGWHEEL; - - return getRotatingMaterial().getModel(partial, referenceState, facing, () -> { - PoseStack poseStack = new PoseStack(); - TransformStack.cast(poseStack) - .centre() - .rotateToFace(facing) - .multiply(Axis.XN.rotationDegrees(90)) - .unCentre(); - return poseStack; - }); - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogRenderer.java index 8a03236a86..a2d40e7929 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.kinetics.simpleRelays.encased; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.IRotate; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -42,7 +42,7 @@ public class EncasedCogRenderer extends KineticBlockEntityRenderer { + + private final boolean large; + + protected final RotatingInstance rotatingModel; + @Nullable + protected final RotatingInstance rotatingTopShaft; + @Nullable + protected final RotatingInstance rotatingBottomShaft; + + public static EncasedCogVisual small(VisualizationContext modelManager, KineticBlockEntity blockEntity, float partialTick) { + return new EncasedCogVisual(modelManager, blockEntity, false, partialTick); + } + + public static EncasedCogVisual large(VisualizationContext modelManager, KineticBlockEntity blockEntity, float partialTick) { + return new EncasedCogVisual(modelManager, blockEntity, true, partialTick); + } + + public EncasedCogVisual(VisualizationContext modelManager, KineticBlockEntity blockEntity, boolean large, float partialTick) { + super(modelManager, blockEntity, partialTick); + this.large = large; + + var instancer = instancerProvider.instancer(AllInstanceTypes.ROTATING, getCogModel()); + rotatingModel = setup(instancer.createInstance()); + + RotatingInstance rotatingTopShaft = null; + RotatingInstance rotatingBottomShaft = null; + + Block block = blockState.getBlock(); + if (block instanceof IRotate def) { + for (Direction d : Iterate.directionsInAxis(axis)) { + if (!def.hasShaftTowards(blockEntity.getLevel(), blockEntity.getBlockPos(), blockState, d)) + continue; + RotatingInstance data = setup(instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.SHAFT_HALF, d)) + .createInstance()); + if (large) { + data.setRotationOffset(BracketedKineticBlockEntityRenderer.getShaftAngleOffset(axis, pos)); + } + if (d.getAxisDirection() == AxisDirection.POSITIVE) { + rotatingTopShaft = data; + } else { + rotatingBottomShaft = data; + } + } + } + + this.rotatingTopShaft = rotatingTopShaft; + this.rotatingBottomShaft = rotatingBottomShaft; + } + + @Override + public void update(float pt) { + updateRotation(rotatingModel); + if (rotatingTopShaft != null) updateRotation(rotatingTopShaft); + if (rotatingBottomShaft != null) updateRotation(rotatingBottomShaft); + } + + @Override + public void updateLight(float partialTick) { + relight(rotatingModel, rotatingTopShaft, rotatingBottomShaft); + } + + @Override + protected void _delete() { + rotatingModel.delete(); + if (rotatingTopShaft != null) rotatingTopShaft.delete(); + if (rotatingBottomShaft != null) rotatingBottomShaft.delete(); + } + + protected Model getCogModel() { + BlockState referenceState = blockEntity.getBlockState(); + Direction facing = + Direction.fromAxisAndDirection(referenceState.getValue(BlockStateProperties.AXIS), AxisDirection.POSITIVE); + PartialModel partial = large ? AllPartialModels.SHAFTLESS_LARGE_COGWHEEL : AllPartialModels.SHAFTLESS_COGWHEEL; + + return Models.partial(partial, facing, EncasedCogVisual::transformCog); + } + + private static void transformCog(Direction dir, PoseStack stack) { + TransformStack.of(stack) + .center() + .rotateToFace(dir) + .rotate(Axis.XN.rotationDegrees(90)) + .uncenter(); + } + + @Override + public void collectCrumblingInstances(Consumer<@Nullable Instance> consumer) { + consumer.accept(rotatingModel); + consumer.accept(rotatingTopShaft); + consumer.accept(rotatingBottomShaft); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/speedController/SpeedControllerRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/speedController/SpeedControllerRenderer.java index a4a57086d2..d785cdfda3 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/speedController/SpeedControllerRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/speedController/SpeedControllerRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.kinetics.speedController; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -9,9 +8,10 @@ import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRende import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -30,8 +30,8 @@ public class SpeedControllerRenderer extends SmartBlockEntityRenderer implements DynamicInstance { - - protected final ModelData piston; - protected final ModelData linkage; - protected final ModelData connector; - - public SteamEngineInstance(MaterialManager materialManager, SteamEngineBlockEntity blockEntity) { - super(materialManager, blockEntity); - - piston = materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(AllPartialModels.ENGINE_PISTON, blockState) - .createInstance(); - linkage = materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(AllPartialModels.ENGINE_LINKAGE, blockState) - .createInstance(); - connector = materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(AllPartialModels.ENGINE_CONNECTOR, blockState) - .createInstance(); - } - - @Override - public void beginFrame() { - Float angle = blockEntity.getTargetAngle(); - if (angle == null) { - piston.setEmptyTransform(); - linkage.setEmptyTransform(); - connector.setEmptyTransform(); - return; - } - - Direction facing = SteamEngineBlock.getFacing(blockState); - Axis facingAxis = facing.getAxis(); - Axis axis = Axis.Y; - - PoweredShaftBlockEntity shaft = blockEntity.getShaft(); - if (shaft != null) - axis = KineticBlockEntityRenderer.getRotationAxisOf(shaft); - - boolean roll90 = facingAxis.isHorizontal() && axis == Axis.Y || facingAxis.isVertical() && axis == Axis.Z; - float sine = Mth.sin(angle); - float sine2 = Mth.sin(angle - Mth.HALF_PI); - float piston = ((1 - sine) / 4) * 24 / 16f; - - transformed(this.piston, facing, roll90) - .translate(0, piston, 0); - - transformed(linkage, facing, roll90) - .centre() - .translate(0, 1, 0) - .unCentre() - .translate(0, piston, 0) - .translate(0, 4 / 16f, 8 / 16f) - .rotateX(sine2 * 23f) - .translate(0, -4 / 16f, -8 / 16f); - - transformed(connector, facing, roll90) - .translate(0, 2, 0) - .centre() - .rotateXRadians(-angle + Mth.HALF_PI) - .unCentre(); - } - - protected ModelData transformed(ModelData modelData, Direction facing, boolean roll90) { - return modelData.loadIdentity() - .translate(getInstancePosition()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing) + 90) - .rotateY(roll90 ? -90 : 0) - .unCentre(); - } - - @Override - public void updateLight() { - relight(pos, piston, linkage, connector); - } - - @Override - protected void remove() { - piston.delete(); - linkage.delete(); - connector.delete(); - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/steamEngine/SteamEngineRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/steamEngine/SteamEngineRenderer.java index fb80bfdd5d..e797a611e0 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/steamEngine/SteamEngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/steamEngine/SteamEngineRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.kinetics.steamEngine; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -11,6 +9,8 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -26,7 +26,7 @@ public class SteamEngineRenderer extends SafeBlockEntityRenderer implements SimpleDynamicVisual { + + protected final TransformedInstance piston; + protected final TransformedInstance linkage; + protected final TransformedInstance connector; + + public SteamEngineVisual(VisualizationContext context, SteamEngineBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + piston = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ENGINE_PISTON)) + .createInstance(); + linkage = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ENGINE_LINKAGE)) + .createInstance(); + connector = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ENGINE_CONNECTOR)) + .createInstance(); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + Float angle = blockEntity.getTargetAngle(); + if (angle == null) { + piston.setZeroTransform().setChanged(); + linkage.setZeroTransform().setChanged(); + connector.setZeroTransform().setChanged(); + return; + } + + Direction facing = SteamEngineBlock.getFacing(blockState); + Axis facingAxis = facing.getAxis(); + Axis axis = Axis.Y; + + PoweredShaftBlockEntity shaft = blockEntity.getShaft(); + if (shaft != null) + axis = KineticBlockEntityRenderer.getRotationAxisOf(shaft); + + boolean roll90 = facingAxis.isHorizontal() && axis == Axis.Y || facingAxis.isVertical() && axis == Axis.Z; + float sine = Mth.sin(angle); + float sine2 = Mth.sin(angle - Mth.HALF_PI); + float piston = ((1 - sine) / 4) * 24 / 16f; + + transformed(this.piston, facing, roll90) + .translate(0, piston, 0) + .setChanged(); + + transformed(linkage, facing, roll90) + .center() + .translate(0, 1, 0) + .uncenter() + .translate(0, piston, 0) + .translate(0, 4 / 16f, 8 / 16f) + .rotateXDegrees(sine2 * 23f) + .translate(0, -4 / 16f, -8 / 16f) + .setChanged(); + + transformed(connector, facing, roll90) + .translate(0, 2, 0) + .center() + .rotateX(-angle + Mth.HALF_PI) + .uncenter() + .setChanged(); + } + + protected TransformedInstance transformed(TransformedInstance modelData, Direction facing, boolean roll90) { + return modelData.setIdentityTransform() + .translate(getVisualPosition()) + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing)) + .rotateXDegrees(AngleHelper.verticalAngle(facing) + 90) + .rotateYDegrees(roll90 ? -90 : 0) + .uncenter(); + } + + @Override + public void updateLight(float partialTick) { + relight(piston, linkage, connector); + } + + @Override + protected void _delete() { + piston.delete(); + linkage.delete(); + connector.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(piston); + consumer.accept(linkage); + consumer.accept(connector); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftInstance.java b/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftInstance.java deleted file mode 100644 index 1c58483599..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftInstance.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.simibubi.create.content.kinetics.transmission; - -import java.util.ArrayList; - -import com.jozufozu.flywheel.api.InstanceData; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.IRotate; -import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.foundation.utility.Iterate; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.Block; - -public class SplitShaftInstance extends KineticBlockEntityInstance { - - protected final ArrayList keys; - - public SplitShaftInstance(MaterialManager modelManager, SplitShaftBlockEntity blockEntity) { - super(modelManager, blockEntity); - - keys = new ArrayList<>(2); - - float speed = blockEntity.getSpeed(); - - Material rotatingMaterial = getRotatingMaterial(); - - for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) { - - Instancer half = rotatingMaterial.getModel(AllPartialModels.SHAFT_HALF, blockState, dir); - - float splitSpeed = speed * blockEntity.getRotationSpeedModifier(dir); - - keys.add(setup(half.createInstance(), splitSpeed)); - } - } - - @Override - public void update() { - Block block = blockState.getBlock(); - final Direction.Axis boxAxis = ((IRotate) block).getRotationAxis(blockState); - - Direction[] directions = Iterate.directionsInAxis(boxAxis); - - for (int i : Iterate.zeroAndOne) { - updateRotation(keys.get(i), blockEntity.getSpeed() * blockEntity.getRotationSpeedModifier(directions[i])); - } - } - - @Override - public void updateLight() { - relight(pos, keys.stream()); - } - - @Override - public void remove() { - keys.forEach(InstanceData::delete); - keys.clear(); - } - -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftRenderer.java index 0846740c88..d94f73b5e7 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.kinetics.transmission; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.IRotate; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -27,7 +27,7 @@ public class SplitShaftRenderer extends KineticBlockEntityRenderer { + + protected final ArrayList keys; + + public SplitShaftVisual(VisualizationContext modelManager, SplitShaftBlockEntity blockEntity, float partialTick) { + super(modelManager, blockEntity, partialTick); + + keys = new ArrayList<>(2); + + float speed = blockEntity.getSpeed(); + + for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) { + + float splitSpeed = speed * blockEntity.getRotationSpeedModifier(dir); + + var instance = instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.partial(AllPartialModels.SHAFT_HALF, dir)) + .createInstance(); + + keys.add(setup(instance, splitSpeed)); + } + } + + @Override + public void update(float pt) { + Block block = blockState.getBlock(); + final Direction.Axis boxAxis = ((IRotate) block).getRotationAxis(blockState); + + Direction[] directions = Iterate.directionsInAxis(boxAxis); + + for (int i : Iterate.zeroAndOne) { + updateRotation(keys.get(i), blockEntity.getSpeed() * blockEntity.getRotationSpeedModifier(directions[i])); + } + } + + @Override + public void updateLight(float partialTick) { + relight(keys.toArray(FlatLit[]::new)); + } + + @Override + protected void _delete() { + keys.forEach(AbstractInstance::delete); + keys.clear(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + keys.forEach(consumer); + } +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelInstance.java b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelInstance.java deleted file mode 100644 index 16ae300bfc..0000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelInstance.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.simibubi.create.content.kinetics.waterwheel; - -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.model.BlockModel; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.kinetics.base.CutoutRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.foundation.render.CachedBufferer; - -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.Direction; -import net.minecraft.core.Direction.AxisDirection; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; - -public class WaterWheelInstance extends CutoutRotatingInstance { - protected final boolean large; - protected final WaterWheelModelKey key; - - public WaterWheelInstance(MaterialManager materialManager, T blockEntity, boolean large) { - super(materialManager, blockEntity); - this.large = large; - key = new WaterWheelModelKey(large, getRenderedBlockState(), blockEntity.material); - } - - public static WaterWheelInstance standard(MaterialManager materialManager, T blockEntity) { - return new WaterWheelInstance<>(materialManager, blockEntity, false); - } - - public static WaterWheelInstance large(MaterialManager materialManager, T blockEntity) { - return new WaterWheelInstance<>(materialManager, blockEntity, true); - } - - @Override - public boolean shouldReset() { - return super.shouldReset() || key.material() != blockEntity.material; - } - - @Override - protected Instancer getModel() { - return getRotatingMaterial().model(key, () -> { - BakedModel model = WaterWheelRenderer.generateModel(key); - BlockState state = key.state(); - Direction dir; - if (key.large()) { - dir = Direction.fromAxisAndDirection(state.getValue(LargeWaterWheelBlock.AXIS), AxisDirection.POSITIVE); - } else { - dir = state.getValue(WaterWheelBlock.FACING); - } - PoseStack transform = CachedBufferer.rotateToFaceVertical(dir).get(); - return BlockModel.of(model, Blocks.AIR.defaultBlockState(), transform); - }); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelRenderer.java b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelRenderer.java index aea9eb997d..a19694ea44 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelRenderer.java @@ -6,16 +6,16 @@ import java.util.Optional; import javax.annotation.Nullable; -import com.jozufozu.flywheel.core.StitchedSprite; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.CreateClient; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; import com.simibubi.create.foundation.model.BakedModelHelper; -import com.simibubi.create.foundation.render.BakedModelRenderHelper; import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.StitchedSprite; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBufferCache.Compartment; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.RegisteredObjects; import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; @@ -70,7 +70,7 @@ public class WaterWheelRenderer extends Kinetic dir = state1.getValue(WaterWheelBlock.FACING); } PoseStack transform = CachedBufferer.rotateToFaceVertical(dir).get(); - return BakedModelRenderHelper.standardModelRender(model, Blocks.AIR.defaultBlockState(), transform); + return VirtualRenderHelper.bufferModel(model, Blocks.AIR.defaultBlockState(), transform); }); } @@ -109,19 +109,19 @@ public class WaterWheelRenderer extends Kinetic return BakedModelHelper.generateModel(template, map::get); } - + @Nullable private static String plankStateToWoodName(BlockState planksBlockState) { Block planksBlock = planksBlockState.getBlock(); ResourceLocation id = RegisteredObjects.getKeyOrThrow(planksBlock); String path = id.getPath(); - + if (path.endsWith("_planks")) // Covers most wood types return path.substring(0, path.length() - 7); - + if (path.contains("wood/planks/")) // TerraFirmaCraft return path.substring(12); - + return null; } diff --git a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelVisual.java b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelVisual.java new file mode 100644 index 0000000000..272357f72c --- /dev/null +++ b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelVisual.java @@ -0,0 +1,89 @@ +package com.simibubi.create.content.kinetics.waterwheel; + +import java.util.function.Consumer; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.content.kinetics.base.KineticBlockEntityVisual; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.render.CachedBufferer; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.model.ModelCache; +import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.level.block.state.BlockState; + +public class WaterWheelVisual extends KineticBlockEntityVisual { + private static final ModelCache MODEL_CACHE = new ModelCache<>(WaterWheelVisual::createModel); + + protected final boolean large; + protected BlockState lastMaterial; + protected RotatingInstance rotatingModel; + + public WaterWheelVisual(VisualizationContext context, T blockEntity, boolean large, float partialTick) { + super(context, blockEntity, partialTick); + this.large = large; + + setupInstance(); + } + + public static WaterWheelVisual standard(VisualizationContext context, T blockEntity, float partialTick) { + return new WaterWheelVisual<>(context, blockEntity, false, partialTick); + } + + public static WaterWheelVisual large(VisualizationContext context, T blockEntity, float partialTick) { + return new WaterWheelVisual<>(context, blockEntity, true, partialTick); + } + + private void setupInstance() { + lastMaterial = blockEntity.material; + rotatingModel = instancerProvider.instancer(AllInstanceTypes.ROTATING, MODEL_CACHE.get(new WaterWheelModelKey(large, blockState, blockEntity.material))) + .createInstance(); + setup(rotatingModel); + } + + @Override + public void update(float pt) { + if (lastMaterial != blockEntity.material) { + rotatingModel.delete(); + setupInstance(); + } + + updateRotation(rotatingModel); + } + + @Override + public void updateLight(float partialTick) { + relight(rotatingModel); + } + + @Override + protected void _delete() { + rotatingModel.delete(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(rotatingModel); + } + + private static Model createModel(WaterWheelModelKey key) { + BakedModel model = WaterWheelRenderer.generateModel(key); + BlockState state = key.state(); + Direction dir; + if (key.large()) { + dir = Direction.fromAxisAndDirection(state.getValue(LargeWaterWheelBlock.AXIS), AxisDirection.POSITIVE); + } else { + dir = state.getValue(WaterWheelBlock.FACING); + } + PoseStack transform = CachedBufferer.rotateToFaceVertical(dir).get(); + return BakedModelBuilder.create(model) + .poseStack(transform) + .build(); + } +} diff --git a/src/main/java/com/simibubi/create/content/logistics/chute/ChuteRenderer.java b/src/main/java/com/simibubi/create/content/logistics/chute/ChuteRenderer.java index b14838fd87..3b3f2c219e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/chute/ChuteRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/chute/ChuteRenderer.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.logistics.chute; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.logistics.chute.ChuteBlock.Shape; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -36,15 +36,15 @@ public class ChuteRenderer extends SafeBlockEntityRenderer { int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); ms.pushPose(); - msr.centre(); + msr.center(); float itemScale = .5f; float itemPosition = be.itemPosition.getValue(partialTicks); ms.translate(0, -.5 + itemPosition, 0); ms.scale(itemScale, itemScale, itemScale); - msr.rotateX(itemPosition * 180); - msr.rotateY(itemPosition * 180); + msr.rotateXDegrees(itemPosition * 180); + msr.rotateYDegrees(itemPosition * 180); itemRenderer.renderStatic(be.item, ItemDisplayContext.FIXED, light, overlay, ms, buffer, be.getLevel(), 0); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/crate/CreativeCrateBlockEntity.java b/src/main/java/com/simibubi/create/content/logistics/crate/CreativeCrateBlockEntity.java index fe2351061a..d2327aae1e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/crate/CreativeCrateBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/crate/CreativeCrateBlockEntity.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.logistics.crate; import java.util.List; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -56,8 +56,8 @@ public class CreativeCrateBlockEntity extends CrateBlockEntity { @Override public void rotate(BlockState state, PoseStack ms) { - TransformStack.cast(ms) - .rotateX(90); + TransformStack.of(ms) + .rotateXDegrees(90); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/depot/DepotRenderer.java b/src/main/java/com/simibubi/create/content/logistics/depot/DepotRenderer.java index 676a66569c..b1ce049c33 100644 --- a/src/main/java/com/simibubi/create/content/logistics/depot/DepotRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/depot/DepotRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.logistics.depot; import java.util.Random; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.simibubi.create.content.kinetics.belt.BeltHelper; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -39,7 +39,7 @@ public class DepotRenderer extends SafeBlockEntityRenderer { int light, int overlay, DepotBehaviour depotBehaviour) { TransportedItemStack transported = depotBehaviour.heldItem; - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); Vec3 itemPosition = VecHelper.getCenterOf(be.getBlockPos()); ms.pushPose(); @@ -86,10 +86,10 @@ public class DepotRenderer extends SafeBlockEntityRenderer { msr.nudge(i); boolean renderUpright = BeltHelper.isItemUpright(stack); - msr.rotateY(360 / 8f * i); + msr.rotateYDegrees(360 / 8f * i); ms.translate(.35f, 0, 0); if (renderUpright) - msr.rotateY(-(360 / 8f * i)); + msr.rotateYDegrees(-(360 / 8f * i)); Random r = new Random(i + 1); int angle = (int) (360 * r.nextFloat()); renderItem(be.getLevel(), ms, buffer, light, overlay, stack, renderUpright ? angle + 90 : angle, r, itemPosition); @@ -103,14 +103,14 @@ public class DepotRenderer extends SafeBlockEntityRenderer { int angle, Random r, Vec3 itemPosition) { ItemRenderer itemRenderer = Minecraft.getInstance() .getItemRenderer(); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2; boolean renderUpright = BeltHelper.isItemUpright(itemStack); BakedModel bakedModel = itemRenderer.getModel(itemStack, null, null, 0); boolean blockItem = bakedModel.isGui3d(); ms.pushPose(); - msr.rotateY(angle); + msr.rotateYDegrees(angle); if (renderUpright) { Entity renderViewEntity = Minecraft.getInstance().cameraEntity; @@ -131,14 +131,14 @@ public class DepotRenderer extends SafeBlockEntityRenderer { ms.scale(.5f, .5f, .5f); if (!blockItem && !renderUpright) { ms.translate(0, -3 / 16f, 0); - msr.rotateX(90); + msr.rotateXDegrees(90); } itemRenderer.render(itemStack, ItemDisplayContext.FIXED, false, ms, buffer, light, overlay, bakedModel); ms.popPose(); if (!renderUpright) { if (!blockItem) - msr.rotateY(10); + msr.rotateYDegrees(10); ms.translate(0, blockItem ? 1 / 64d : 1 / 16d, 0); } else ms.translate(0, 0, -1 / 16f); diff --git a/src/main/java/com/simibubi/create/content/logistics/depot/EjectorBlockEntity.java b/src/main/java/com/simibubi/create/content/logistics/depot/EjectorBlockEntity.java index ad9a86236e..ab778e3978 100644 --- a/src/main/java/com/simibubi/create/content/logistics/depot/EjectorBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/depot/EjectorBlockEntity.java @@ -6,7 +6,6 @@ import java.util.List; import javax.annotation.Nullable; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; @@ -29,6 +28,7 @@ import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -630,9 +630,9 @@ public class EjectorBlockEntity extends KineticBlockEntity { super.rotate(state, ms); return; } - TransformStack.cast(ms) - .rotateY(angle(state)) - .rotateX(90); + TransformStack.of(ms) + .rotateYDegrees(angle(state)) + .rotateXDegrees(90); } protected float angle(BlockState state) { diff --git a/src/main/java/com/simibubi/create/content/logistics/depot/EjectorInstance.java b/src/main/java/com/simibubi/create/content/logistics/depot/EjectorInstance.java deleted file mode 100644 index 10b0b4d5dc..0000000000 --- a/src/main/java/com/simibubi/create/content/logistics/depot/EjectorInstance.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.simibubi.create.content.logistics.depot; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.ShaftInstance; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.util.Mth; - -public class EjectorInstance extends ShaftInstance implements DynamicInstance { - - protected final ModelData plate; - - private float lastProgress = Float.NaN; - - public EjectorInstance(MaterialManager dispatcher, EjectorBlockEntity blockEntity) { - super(dispatcher, blockEntity); - - plate = getTransformMaterial().getModel(AllPartialModels.EJECTOR_TOP, blockState).createInstance(); - - pivotPlate(); - } - - @Override - public void beginFrame() { - float lidProgress = getLidProgress(); - - if (Mth.equal(lidProgress, lastProgress)) return; - - pivotPlate(lidProgress); - lastProgress = lidProgress; - } - - @Override - public void updateLight() { - super.updateLight(); - relight(pos, plate); - } - - @Override - public void remove() { - super.remove(); - plate.delete(); - } - - private void pivotPlate() { - pivotPlate(getLidProgress()); - } - - private float getLidProgress() { - return blockEntity.getLidProgress(AnimationTickHolder.getPartialTicks()); - } - - private void pivotPlate(float lidProgress) { - float angle = lidProgress * 70; - - EjectorRenderer.applyLidAngle(blockEntity, angle, plate.loadIdentity().translate(getInstancePosition())); - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/depot/EjectorRenderer.java b/src/main/java/com/simibubi/create/content/logistics/depot/EjectorRenderer.java index ccb33d9dd3..a77c22a158 100644 --- a/src/main/java/com/simibubi/create/content/logistics/depot/EjectorRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/depot/EjectorRenderer.java @@ -1,11 +1,6 @@ package com.simibubi.create.content.logistics.depot; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.util.transform.Rotate; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.jozufozu.flywheel.util.transform.Translate; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.base.ShaftRenderer; @@ -15,6 +10,10 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.transform.Rotate; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import dev.engine_room.flywheel.lib.transform.Translate; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -41,18 +40,17 @@ public class EjectorRenderer extends ShaftRenderer { int light, int overlay) { super.renderSafe(be, partialTicks, ms, buffer, light, overlay); - VertexConsumer vertexBuilder = buffer.getBuffer(RenderType.solid()); float lidProgress = be.getLidProgress(partialTicks); float angle = lidProgress * 70; - if (!Backend.canUseInstancing(be.getLevel())) { + if (!VisualizationManager.supportsVisualization(be.getLevel())) { SuperByteBuffer model = CachedBufferer.partial(AllPartialModels.EJECTOR_TOP, be.getBlockState()); applyLidAngle(be, angle, model); model.light(light) - .renderInto(ms, vertexBuilder); + .renderInto(ms, buffer.getBuffer(RenderType.solid())); } - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); float maxTime = (float) (be.earlyTarget != null ? be.earlyTargetTime : be.launcher.getTotalFlyingTicks()); @@ -66,8 +64,8 @@ public class EjectorRenderer extends ShaftRenderer { msr.translate(launchedItemLocation.subtract(Vec3.atLowerCornerOf(be.getBlockPos()))); Vec3 itemRotOffset = VecHelper.voxelSpace(0, 3, 0); msr.translate(itemRotOffset); - msr.rotateY(AngleHelper.horizontalAngle(be.getFacing())); - msr.rotateX(time * 40); + msr.rotateYDegrees(AngleHelper.horizontalAngle(be.getFacing())); + msr.rotateXDegrees(time * 40); msr.translateBack(itemRotOffset); Minecraft.getInstance() .getItemRenderer() @@ -81,10 +79,10 @@ public class EjectorRenderer extends ShaftRenderer { ms.pushPose(); applyLidAngle(be, angle, msr); - msr.centre() - .rotateY(-180 - AngleHelper.horizontalAngle(be.getBlockState() + msr.center() + .rotateYDegrees(-180 - AngleHelper.horizontalAngle(be.getBlockState() .getValue(EjectorBlock.HORIZONTAL_FACING))) - .unCentre(); + .uncenter(); DepotRenderer.renderItemsOf(be, partialTicks, ms, buffer, light, overlay, behaviour); ms.popPose(); } @@ -94,12 +92,12 @@ public class EjectorRenderer extends ShaftRenderer { } static & Rotate> void applyLidAngle(KineticBlockEntity be, Vec3 rotationOffset, float angle, T tr) { - tr.centre() - .rotateY(180 + AngleHelper.horizontalAngle(be.getBlockState() + tr.center() + .rotateYDegrees(180 + AngleHelper.horizontalAngle(be.getBlockState() .getValue(EjectorBlock.HORIZONTAL_FACING))) - .unCentre() + .uncenter() .translate(rotationOffset) - .rotateX(-angle) + .rotateXDegrees(-angle) .translateBack(rotationOffset); } diff --git a/src/main/java/com/simibubi/create/content/logistics/depot/EjectorVisual.java b/src/main/java/com/simibubi/create/content/logistics/depot/EjectorVisual.java new file mode 100644 index 0000000000..c1df29c359 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/depot/EjectorVisual.java @@ -0,0 +1,70 @@ +package com.simibubi.create.content.logistics.depot; + +import java.util.function.Consumer; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.kinetics.base.ShaftVisual; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; + +public class EjectorVisual extends ShaftVisual implements SimpleDynamicVisual { + + protected final TransformedInstance plate; + + private float lastProgress = Float.NaN; + + public EjectorVisual(VisualizationContext dispatcher, EjectorBlockEntity blockEntity, float partialTick) { + super(dispatcher, blockEntity, partialTick); + + plate = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.EJECTOR_TOP)).createInstance(); + + pivotPlate(getLidProgress(partialTick)); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + float lidProgress = getLidProgress(ctx.partialTick()); + + if (lidProgress == lastProgress) { + return; + } + + pivotPlate(lidProgress); + lastProgress = lidProgress; + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + relight(plate); + } + + @Override + protected void _delete() { + super._delete(); + plate.delete(); + } + + private float getLidProgress(float pt) { + return blockEntity.getLidProgress(pt); + } + + private void pivotPlate(float lidProgress) { + float angle = lidProgress * 70; + + EjectorRenderer.applyLidAngle(blockEntity, angle, plate.setIdentityTransform().translate(getVisualPosition())); + plate.setChanged(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + super.collectCrumblingInstances(consumer); + consumer.accept(plate); + } +} diff --git a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapData.java deleted file mode 100644 index 453c109a78..0000000000 --- a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapData.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.simibubi.create.content.logistics.flwdata; - -import org.joml.Vector3f; - -import com.jozufozu.flywheel.api.InstanceData; -import com.jozufozu.flywheel.core.materials.FlatLit; - -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.core.BlockPos; - -public class FlapData extends InstanceData implements FlatLit { - - float x; - float y; - float z; - byte blockLight; - byte skyLight; - float segmentOffsetX; - float segmentOffsetY; - float segmentOffsetZ; - float pivotX; - float pivotY; - float pivotZ; - float horizontalAngle; - float intensity; - float flapScale; - float flapness; - - public FlapData setPosition(BlockPos pos) { - return setPosition(pos.getX(), pos.getY(), pos.getZ()); - } - - public FlapData setPosition(Vector3f pos) { - return setPosition(pos.x(), pos.y(), pos.z()); - } - - public FlapData setPosition(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; - markDirty(); - return this; - } - - @Override - public FlapData setBlockLight(int blockLight) { - this.blockLight = (byte) (blockLight & 0xF); - markDirty(); - return this; - } - - @Override - public FlapData setSkyLight(int skyLight) { - this.skyLight = (byte) (skyLight & 0xF); - markDirty(); - return this; - } - - @Override - public int getPackedLight() { - return LightTexture.pack(this.blockLight, this.skyLight); - } - - public FlapData setSegmentOffset(float x, float y, float z) { - this.segmentOffsetX = x; - this.segmentOffsetY = y; - this.segmentOffsetZ = z; - markDirty(); - return this; - } - - public FlapData setIntensity(float intensity) { - this.intensity = intensity; - markDirty(); - return this; - } - - public FlapData setHorizontalAngle(float horizontalAngle) { - this.horizontalAngle = horizontalAngle; - markDirty(); - return this; - } - - public FlapData setFlapScale(float flapScale) { - this.flapScale = flapScale; - markDirty(); - return this; - } - - public FlapData setFlapness(float flapness) { - this.flapness = flapness; - markDirty(); - return this; - } - - public FlapData setPivotVoxelSpace(float x, float y, float z) { - pivotX = x / 16f; - pivotY = y / 16f; - pivotZ = z / 16f; - markDirty(); - return this; - } - -} diff --git a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapInstance.java b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapInstance.java new file mode 100644 index 0000000000..30e5251262 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapInstance.java @@ -0,0 +1,96 @@ +package com.simibubi.create.content.logistics.flwdata; + +import org.joml.Vector3f; + +import dev.engine_room.flywheel.api.instance.InstanceHandle; +import dev.engine_room.flywheel.api.instance.InstanceType; +import dev.engine_room.flywheel.lib.instance.AbstractInstance; +import dev.engine_room.flywheel.lib.instance.FlatLit; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.core.BlockPos; + +public class FlapInstance extends AbstractInstance implements FlatLit { + + public float x; + public float y; + public float z; + public byte blockLight; + public byte skyLight; + public int packedLight; + public float segmentOffsetX; + public float segmentOffsetY; + public float segmentOffsetZ; + public float pivotX; + public float pivotY; + public float pivotZ; + public float horizontalAngle; + public float intensity; + public float flapScale; + public float flapness; + + public FlapInstance(InstanceType type, InstanceHandle handle) { + super(type, handle); + } + + + public FlapInstance setPosition(BlockPos pos) { + return setPosition(pos.getX(), pos.getY(), pos.getZ()); + } + + public FlapInstance setPosition(Vector3f pos) { + return setPosition(pos.x(), pos.y(), pos.z()); + } + + public FlapInstance setPosition(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + return this; + } + + @Override + public FlapInstance light(int blockLight, int skyLight) { + return this.light(LightTexture.pack(blockLight, skyLight)); + } + + @Override + public FlapInstance light(int packedLight) { + this.packedLight = packedLight; + return this; + } + + public FlapInstance setSegmentOffset(float x, float y, float z) { + this.segmentOffsetX = x; + this.segmentOffsetY = y; + this.segmentOffsetZ = z; + return this; + } + + public FlapInstance setIntensity(float intensity) { + this.intensity = intensity; + return this; + } + + public FlapInstance setHorizontalAngle(float horizontalAngle) { + this.horizontalAngle = horizontalAngle; + return this; + } + + public FlapInstance setFlapScale(float flapScale) { + this.flapScale = flapScale; + return this; + } + + public FlapInstance setFlapness(float flapness) { + this.flapness = flapness; + return this; + } + + public FlapInstance setPivotVoxelSpace(float x, float y, float z) { + pivotX = x / 16f; + pivotY = y / 16f; + pivotZ = z / 16f; + return this; + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapType.java b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapType.java deleted file mode 100644 index 42adae76ed..0000000000 --- a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapType.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.simibubi.create.content.logistics.flwdata; - -import com.jozufozu.flywheel.api.struct.Batched; -import com.jozufozu.flywheel.api.struct.Instanced; -import com.jozufozu.flywheel.api.struct.StructWriter; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.layout.BufferLayout; -import com.jozufozu.flywheel.core.model.ModelTransformer; -import com.simibubi.create.foundation.render.AllInstanceFormats; -import com.simibubi.create.foundation.render.AllProgramSpecs; - -import net.minecraft.resources.ResourceLocation; - -public class FlapType implements Instanced, Batched { - @Override - public FlapData create() { - return new FlapData(); - } - - @Override - public BufferLayout getLayout() { - return AllInstanceFormats.FLAP; - } - - @Override - public StructWriter getWriter(VecBuffer backing) { - return new UnsafeFlapWriter(backing, this); - } - - @Override - public ResourceLocation getProgramSpec() { - return AllProgramSpecs.FLAPS; - } - - @Override - public void transform(FlapData d, ModelTransformer.Params b) { - b.translate(d.x, d.y, d.z) - .centre() - .rotateY(-d.horizontalAngle) - .unCentre() - .translate(d.pivotX, d.pivotY, d.pivotZ) - .rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale)) - .translateBack(d.pivotX, d.pivotY, d.pivotZ) - .translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ) - .light(d.getPackedLight()); - } - - private static float getFlapAngle(float flapness, float intensity, float scale) { - float absFlap = Math.abs(flapness); - - float angle = (float) (Math.sin((1. - absFlap) * Math.PI * intensity) * 30. * flapness * scale); - - if (flapness > 0) { - return angle * 0.5f; - } else { - return angle; - } - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/flwdata/UnsafeFlapWriter.java b/src/main/java/com/simibubi/create/content/logistics/flwdata/UnsafeFlapWriter.java deleted file mode 100644 index 4ca7961d5d..0000000000 --- a/src/main/java/com/simibubi/create/content/logistics/flwdata/UnsafeFlapWriter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.simibubi.create.content.logistics.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.api.struct.StructType; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; - -public class UnsafeFlapWriter extends UnsafeBufferWriter { - public UnsafeFlapWriter(VecBuffer backingBuffer, StructType vertexType) { - super(backingBuffer, vertexType); - } - - @Override - protected void writeInternal(FlapData d) { - long addr = writePointer; - MemoryUtil.memPutFloat(addr, d.x); - MemoryUtil.memPutFloat(addr + 4, d.y); - MemoryUtil.memPutFloat(addr + 8, d.z); - MemoryUtil.memPutByte(addr + 12, (byte) (d.blockLight << 4)); - MemoryUtil.memPutByte(addr + 13, (byte) (d.skyLight << 4)); - MemoryUtil.memPutFloat(addr + 14, d.segmentOffsetX); - MemoryUtil.memPutFloat(addr + 18, d.segmentOffsetY); - MemoryUtil.memPutFloat(addr + 22, d.segmentOffsetZ); - MemoryUtil.memPutFloat(addr + 26, d.pivotX); - MemoryUtil.memPutFloat(addr + 30, d.pivotY); - MemoryUtil.memPutFloat(addr + 34, d.pivotZ); - MemoryUtil.memPutFloat(addr + 38, d.horizontalAngle); - MemoryUtil.memPutFloat(addr + 42, d.intensity); - MemoryUtil.memPutFloat(addr + 46, d.flapScale); - MemoryUtil.memPutFloat(addr + 50, d.flapness); - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlockEntity.java b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlockEntity.java index 00474106b5..733c8301d8 100644 --- a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlockEntity.java @@ -5,7 +5,6 @@ import java.util.List; import org.apache.commons.lang3.mutable.MutableBoolean; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; import com.simibubi.create.AllSoundEvents; @@ -28,6 +27,7 @@ import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -117,7 +117,7 @@ public class FunnelBlockEntity extends SmartBlockEntity implements IHaveHovering private void activateExtractor() { if (invVersionTracker.stillWaiting(invManipulation)) return; - + BlockState blockState = getBlockState(); Direction facing = AbstractFunnelBlock.getFunnelFacing(blockState); @@ -259,7 +259,7 @@ public class FunnelBlockEntity extends SmartBlockEntity implements IHaveHovering new InvManipulationBehaviour(this, (w, p, s) -> new BlockFace(p, AbstractFunnelBlock.getFunnelFacing(s) .getOpposite())); behaviours.add(invManipulation); - + behaviours.add(invVersionTracker = new VersionedInventoryTrackerBehaviour(this)); filtering = new FilteringBehaviour(this, new FunnelFilterSlotPositioning()); @@ -267,7 +267,7 @@ public class FunnelBlockEntity extends SmartBlockEntity implements IHaveHovering filtering.onlyActiveWhen(this::supportsFiltering); filtering.withCallback($ -> invVersionTracker.reset()); behaviours.add(filtering); - + behaviours.add(new DirectBeltInputBehaviour(this).onlyInsertWhen(this::supportsDirectBeltInput) .setInsertionHandler(this::handleDirectBeltInput)); registerAwardables(behaviours, AllAdvancements.FUNNEL); @@ -363,7 +363,7 @@ public class FunnelBlockEntity extends SmartBlockEntity implements IHaveHovering extractionCooldown = compound.getInt("TransferCooldown"); if (clientPacket) - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> VisualizationHelper.queueUpdate(this)); } public void onTransfer(ItemStack stack) { diff --git a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelFilterSlotPositioning.java b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelFilterSlotPositioning.java index 8de1dd63d1..671d459261 100644 --- a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelFilterSlotPositioning.java +++ b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelFilterSlotPositioning.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.logistics.funnel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.logistics.funnel.BeltFunnelBlock.Shape; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.world.level.block.state.BlockState; @@ -59,23 +59,23 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { Shape shape = state.getValue(BeltFunnelBlock.SHAPE); super.rotate(state, ms); if (shape == Shape.PULLING || shape == Shape.PUSHING) - TransformStack.cast(ms) - .rotateX(-22.5f); + TransformStack.of(ms) + .rotateXDegrees(-22.5f); return; } if (state.getBlock() instanceof FunnelBlock) { super.rotate(state, ms); - TransformStack.cast(ms) - .rotateX(-22.5f); + TransformStack.of(ms) + .rotateXDegrees(-22.5f); return; } float yRot = AngleHelper.horizontalAngle(AbstractFunnelBlock.getFunnelFacing(state)) + (facing == Direction.DOWN ? 180 : 0); - TransformStack.cast(ms) - .rotateY(yRot) - .rotateX(facing == Direction.DOWN ? -90 : 90); + TransformStack.of(ms) + .rotateYDegrees(yRot) + .rotateXDegrees(facing == Direction.DOWN ? -90 : 90); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelInstance.java deleted file mode 100644 index c386dc75d7..0000000000 --- a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelInstance.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.simibubi.create.content.logistics.funnel; - -import java.util.ArrayList; - -import com.jozufozu.flywheel.api.InstanceData; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.jozufozu.flywheel.core.PartialModel; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.logistics.flwdata.FlapData; -import com.simibubi.create.foundation.render.AllMaterialSpecs; -import com.simibubi.create.foundation.utility.AnimationTickHolder; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.LightLayer; - -public class FunnelInstance extends BlockEntityInstance implements DynamicInstance { - - private final ArrayList flaps; - - public FunnelInstance(MaterialManager materialManager, FunnelBlockEntity blockEntity) { - super(materialManager, blockEntity); - - flaps = new ArrayList<>(4); - - if (!blockEntity.hasFlap()) return; - - PartialModel flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllPartialModels.FUNNEL_FLAP - : AllPartialModels.BELT_FUNNEL_FLAP); - Instancer model = materialManager.defaultSolid() - .material(AllMaterialSpecs.FLAPS) - .getModel(flapPartial, blockState); - - int blockLight = world.getBrightness(LightLayer.BLOCK, pos); - int skyLight = world.getBrightness(LightLayer.SKY, pos); - - Direction direction = FunnelBlock.getFunnelFacing(blockState); - - float flapness = blockEntity.flap.getValue(AnimationTickHolder.getPartialTicks()); - float horizontalAngle = direction.getOpposite().toYRot(); - - for (int segment = 0; segment <= 3; segment++) { - float intensity = segment == 3 ? 1.5f : segment + 1; - float segmentOffset = -3.05f / 16f * segment + 0.075f / 16f; - - FlapData key = model.createInstance(); - - key.setPosition(getInstancePosition()) - .setSegmentOffset(segmentOffset, 0, -blockEntity.getFlapOffset()) - .setBlockLight(blockLight) - .setSkyLight(skyLight) - .setHorizontalAngle(horizontalAngle) - .setFlapness(flapness) - .setFlapScale(-1) - .setPivotVoxelSpace(0, 10, 9.5f) - .setIntensity(intensity); - - flaps.add(key); - } - } - - @Override - public void beginFrame() { - if (flaps == null) return; - - float flapness = blockEntity.flap.getValue(AnimationTickHolder.getPartialTicks()); - - for (FlapData flap : flaps) { - flap.setFlapness(flapness); - } - } - - @Override - public void updateLight() { - if (flaps != null) - relight(pos, flaps.stream()); - } - - @Override - public void remove() { - if (flaps == null) return; - - flaps.forEach(InstanceData::delete); - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelMovementBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelMovementBehaviour.java index 9d85eb9746..6f34f46b29 100644 --- a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelMovementBehaviour.java @@ -118,9 +118,4 @@ public class FunnelMovementBehaviour implements MovementBehaviour { } } - @Override - public boolean renderAsNormalBlockEntity() { - return true; - } - } diff --git a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelRenderer.java index 65105f1d49..4be0b1b428 100644 --- a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelRenderer.java @@ -1,8 +1,5 @@ package com.simibubi.create.content.logistics.funnel; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -12,6 +9,9 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -30,7 +30,7 @@ public class FunnelRenderer extends SmartBlockEntityRenderer int light, int overlay) { super.renderSafe(be, partialTicks, ms, buffer, light, overlay); - if (!be.hasFlap() || Backend.canUseInstancing(be.getLevel())) + if (!be.hasFlap() || VisualizationManager.supportsVisualization(be.getLevel())) return; BlockState blockState = be.getBlockState(); @@ -39,16 +39,16 @@ public class FunnelRenderer extends SmartBlockEntityRenderer : AllPartialModels.BELT_FUNNEL_FLAP); SuperByteBuffer flapBuffer = CachedBufferer.partial(partialModel, blockState); Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); float horizontalAngle = AngleHelper.horizontalAngle(FunnelBlock.getFunnelFacing(blockState) .getOpposite()); float f = be.flap.getValue(partialTicks); ms.pushPose(); - msr.centre() - .rotateY(horizontalAngle) - .unCentre(); + msr.center() + .rotateYDegrees(horizontalAngle) + .uncenter(); ms.translate(0.075f / 16f, 0, -be.getFlapOffset()); for (int segment = 0; segment <= 3; segment++) { @@ -61,7 +61,7 @@ public class FunnelRenderer extends SmartBlockEntityRenderer flapAngle *= .5f; msr.translate(pivot) - .rotateX(flapAngle) + .rotateXDegrees(flapAngle) .translateBack(pivot); flapBuffer.light(light) diff --git a/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelVisual.java b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelVisual.java new file mode 100644 index 0000000000..527d2d48bb --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/funnel/FunnelVisual.java @@ -0,0 +1,98 @@ +package com.simibubi.create.content.logistics.funnel; + +import java.util.ArrayList; +import java.util.function.Consumer; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.logistics.flwdata.FlapInstance; +import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.utility.AnimationTickHolder; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.AbstractInstance; +import dev.engine_room.flywheel.lib.instance.FlatLit; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; +import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LightLayer; + +public class FunnelVisual extends AbstractBlockEntityVisual implements SimpleDynamicVisual { + + private final ArrayList flaps; + + public FunnelVisual(VisualizationContext context, FunnelBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + flaps = new ArrayList<>(4); + + if (!blockEntity.hasFlap()) return; + + PartialModel flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllPartialModels.FUNNEL_FLAP + : AllPartialModels.BELT_FUNNEL_FLAP); + Instancer model = instancerProvider.instancer(AllInstanceTypes.FLAP, Models.partial(flapPartial)); + + int blockLight = level.getBrightness(LightLayer.BLOCK, pos); + int skyLight = level.getBrightness(LightLayer.SKY, pos); + + Direction direction = FunnelBlock.getFunnelFacing(blockState); + + float flapness = blockEntity.flap.getValue(AnimationTickHolder.getPartialTicks()); + float horizontalAngle = direction.getOpposite().toYRot(); + + for (int segment = 0; segment <= 3; segment++) { + float intensity = segment == 3 ? 1.5f : segment + 1; + float segmentOffset = -3.05f / 16f * segment + 0.075f / 16f; + + FlapInstance key = model.createInstance(); + + key.setPosition(getVisualPosition()) + .setSegmentOffset(segmentOffset, 0, -blockEntity.getFlapOffset()) + .light(blockLight, skyLight) + .setHorizontalAngle(horizontalAngle) + .setFlapness(flapness) + .setFlapScale(-1) + .setPivotVoxelSpace(0, 10, 9.5f) + .setIntensity(intensity) + .setChanged(); + + flaps.add(key); + } + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + if (flaps == null) return; + + float flapness = blockEntity.flap.getValue(ctx.partialTick()); + + for (FlapInstance flap : flaps) { + flap.setFlapness(flapness) + .setChanged(); + } + } + + @Override + public void updateLight(float partialTick) { + if (flaps != null) + relight(flaps.toArray(FlatLit[]::new)); + } + + @Override + protected void _delete() { + if (flaps == null) return; + + flaps.forEach(AbstractInstance::delete); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + if (flaps == null) return; + + flaps.forEach(consumer); + } +} diff --git a/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelBlockEntity.java b/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelBlockEntity.java index 4120501568..9a932ce55b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelBlockEntity.java @@ -9,7 +9,6 @@ import java.util.Set; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; import com.simibubi.create.content.logistics.funnel.BeltFunnelBlock; @@ -20,6 +19,7 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -109,7 +109,7 @@ public class BeltTunnelBlockEntity extends SmartBlockEntity { sides.addAll(flaps.keySet()); super.read(compound, clientPacket); if (clientPacket) - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> VisualizationHelper.queueUpdate(this)); } private LerpedFloat createChasingFlap() { diff --git a/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelInstance.java deleted file mode 100644 index ccbd7d4a07..0000000000 --- a/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelInstance.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.simibubi.create.content.logistics.tunnel; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumMap; -import java.util.Map; - -import com.jozufozu.flywheel.api.InstanceData; -import com.jozufozu.flywheel.api.Instancer; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.logistics.flwdata.FlapData; -import com.simibubi.create.foundation.render.AllMaterialSpecs; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.animation.LerpedFloat; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.LightLayer; - -public class BeltTunnelInstance extends BlockEntityInstance implements DynamicInstance { - - private final Map> tunnelFlaps; - - public BeltTunnelInstance(MaterialManager materialManager, BeltTunnelBlockEntity blockEntity) { - super(materialManager, blockEntity); - - tunnelFlaps = new EnumMap<>(Direction.class); - - Instancer model = materialManager.defaultSolid() - .material(AllMaterialSpecs.FLAPS) - .getModel(AllPartialModels.BELT_TUNNEL_FLAP, blockState); - - int blockLight = world.getBrightness(LightLayer.BLOCK, pos); - int skyLight = world.getBrightness(LightLayer.SKY, pos); - - blockEntity.flaps.forEach((direction, flapValue) -> { - - float flapness = flapValue.getValue(AnimationTickHolder.getPartialTicks()); - - float horizontalAngle = direction.getOpposite().toYRot(); - - float flapScale = direction.getAxis() == Direction.Axis.X ? 1 : -1; - - ArrayList flaps = new ArrayList<>(4); - - for (int segment = 0; segment <= 3; segment++) { - float intensity = segment == 3 ? 1.5f : segment + 1; - float segmentOffset = -3.05f / 16f * segment + 0.075f / 16f; - - FlapData key = model.createInstance(); - - key.setPosition(getInstancePosition()) - .setSegmentOffset(segmentOffset, 0, 0) - .setBlockLight(blockLight) - .setSkyLight(skyLight) - .setHorizontalAngle(horizontalAngle) - .setFlapness(flapness) - .setFlapScale(flapScale) - .setPivotVoxelSpace(0, 10, 1) - .setIntensity(intensity); - - flaps.add(key); - } - - tunnelFlaps.put(direction, flaps); - }); - } - - @Override - public boolean shouldReset() { - return super.shouldReset() || tunnelFlaps.size() != blockEntity.flaps.size(); - } - - @Override - public void beginFrame() { - tunnelFlaps.forEach((direction, keys) -> { - LerpedFloat lerpedFloat = blockEntity.flaps.get(direction); - if (lerpedFloat == null) - return; - - float flapness = lerpedFloat.getValue(AnimationTickHolder.getPartialTicks()); - for (FlapData flap : keys) { - flap.setFlapness(flapness); - } - }); - } - - @Override - public void updateLight() { - relight(pos, tunnelFlaps.values().stream().flatMap(Collection::stream)); - } - - @Override - public void remove() { - tunnelFlaps.values() - .stream() - .flatMap(Collection::stream) - .forEach(InstanceData::delete); - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelRenderer.java index 5bcc9af4e0..6cfa1c5c49 100644 --- a/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/tunnel/BeltTunnelRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.logistics.tunnel; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -12,6 +10,8 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -31,13 +31,13 @@ public class BeltTunnelRenderer extends SmartBlockEntityRenderer implements SimpleDynamicVisual { + + private final Map> tunnelFlaps = new EnumMap<>(Direction.class); + + public BeltTunnelVisual(VisualizationContext context, BeltTunnelBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + setupFlaps(partialTick); + } + + private void setupFlaps(float partialTick) { + Instancer model = instancerProvider.instancer(AllInstanceTypes.FLAP, Models.partial(AllPartialModels.BELT_TUNNEL_FLAP)); + + int blockLight = level.getBrightness(LightLayer.BLOCK, pos); + int skyLight = level.getBrightness(LightLayer.SKY, pos); + + blockEntity.flaps.forEach((direction, flapValue) -> { + + float flapness = flapValue.getValue(partialTick); + + float horizontalAngle = direction.getOpposite().toYRot(); + + float flapScale = direction.getAxis() == Direction.Axis.X ? 1 : -1; + + ArrayList flaps = new ArrayList<>(4); + + for (int segment = 0; segment <= 3; segment++) { + float intensity = segment == 3 ? 1.5f : segment + 1; + float segmentOffset = -3.05f / 16f * segment + 0.075f / 16f; + + FlapInstance key = model.createInstance(); + + key.setPosition(getVisualPosition()) + .setSegmentOffset(segmentOffset, 0, 0) + .light(blockLight, skyLight) + .setHorizontalAngle(horizontalAngle) + .setFlapness(flapness) + .setFlapScale(flapScale) + .setPivotVoxelSpace(0, 10, 1) + .setIntensity(intensity) + .setChanged(); + + flaps.add(key); + } + + tunnelFlaps.put(direction, flaps); + }); + } + + @Override + public void update(float partialTick) { + super.update(partialTick); + + _delete(); + setupFlaps(partialTick); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + tunnelFlaps.forEach((direction, keys) -> { + LerpedFloat lerpedFloat = blockEntity.flaps.get(direction); + if (lerpedFloat == null) + return; + + float flapness = lerpedFloat.getValue(ctx.partialTick()); + for (FlapInstance flap : keys) { + flap.setFlapness(flapness) + .setChanged(); + } + }); + } + + @Override + public void updateLight(float partialTick) { + relight(tunnelFlaps.values().stream().flatMap(Collection::stream).toArray(FlatLit[]::new)); + } + + @Override + protected void _delete() { + tunnelFlaps.values() + .stream() + .flatMap(Collection::stream) + .forEach(AbstractInstance::delete); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + tunnelFlaps.values() + .stream() + .flatMap(Collection::stream) + .forEach(consumer); + } +} diff --git a/src/main/java/com/simibubi/create/content/processing/basin/BasinMovementBehaviour.java b/src/main/java/com/simibubi/create/content/processing/basin/BasinMovementBehaviour.java index 646c3783d0..85f183bac8 100644 --- a/src/main/java/com/simibubi/create/content/processing/basin/BasinMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/processing/basin/BasinMovementBehaviour.java @@ -22,11 +22,6 @@ public class BasinMovementBehaviour implements MovementBehaviour { return map; } - @Override - public boolean renderAsNormalBlockEntity() { - return true; - } - @Override public void tick(MovementContext context) { MovementBehaviour.super.tick(context); diff --git a/src/main/java/com/simibubi/create/content/processing/basin/BasinRenderer.java b/src/main/java/com/simibubi/create/content/processing/basin/BasinRenderer.java index 6b47a0e9c0..9d4dec2043 100644 --- a/src/main/java/com/simibubi/create/content/processing/basin/BasinRenderer.java +++ b/src/main/java/com/simibubi/create/content/processing/basin/BasinRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.processing.basin; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -45,8 +45,8 @@ public class BasinRenderer extends SmartBlockEntityRenderer { BlockPos pos = basin.getBlockPos(); ms.translate(.5, .2f, .5); - TransformStack.cast(ms) - .rotateY(basin.ingredientRotation.getValue(partialTicks)); + TransformStack.of(ms) + .rotateYDegrees(basin.ingredientRotation.getValue(partialTicks)); RandomSource r = RandomSource.create(pos.hashCode()); Vec3 baseVector = new Vec3(.125, level, 0); @@ -79,9 +79,9 @@ public class BasinRenderer extends SmartBlockEntityRenderer { Vec3 itemPosition = VecHelper.rotate(baseVector, anglePartition * itemCount, Axis.Y); ms.translate(itemPosition.x, itemPosition.y, itemPosition.z); - TransformStack.cast(ms) - .rotateY(anglePartition * itemCount + 35) - .rotateX(65); + TransformStack.of(ms) + .rotateYDegrees(anglePartition * itemCount + 35) + .rotateXDegrees(65); for (int i = 0; i <= stack.getCount() / 8; i++) { ms.pushPose(); @@ -121,12 +121,12 @@ public class BasinRenderer extends SmartBlockEntityRenderer { continue; ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(outVec) .translate(new Vec3(0, Math.max(-.55f, -(progress * progress * 2)), 0)) .translate(directionVec.scale(progress * .5f)) - .rotateY(AngleHelper.horizontalAngle(direction)) - .rotateX(progress * 180); + .rotateYDegrees(AngleHelper.horizontalAngle(direction)) + .rotateXDegrees(progress * 180); renderItem(ms, buffer, light, overlay, intAttached.getValue()); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java index 10fba90a71..e5352a8dff 100644 --- a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java @@ -14,6 +14,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import dev.engine_room.flywheel.api.backend.BackendManager; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; @@ -75,7 +76,8 @@ public class BlazeBurnerBlockEntity extends SmartBlockEntity { super.tick(); if (level.isClientSide) { - tickAnimation(); + if (shouldTickAnimation()) + tickAnimation(); if (!isVirtual()) spawnParticles(getHeatLevelFromBlock(), 1); return; @@ -102,7 +104,13 @@ public class BlazeBurnerBlockEntity extends SmartBlockEntity { } @OnlyIn(Dist.CLIENT) - private void tickAnimation() { + private boolean shouldTickAnimation() { + // Offload the animation tick to the visual when flywheel in enabled + return !BackendManager.isBackendOn(); + } + + @OnlyIn(Dist.CLIENT) + void tickAnimation() { boolean active = getHeatLevelFromBlock().isAtLeast(HeatLevel.FADING) && isValidBlockAbove(); if (!active) { @@ -305,14 +313,14 @@ public class BlazeBurnerBlockEntity extends SmartBlockEntity { Vec3 c = VecHelper.getCenterOf(worldPosition); Vec3 v = c.add(VecHelper.offsetRandomly(Vec3.ZERO, r, .125f) .multiply(1, 0, 1)); - + if (r.nextInt(4) != 0) return; boolean empty = level.getBlockState(worldPosition.above()) .getCollisionShape(level, worldPosition.above()) .isEmpty(); - + if (empty || r.nextInt(8) == 0) level.addParticle(ParticleTypes.LARGE_SMOKE, v.x, v.y, v.z, 0, 0, 0); diff --git a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerMovementBehaviour.java index 2904d30046..3074fc8afc 100644 --- a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerMovementBehaviour.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.processing.burner; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; @@ -13,6 +12,7 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; @@ -30,11 +30,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlazeBurnerMovementBehaviour implements MovementBehaviour { - @Override - public boolean renderAsNormalBlockEntity() { - return false; - } - @Override public ItemStack canBeDisabledVia(MovementContext context) { return null; @@ -117,6 +112,11 @@ public class BlazeBurnerMovementBehaviour implements MovementBehaviour { return false; } + @Override + public boolean disableBlockEntityRendering() { + return true; + } + @Override @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, diff --git a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerRenderer.java b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerRenderer.java index 976db1a60f..002b4c9366 100644 --- a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerRenderer.java +++ b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerRenderer.java @@ -2,8 +2,6 @@ package com.simibubi.create.content.processing.burner; import javax.annotation.Nullable; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -18,7 +16,9 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -124,15 +124,7 @@ public class BlazeBurnerRenderer extends SafeBlockEntityRenderer implements SimpleDynamicVisual, SimpleTickableVisual { + + private final BlazeBurnerBlock.HeatLevel heatLevel; + + private final TransformedInstance head; + private final TransformedInstance smallRods; + private final TransformedInstance largeRods; + + private final boolean isInert; + + @Nullable + private ScrollInstance flame; + @Nullable + private TransformedInstance goggles; + @Nullable + private TransformedInstance hat; + + private boolean validBlockAbove; + + public BlazeBurnerVisual(VisualizationContext ctx, BlazeBurnerBlockEntity blockEntity, float partialTick) { + super(ctx, blockEntity, partialTick); + + heatLevel = blockEntity.getHeatLevelFromBlock(); + validBlockAbove = blockEntity.isValidBlockAbove(); + + PartialModel blazeModel = BlazeBurnerRenderer.getBlazeModel(heatLevel, validBlockAbove); + isInert = blazeModel == AllPartialModels.BLAZE_INERT; + + head = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(blazeModel)) + .createInstance(); + + head.light(LightTexture.FULL_BRIGHT); + + if (heatLevel.isAtLeast(BlazeBurnerBlock.HeatLevel.FADING)) { + PartialModel rodsModel = heatLevel == BlazeBurnerBlock.HeatLevel.SEETHING ? AllPartialModels.BLAZE_BURNER_SUPER_RODS + : AllPartialModels.BLAZE_BURNER_RODS; + PartialModel rodsModel2 = heatLevel == BlazeBurnerBlock.HeatLevel.SEETHING ? AllPartialModels.BLAZE_BURNER_SUPER_RODS_2 + : AllPartialModels.BLAZE_BURNER_RODS_2; + + smallRods = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(rodsModel)) + .createInstance(); + largeRods = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(rodsModel2)) + .createInstance(); + + smallRods.light(LightTexture.FULL_BRIGHT); + largeRods.light(LightTexture.FULL_BRIGHT); + } else { + smallRods = null; + largeRods = null; + } + } + + @Override + public void tick(TickableVisual.Context context) { + blockEntity.tickAnimation(); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + if (!isVisible(ctx.frustum()) || doDistanceLimitThisFrame(ctx)) { + return; + } + + float animation = blockEntity.headAnimation.getValue(ctx.partialTick()) * .175f; + + boolean validBlockAbove = animation > 0.125f; + + if (validBlockAbove != this.validBlockAbove) { + this.validBlockAbove = validBlockAbove; + + PartialModel blazeModel = BlazeBurnerRenderer.getBlazeModel(heatLevel, validBlockAbove); + instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(blazeModel)) + .stealInstance(head); + } + + // Switch between showing/hiding the flame + if (validBlockAbove && flame == null) { + setupFlameInstance(); + } else if (!validBlockAbove && flame != null) { + flame.delete(); + flame = null; + } + + if (blockEntity.goggles && goggles == null) { + goggles = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(isInert ? AllPartialModels.BLAZE_GOGGLES_SMALL : AllPartialModels.BLAZE_GOGGLES)) + .createInstance(); + goggles.light(LightTexture.FULL_BRIGHT); + } else if (!blockEntity.goggles && goggles != null) { + goggles.delete(); + goggles = null; + } + + if (blockEntity.hat && hat == null) { + hat = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.TRAIN_HAT)) + .createInstance(); + hat.light(LightTexture.FULL_BRIGHT); + } else if (!blockEntity.hat && hat != null) { + hat.delete(); + hat = null; + } + + var hashCode = blockEntity.hashCode(); + float time = AnimationTickHolder.getRenderTime(level); + float renderTick = time + (hashCode % 13) * 16f; + float offsetMult = heatLevel.isAtLeast(BlazeBurnerBlock.HeatLevel.FADING) ? 64 : 16; + float offset = Mth.sin((float) ((renderTick / 16f) % (2 * Math.PI))) / offsetMult; + float headY = offset - (animation * .75f); + + float horizontalAngle = AngleHelper.rad(blockEntity.headAngle.getValue(ctx.partialTick())); + + head.setIdentityTransform() + .translate(getVisualPosition()) + .translateY(headY) + .translate(Translate.CENTER) + .rotateY(horizontalAngle) + .translateBack(Translate.CENTER) + .setChanged(); + + if (goggles != null) { + goggles.setIdentityTransform() + .translate(getVisualPosition()) + .translateY(headY + 8 / 16f) + .translate(Translate.CENTER) + .rotateY(horizontalAngle) + .translateBack(Translate.CENTER) + .setChanged(); + } + + if (hat != null) { + hat.setIdentityTransform() + .translate(getVisualPosition()) + .translateY(headY); + if (isInert) { + hat.translateY(0.5f) + .center() + .scale(0.75f) + .uncenter(); + } else { + hat.translateY(0.75f); + } + hat.rotateCentered(horizontalAngle + Mth.PI, Direction.UP) + .translate(0.5f, 0, 0.5f) + .light(LightTexture.FULL_BRIGHT); + + hat.setChanged(); + } + + if (smallRods != null) { + float offset1 = Mth.sin((float) ((renderTick / 16f + Math.PI) % (2 * Math.PI))) / offsetMult; + + smallRods.setIdentityTransform() + .translate(getVisualPosition()) + .translateY(offset1 + animation + .125f) + .setChanged(); + } + + if (largeRods != null) { + float offset2 = Mth.sin((float) ((renderTick / 16f + Math.PI / 2) % (2 * Math.PI))) / offsetMult; + + largeRods.setIdentityTransform() + .translate(getVisualPosition()) + .translateY(offset2 + animation - 3 / 16f) + .setChanged(); + } + } + + private void setupFlameInstance() { + flame = instancerProvider.instancer(AllInstanceTypes.SCROLLING, Models.partial(AllPartialModels.BLAZE_BURNER_FLAME)) + .createInstance(); + + flame.position(getVisualPosition()) + .light(LightTexture.FULL_BRIGHT); + + SpriteShiftEntry spriteShift = + heatLevel == BlazeBurnerBlock.HeatLevel.SEETHING ? AllSpriteShifts.SUPER_BURNER_FLAME : AllSpriteShifts.BURNER_FLAME; + + float spriteWidth = spriteShift.getTarget() + .getU1() + - spriteShift.getTarget() + .getU0(); + + float spriteHeight = spriteShift.getTarget() + .getV1() + - spriteShift.getTarget() + .getV0(); + + float speed = 1 / 32f + 1 / 64f * heatLevel.ordinal(); + + flame.speedU = speed / 2; + flame.speedV = speed; + + flame.scaleU = spriteWidth / 2; + flame.scaleV = spriteHeight / 2; + + flame.diffU = spriteShift.getTarget().getU0() - spriteShift.getOriginal().getU0(); + flame.diffV = spriteShift.getTarget().getV0() - spriteShift.getOriginal().getV0(); + } + + @Override + public void updateLight(float partialTick) { + } + + @Override + public void collectCrumblingInstances(Consumer<@Nullable Instance> consumer) { + + } + + @Override + protected void _delete() { + head.delete(); + if (smallRods != null) { + smallRods.delete(); + } + if (largeRods != null) { + largeRods.delete(); + } + if (flame != null) { + flame.delete(); + } + if (goggles != null) { + goggles.delete(); + } + if (hat != null) { + hat.delete(); + } + } +} diff --git a/src/main/java/com/simibubi/create/content/processing/burner/ScrollInstance.java b/src/main/java/com/simibubi/create/content/processing/burner/ScrollInstance.java new file mode 100644 index 0000000000..12bcc25e1a --- /dev/null +++ b/src/main/java/com/simibubi/create/content/processing/burner/ScrollInstance.java @@ -0,0 +1,35 @@ +package com.simibubi.create.content.processing.burner; + +import org.joml.Quaternionf; + +import dev.engine_room.flywheel.api.instance.InstanceHandle; +import dev.engine_room.flywheel.api.instance.InstanceType; +import dev.engine_room.flywheel.lib.instance.ColoredLitInstance; +import net.minecraft.core.Vec3i; + +public class ScrollInstance extends ColoredLitInstance { + public float x; + public float y; + public float z; + public final Quaternionf rotation = new Quaternionf(); + + public float speedU; + public float speedV; + + public float diffU; + public float diffV; + + public float scaleU; + public float scaleV; + + public ScrollInstance(InstanceType type, InstanceHandle handle) { + super(type, handle); + } + + public ScrollInstance position(Vec3i position) { + this.x = position.getX(); + this.y = position.getY(); + this.z = position.getZ(); + return this; + } +} diff --git a/src/main/java/com/simibubi/create/content/redstone/FilteredDetectorFilterSlot.java b/src/main/java/com/simibubi/create/content/redstone/FilteredDetectorFilterSlot.java index 04c7ebf3c9..616e256d53 100644 --- a/src/main/java/com/simibubi/create/content/redstone/FilteredDetectorFilterSlot.java +++ b/src/main/java/com/simibubi/create/content/redstone/FilteredDetectorFilterSlot.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.redstone; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.world.level.block.state.BlockState; @@ -47,8 +47,8 @@ public class FilteredDetectorFilterSlot extends ValueBoxTransform.Sided { return; if (getSide() != Direction.UP) return; - TransformStack.cast(ms) - .rotateZ(-AngleHelper.horizontalAngle(facing) + 180); + TransformStack.of(ms) + .rotateZDegrees(-AngleHelper.horizontalAngle(facing) + 180); } @Override diff --git a/src/main/java/com/simibubi/create/content/redstone/analogLever/AnalogLeverInstance.java b/src/main/java/com/simibubi/create/content/redstone/analogLever/AnalogLeverInstance.java deleted file mode 100644 index b7c42523f2..0000000000 --- a/src/main/java/com/simibubi/create/content/redstone/analogLever/AnalogLeverInstance.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.simibubi.create.content.redstone.analogLever; - -import com.jozufozu.flywheel.api.Material; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.util.transform.Rotate; -import com.jozufozu.flywheel.util.transform.Translate; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.Color; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.properties.AttachFace; - -public class AnalogLeverInstance extends BlockEntityInstance implements DynamicInstance { - - protected final ModelData handle; - protected final ModelData indicator; - - final float rX; - final float rY; - - public AnalogLeverInstance(MaterialManager materialManager, AnalogLeverBlockEntity blockEntity) { - super(materialManager, blockEntity); - - Material mat = getTransformMaterial(); - - handle = mat.getModel(AllPartialModels.ANALOG_LEVER_HANDLE, blockState) - .createInstance(); - indicator = mat.getModel(AllPartialModels.ANALOG_LEVER_INDICATOR, blockState) - .createInstance(); - - AttachFace face = blockState.getValue(AnalogLeverBlock.FACE); - rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; - rY = AngleHelper.horizontalAngle(blockState.getValue(AnalogLeverBlock.FACING)); - - transform(indicator.loadIdentity()); - animateLever(); - } - - @Override - public void beginFrame() { - if (!blockEntity.clientState.settled()) - animateLever(); - } - - protected void animateLever() { - float state = blockEntity.clientState.getValue(AnimationTickHolder.getPartialTicks()); - - indicator.setColor(Color.mixColors(0x2C0300, 0xCD0000, state / 15f)); - - float angle = (float) ((state / 15) * 90 / 180 * Math.PI); - - transform(handle.loadIdentity()).translate(1 / 2f, 1 / 16f, 1 / 2f) - .rotate(Direction.EAST, angle) - .translate(-1 / 2f, -1 / 16f, -1 / 2f); - } - - @Override - public void remove() { - handle.delete(); - indicator.delete(); - } - - @Override - public void updateLight() { - relight(pos, handle, indicator); - } - - private & Rotate> T transform(T msr) { - return msr.translate(getInstancePosition()) - .centre() - .rotate(Direction.UP, (float) (rY / 180 * Math.PI)) - .rotate(Direction.EAST, (float) (rX / 180 * Math.PI)) - .unCentre(); - } -} diff --git a/src/main/java/com/simibubi/create/content/redstone/analogLever/AnalogLeverRenderer.java b/src/main/java/com/simibubi/create/content/redstone/analogLever/AnalogLeverRenderer.java index 89a6150c16..e544e026a2 100644 --- a/src/main/java/com/simibubi/create/content/redstone/analogLever/AnalogLeverRenderer.java +++ b/src/main/java/com/simibubi/create/content/redstone/analogLever/AnalogLeverRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.redstone.analogLever; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -26,7 +26,7 @@ public class AnalogLeverRenderer extends SafeBlockEntityRenderer implements SimpleDynamicVisual { + + protected final TransformedInstance handle; + protected final TransformedInstance indicator; + + final float rX; + final float rY; + + public AnalogLeverVisual(VisualizationContext context, AnalogLeverBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + handle = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ANALOG_LEVER_HANDLE)) + .createInstance(); + indicator = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.ANALOG_LEVER_INDICATOR)) + .createInstance(); + + AttachFace face = blockState.getValue(AnalogLeverBlock.FACE); + rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; + rY = AngleHelper.horizontalAngle(blockState.getValue(AnalogLeverBlock.FACING)); + + transform(indicator.setIdentityTransform()); + + animateLever(partialTick); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + if (!blockEntity.clientState.settled()) + animateLever(ctx.partialTick()); + } + + protected void animateLever(float pt) { + float state = blockEntity.clientState.getValue(pt); + + indicator.colorRgb(Color.mixColors(0x2C0300, 0xCD0000, state / 15f)); + indicator.setChanged(); + + float angle = (float) ((state / 15) * 90 / 180 * Math.PI); + + transform(handle.setIdentityTransform()).translate(1 / 2f, 1 / 16f, 1 / 2f) + .rotate(angle, Direction.EAST) + .translate(-1 / 2f, -1 / 16f, -1 / 2f) + .setChanged(); + } + + @Override + protected void _delete() { + handle.delete(); + indicator.delete(); + } + + @Override + public void updateLight(float partialTick) { + relight(handle, indicator); + } + + private & Rotate> T transform(T msr) { + return msr.translate(getVisualPosition()) + .center() + .rotate((float) (rY / 180 * Math.PI), Direction.UP) + .rotate((float) (rX / 180 * Math.PI), Direction.EAST) + .uncenter(); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(handle); + consumer.accept(indicator); + } +} diff --git a/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeInstance.java b/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeInstance.java deleted file mode 100644 index 0c51e6b76d..0000000000 --- a/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeInstance.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.simibubi.create.content.redstone.diodes; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.TickableInstance; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.foundation.utility.Color; - -public class BrassDiodeInstance extends BlockEntityInstance implements TickableInstance { - - protected final ModelData indicator; - - protected int previousState; - - public BrassDiodeInstance(MaterialManager materialManager, BrassDiodeBlockEntity blockEntity) { - super(materialManager, blockEntity); - - indicator = materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(AllPartialModels.FLEXPEATER_INDICATOR, blockState).createInstance(); - - indicator.loadIdentity() - .translate(getInstancePosition()) - .setColor(getColor()); - - previousState = blockEntity.state; - } - - @Override - public void tick() { - if (previousState == blockEntity.state) return; - - indicator.setColor(getColor()); - - previousState = blockEntity.state; - } - - @Override - public void updateLight() { - relight(pos, indicator); - } - - @Override - public void remove() { - indicator.delete(); - } - - protected int getColor() { - return Color.mixColors(0x2c0300, 0xcd0000, blockEntity.getProgress()); - } -} diff --git a/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeScrollSlot.java b/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeScrollSlot.java index c492cae703..c7306af4e3 100644 --- a/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeScrollSlot.java +++ b/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeScrollSlot.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.redstone.diodes; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.Vec3; @@ -20,14 +20,14 @@ public class BrassDiodeScrollSlot extends ValueBoxTransform { @Override public void rotate(BlockState state, PoseStack ms) { float yRot = AngleHelper.horizontalAngle(state.getValue(BlockStateProperties.HORIZONTAL_FACING)) + 180; - TransformStack.cast(ms) - .rotateY(yRot) - .rotateX(90); + TransformStack.of(ms) + .rotateYDegrees(yRot) + .rotateXDegrees(90); } @Override public int getOverrideColor() { return 0x592424; } - + } diff --git a/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeVisual.java b/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeVisual.java new file mode 100644 index 0000000000..4b191fff7f --- /dev/null +++ b/src/main/java/com/simibubi/create/content/redstone/diodes/BrassDiodeVisual.java @@ -0,0 +1,64 @@ +package com.simibubi.create.content.redstone.diodes; + +import java.util.function.Consumer; + +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.foundation.utility.Color; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.visual.TickableVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; +import dev.engine_room.flywheel.lib.visual.SimpleTickableVisual; + +public class BrassDiodeVisual extends AbstractBlockEntityVisual implements SimpleTickableVisual { + + protected final TransformedInstance indicator; + + protected int previousState; + + public BrassDiodeVisual(VisualizationContext context, BrassDiodeBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + indicator = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.FLEXPEATER_INDICATOR)).createInstance(); + + indicator.setIdentityTransform() + .translate(getVisualPosition()) + .colorRgb(getColor()) + .setChanged(); + + previousState = blockEntity.state; + } + + @Override + public void tick(TickableVisual.Context context) { + if (previousState == blockEntity.state) return; + + indicator.colorRgb(getColor()); + indicator.setChanged(); + + previousState = blockEntity.state; + } + + @Override + public void updateLight(float partialTick) { + relight(indicator); + } + + @Override + protected void _delete() { + indicator.delete(); + } + + protected int getColor() { + return Color.mixColors(0x2c0300, 0xcd0000, blockEntity.getProgress()); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(indicator); + } +} diff --git a/src/main/java/com/simibubi/create/content/redstone/displayLink/DisplayLinkRenderer.java b/src/main/java/com/simibubi/create/content/redstone/displayLink/DisplayLinkRenderer.java index c53bb68e8d..9ca03ea537 100644 --- a/src/main/java/com/simibubi/create/content/redstone/displayLink/DisplayLinkRenderer.java +++ b/src/main/java/com/simibubi/create/content/redstone/displayLink/DisplayLinkRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.redstone.displayLink; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; @@ -8,6 +7,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -33,7 +33,7 @@ public class DisplayLinkRenderer extends SafeBlockEntityRenderer buttons; @@ -88,7 +88,7 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere PartialItemModelRenderer renderer, ItemDisplayContext transformType, PoseStack ms, int light, RenderType renderType, boolean active, boolean renderDepression) { float pt = AnimationTickHolder.getPartialTicks(); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); ms.pushPose(); @@ -107,8 +107,8 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere float equip = equipProgress.getValue(pt); int handModifier = transformType == ItemDisplayContext.FIRST_PERSON_LEFT_HAND ? -1 : 1; msr.translate(0, equip / 4, equip / 4 * handModifier); - msr.rotateY(equip * -30 * handModifier); - msr.rotateZ(equip * -30); + msr.rotateYDegrees(equip * -30 * handModifier); + msr.rotateZDegrees(equip * -30); active = true; } diff --git a/src/main/java/com/simibubi/create/content/redstone/nixieTube/NixieTubeRenderer.java b/src/main/java/com/simibubi/create/content/redstone/nixieTube/NixieTubeRenderer.java index 087636090d..19ca595eba 100644 --- a/src/main/java/com/simibubi/create/content/redstone/nixieTube/NixieTubeRenderer.java +++ b/src/main/java/com/simibubi/create/content/redstone/nixieTube/NixieTubeRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.redstone.nixieTube; import java.util.Random; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.redstone.nixieTube.DoubleFaceAttachedBlock.DoubleAttachFace; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.DyeHelper; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.font.glyphs.BakedGlyph; @@ -46,11 +46,11 @@ public class NixieTubeRenderer extends SafeBlockEntityRenderer implements DynamicInstance { - - private final ModelData connector; - private final ModelData pipe; - - public SchematicannonInstance(MaterialManager materialManager, SchematicannonBlockEntity blockEntity) { - super(materialManager, blockEntity); - - Material mat = getTransformMaterial(); - - connector = mat.getModel(AllPartialModels.SCHEMATICANNON_CONNECTOR, blockState).createInstance(); - pipe = mat.getModel(AllPartialModels.SCHEMATICANNON_PIPE, blockState).createInstance(); - } - - @Override - public void beginFrame() { - float partialTicks = AnimationTickHolder.getPartialTicks(); - - double[] cannonAngles = SchematicannonRenderer.getCannonAngles(blockEntity, pos, partialTicks); - - double yaw = cannonAngles[0]; - double pitch = cannonAngles[1]; - - double recoil = SchematicannonRenderer.getRecoil(blockEntity, partialTicks); - - PoseStack ms = new PoseStack(); - TransformStack msr = TransformStack.cast(ms); - - msr.translate(getInstancePosition()); - - ms.pushPose(); - msr.centre(); - msr.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI)); - msr.unCentre(); - connector.setTransform(ms); - ms.popPose(); - - msr.translate(.5f, 15 / 16f, .5f); - msr.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI)); - msr.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI)); - msr.translateBack(.5f, 15 / 16f, .5f); - msr.translate(0, -recoil / 100, 0); - - pipe.setTransform(ms); - } - - @Override - public void remove() { - connector.delete(); - pipe.delete(); - } - - @Override - public void updateLight() { - relight(pos, connector, pipe); - } -} diff --git a/src/main/java/com/simibubi/create/content/schematics/cannon/SchematicannonRenderer.java b/src/main/java/com/simibubi/create/content/schematics/cannon/SchematicannonRenderer.java index 7b70905ae7..e34e3e3e1f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/cannon/SchematicannonRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/cannon/SchematicannonRenderer.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.schematics.cannon; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.core.model.ModelUtil; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; @@ -13,7 +11,9 @@ import com.simibubi.create.content.schematics.cannon.LaunchedItem.ForEntity; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.VirtualRenderHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -39,7 +39,7 @@ public class SchematicannonRenderer extends SafeBlockEntityRenderer implements SimpleDynamicVisual { + + private final TransformedInstance connector; + private final TransformedInstance pipe; + + public SchematicannonVisual(VisualizationContext context, SchematicannonBlockEntity blockEntity, float partialTick) { + super(context, blockEntity, partialTick); + + connector = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.SCHEMATICANNON_CONNECTOR)).createInstance(); + pipe = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.SCHEMATICANNON_PIPE)).createInstance(); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + float partialTicks = ctx.partialTick(); + + double[] cannonAngles = SchematicannonRenderer.getCannonAngles(blockEntity, pos, partialTicks); + + double yaw = cannonAngles[0]; + double pitch = cannonAngles[1]; + + double recoil = SchematicannonRenderer.getRecoil(blockEntity, partialTicks); + + PoseStack ms = new PoseStack(); + var msr = TransformStack.of(ms); + + msr.translate(getVisualPosition()); + + ms.pushPose(); + msr.center(); + msr.rotate((float) ((yaw + 90) / 180 * Math.PI), Direction.UP); + msr.uncenter(); + connector.setTransform(ms); + ms.popPose(); + + msr.translate(.5f, 15 / 16f, .5f); + msr.rotate((float) ((yaw + 90) / 180 * Math.PI), Direction.UP); + msr.rotate((float) (pitch / 180 * Math.PI), Direction.SOUTH); + msr.translateBack(.5f, 15 / 16f, .5f); + msr.translate(0, -recoil / 100, 0); + + pipe.setTransform(ms); + + connector.setChanged(); + pipe.setChanged(); + } + + @Override + protected void _delete() { + connector.delete(); + pipe.delete(); + } + + @Override + public void updateLight(float partialTick) { + relight(connector, pipe); + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(connector); + consumer.accept(pipe); + } +} diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java index 5fe24465a7..a119bf330f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java @@ -3,18 +3,14 @@ package com.simibubi.create.content.schematics.client; import java.util.LinkedHashMap; import java.util.Map; -import com.jozufozu.flywheel.core.model.ModelUtil; -import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferedData; -import com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexFormat; import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.foundation.render.BlockEntityRenderHelper; +import com.simibubi.create.foundation.render.ShadedBlockSbbBuilder; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; +import dev.engine_room.flywheel.lib.model.ModelUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.BlockRenderDispatcher; @@ -79,15 +75,12 @@ public class SchematicRenderer { } protected void redraw() { - bufferCache.forEach((layer, sbb) -> sbb.delete()); bufferCache.clear(); for (RenderType layer : RenderType.chunkBufferLayers()) { SuperByteBuffer buffer = drawLayer(layer); if (!buffer.isEmpty()) bufferCache.put(layer, buffer); - else - buffer.delete(); } } @@ -100,17 +93,12 @@ public class SchematicRenderer { RandomSource random = objects.random; BlockPos.MutableBlockPos mutableBlockPos = objects.mutableBlockPos; SchematicWorld renderWorld = schematic; - renderWorld.renderMode = true; BoundingBox bounds = renderWorld.getBounds(); - ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper; - BufferBuilder shadedBuilder = objects.shadedBuilder; - BufferBuilder unshadedBuilder = objects.unshadedBuilder; - - shadedBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - unshadedBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - shadeSeparatingWrapper.prepare(shadedBuilder, unshadedBuilder); + ShadedBlockSbbBuilder sbbBuilder = objects.sbbBuilder; + sbbBuilder.begin(); + renderWorld.renderMode = true; ModelBlockRenderer.enableCaching(); for (BlockPos localPos : BlockPos.betweenClosed(bounds.minX(), bounds.minY(), bounds.minZ(), bounds.maxX(), bounds.maxY(), bounds.maxZ())) { BlockPos pos = mutableBlockPos.setWithOffset(localPos, anchor); @@ -127,7 +115,7 @@ public class SchematicRenderer { poseStack.pushPose(); poseStack.translate(localPos.getX(), localPos.getY(), localPos.getZ()); - renderer.tesselateBlock(renderWorld, model, state, pos, poseStack, shadeSeparatingWrapper, true, + renderer.tesselateBlock(renderWorld, model, state, pos, poseStack, sbbBuilder, true, random, seed, OverlayTexture.NO_OVERLAY, modelData, layer); poseStack.popPose(); @@ -135,15 +123,9 @@ public class SchematicRenderer { } } ModelBlockRenderer.clearCache(); - - shadeSeparatingWrapper.clear(); - ShadeSeparatedBufferedData bufferedData = ModelUtil.endAndCombine(shadedBuilder, unshadedBuilder); - renderWorld.renderMode = false; - SuperByteBuffer sbb = new SuperByteBuffer(bufferedData); - bufferedData.release(); - return sbb; + return sbbBuilder.end(); } private static int getLayerCount() { @@ -155,9 +137,7 @@ public class SchematicRenderer { public final PoseStack poseStack = new PoseStack(); public final RandomSource random = RandomSource.createNewThreadLocalInstance(); public final BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - public final ShadeSeparatingVertexConsumer shadeSeparatingWrapper = new ShadeSeparatingVertexConsumer(); - public final BufferBuilder shadedBuilder = new BufferBuilder(512); - public final BufferBuilder unshadedBuilder = new BufferBuilder(512); + public final ShadedBlockSbbBuilder sbbBuilder = new ShadedBlockSbbBuilder(); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java index 7245dcb791..f4e7399108 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicTransformation.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.schematics.client; import static java.lang.Math.abs; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction.Axis; import net.minecraft.world.level.block.Mirror; @@ -22,7 +22,7 @@ public class SchematicTransformation { private Vec3 chasingPos; private Vec3 prevChasingPos; private BlockPos target; - + private LerpedFloat scaleFrontBack, scaleLeftRight; private LerpedFloat rotation; private double xOrigin; @@ -61,7 +61,7 @@ public class SchematicTransformation { float pt = AnimationTickHolder.getPartialTicks(); // Translation - TransformStack.cast(ms) + TransformStack.of(ms) .translate(VecHelper.lerp(pt, prevChasingPos, chasingPos) .subtract(camera)); Vec3 rotationOffset = getRotationOffset(true); @@ -71,9 +71,9 @@ public class SchematicTransformation { float lr = getScaleLR().getValue(pt); float rot = rotation.getValue(pt) + ((fb < 0 && lr < 0) ? 180 : 0); ms.translate(xOrigin, 0, zOrigin); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(rotationOffset) - .rotateY(rot) + .rotateYDegrees(rot) .translateBack(rotationOffset); ms.scale(abs(fb), 1, abs(lr)); ms.translate(-xOrigin, 0, -zOrigin); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java index e27d4f34c8..25797736fe 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.schematics.client.tools; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllKeys; import com.simibubi.create.content.schematics.client.SchematicTransformation; @@ -8,6 +7,7 @@ import com.simibubi.create.foundation.outliner.AABBOutline; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.nbt.NbtUtils; import net.minecraft.util.Mth; @@ -59,10 +59,10 @@ public class DeployTool extends PlacementToolBase { Vec3 origin = new Vec3(xOrigin, 0, zOrigin); ms.translate(x - centerX - camera.x, y - camera.y, z - centerZ - camera.z); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(origin) .translate(rotationOffset) - .rotateY(transformation.getCurrentRotation()) + .rotateYDegrees(transformation.getCurrentRotation()) .translateBack(rotationOffset) .translateBack(origin); diff --git a/src/main/java/com/simibubi/create/content/trains/bogey/BackupBogeyRenderer.java b/src/main/java/com/simibubi/create/content/trains/bogey/BackupBogeyRenderer.java index fd991fb043..ff93126a98 100644 --- a/src/main/java/com/simibubi/create/content/trains/bogey/BackupBogeyRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/bogey/BackupBogeyRenderer.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.trains.bogey; -import com.jozufozu.flywheel.api.MaterialManager; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.trains.entity.CarriageBogey; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; import net.minecraft.nbt.CompoundTag; public class BackupBogeyRenderer extends BogeyRenderer.CommonRenderer { @@ -16,7 +16,7 @@ public class BackupBogeyRenderer extends BogeyRenderer.CommonRenderer { } @Override - public void initialiseContraptionModelData(MaterialManager materialManager, CarriageBogey carriageBogey) { + public void initialiseContraptionModelData(VisualizationContext context, CarriageBogey carriageBogey) { } } diff --git a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java index 3bb782c6fa..8c01ad8e5e 100644 --- a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java @@ -7,21 +7,23 @@ import java.util.Map; import java.util.stream.IntStream; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix3f; -import org.joml.Matrix4f; -import org.joml.Quaternionf; +import org.joml.Matrix3fc; +import org.joml.Matrix4fc; +import org.joml.Quaternionfc; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.util.transform.Transform; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.trains.entity.CarriageBogey; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.VirtualRenderHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.Transform; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; @@ -178,24 +180,24 @@ public abstract class BogeyRenderer { /** * Provides render implementations a point in setup to instantiate all model data to be needed * - * @param materialManager The material manager + * @param context The visualization context * @param carriageBogey The bogey to create data for */ @OnlyIn(Dist.CLIENT) - public abstract void initialiseContraptionModelData(MaterialManager materialManager, CarriageBogey carriageBogey); + public abstract void initialiseContraptionModelData(VisualizationContext context, CarriageBogey carriageBogey); /** * Creates instances of models for in-world rendering to a set length from a provided partial model * - * @param materialManager The material manager + * @param context The visualization context * @param model Partial model to be instanced * @param count Amount of models neeeded */ - public void createModelInstance(MaterialManager materialManager, PartialModel model, int count) { + public void createModelInstance(VisualizationContext context, PartialModel model, int count) { + var instancer = context.instancerProvider() + .instancer(InstanceTypes.TRANSFORMED, Models.partial(model)); BogeyModelData[] modelData = IntStream.range(0, count) - .mapToObj(i -> materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(model).createInstance()) + .mapToObj(i -> instancer.createInstance()) .map(BogeyModelData::new) .toArray(BogeyModelData[]::new); contraptionModelData.put(keyFromModel(model), modelData); @@ -204,15 +206,15 @@ public abstract class BogeyRenderer { /** * Creates instances of models for in-contraption rendering to a set length from a provided blockstate * - * @param materialManager The material manager + * @param context The visualization context * @param state Blockstate of the model to be created * @param count Amount of models needed */ - public void createModelInstance(MaterialManager materialManager, BlockState state, int count) { + public void createModelInstance(VisualizationContext context, BlockState state, int count) { + var instancer = context.instancerProvider() + .instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(state)); BogeyModelData[] modelData = IntStream.range(0, count) - .mapToObj(i -> materialManager.defaultSolid() - .material(Materials.TRANSFORMED) - .getModel(state).createInstance()) + .mapToObj(i -> instancer.createInstance()) .map(BogeyModelData::new) .toArray(BogeyModelData[]::new); contraptionModelData.put(keyFromModel(state), modelData); @@ -221,23 +223,23 @@ public abstract class BogeyRenderer { /** * Creates a single instance of models for in-contraption rendering from a provided blockstate * - * @param materialManager The material manager + * @param context The visualization context * @param states Blockstates of the models to be created */ - public void createModelInstance(MaterialManager materialManager, BlockState... states) { + public void createModelInstance(VisualizationContext context, BlockState... states) { for (BlockState state : states) - this.createModelInstance(materialManager, state, 1); + this.createModelInstance(context, state, 1); } /** * Helper function to create a single model instance for in-contraption rendering * - * @param materialManager The material manager + * @param context The visualization context * @param models The type of model to create instances of */ - public void createModelInstance(MaterialManager materialManager, PartialModel... models) { + public void createModelInstance(VisualizationContext context, PartialModel... models) { for (PartialModel model : models) - createModelInstance(materialManager, model, 1); + createModelInstance(context, model, 1); } /** @@ -302,7 +304,7 @@ public abstract class BogeyRenderer { */ private String keyFromModel(PartialModel partialModel) { - return partialModel.getLocation().toString(); + return partialModel.modelLocation().toString(); } /** @@ -338,44 +340,47 @@ public abstract class BogeyRenderer { } public BogeyModelData setTransform(PoseStack ms) { - if (this.transform instanceof ModelData model) - model.setTransform(ms); + if (this.transform instanceof TransformedInstance model) + model.setTransform(ms) + .setChanged(); return this; } public BogeyModelData setEmptyTransform() { - if (this.transform instanceof ModelData model) - model.setEmptyTransform(); + if (this.transform instanceof TransformedInstance model) + model.setZeroTransform() + .setChanged(); return this; } public BogeyModelData delete() { - if (this.transform instanceof ModelData model) + if (this.transform instanceof TransformedInstance model) model.delete(); return this; } public BogeyModelData updateLight(int blockLight, int skyLight) { - if (this.transform instanceof ModelData model) - model.setBlockLight(blockLight).setSkyLight(skyLight); + if (this.transform instanceof TransformedInstance model) + model.light(blockLight, skyLight) + .setChanged(); return this; } @Override - public BogeyModelData mulPose(Matrix4f pose) { + public BogeyModelData mulPose(Matrix4fc pose) { this.transform.mulPose(pose); return this; } @Override - public BogeyModelData mulNormal(Matrix3f normal) { + public BogeyModelData mulNormal(Matrix3fc normal) { this.transform.mulNormal(normal); return this; } @Override - public BogeyModelData multiply(Quaternionf quaternion) { - this.transform.multiply(quaternion); + public BogeyModelData rotate(Quaternionfc quaternion) { + this.transform.rotate(quaternion); return this; } @@ -386,7 +391,7 @@ public abstract class BogeyRenderer { } @Override - public BogeyModelData translate(double x, double y, double z) { + public BogeyModelData translate(float x, float y, float z) { this.transform.translate(x, y, z); return this; } diff --git a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyStyle.java b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyStyle.java index c1b63f7851..1d7e355dcd 100644 --- a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyStyle.java +++ b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyStyle.java @@ -9,12 +9,12 @@ import java.util.stream.Stream; import org.jetbrains.annotations.NotNull; -import com.jozufozu.flywheel.api.MaterialManager; import com.simibubi.create.AllBogeyStyles; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.trains.bogey.BogeyRenderer.CommonRenderer; import com.simibubi.create.content.trains.entity.CarriageBogey; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -28,7 +28,7 @@ import net.minecraftforge.registries.ForgeRegistries; public class BogeyStyle { - + public final ResourceLocation name; public final ResourceLocation cycleGroup; public final Component displayName; @@ -36,13 +36,13 @@ public class BogeyStyle { public final ParticleOptions contactParticle; public final ParticleOptions smokeParticle; public final CompoundTag defaultData; - + private Optional> commonRendererFactory; private Map sizes; - + @OnlyIn(Dist.CLIENT) private Map sizeRenderers; - + @OnlyIn(Dist.CLIENT) private Optional commonRenderer; @@ -51,7 +51,7 @@ public class BogeyStyle { CompoundTag defaultData, Map sizes, Map> sizeRenderers, Optional> commonRenderer) { - + this.name = name; this.cycleGroup = cycleGroup; this.displayName = displayName; @@ -64,7 +64,7 @@ public class BogeyStyle { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { this.sizeRenderers = new HashMap<>(); sizeRenderers.forEach((k, v) -> this.sizeRenderers.put(k, v.get())); - + this.commonRendererFactory = commonRenderer; this.commonRenderer = commonRenderer.map(Supplier::get); }); @@ -116,8 +116,8 @@ public class BogeyStyle { return this.commonRendererFactory.map(Supplier::get); } - public BogeyInstance createInstance(CarriageBogey bogey, BogeySizes.BogeySize size, MaterialManager materialManager) { - return new BogeyInstance(bogey, this, size, materialManager); + public BogeyVisual createVisual(CarriageBogey bogey, BogeySizes.BogeySize size, VisualizationContext context) { + return new BogeyVisual(bogey, this, size, context); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyInstance.java b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyVisual.java similarity index 78% rename from src/main/java/com/simibubi/create/content/trains/bogey/BogeyInstance.java rename to src/main/java/com/simibubi/create/content/trains/bogey/BogeyVisual.java index cf5d911fbb..9849caada2 100644 --- a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyInstance.java +++ b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyVisual.java @@ -2,18 +2,18 @@ package com.simibubi.create.content.trains.bogey; import java.util.Optional; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.util.AnimationTickHolder; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.trains.entity.CarriageBogey; import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.LightLayer; import net.minecraft.world.phys.Vec3; -public final class BogeyInstance { +public final class BogeyVisual { private final BogeySizes.BogeySize size; private final BogeyStyle style; @@ -21,8 +21,8 @@ public final class BogeyInstance { public final BogeyRenderer renderer; public final Optional commonRenderer; - public BogeyInstance(CarriageBogey bogey, BogeyStyle style, BogeySizes.BogeySize size, - MaterialManager materialManager) { + public BogeyVisual(CarriageBogey bogey, BogeyStyle style, BogeySizes.BogeySize size, + VisualizationContext context) { this.bogey = bogey; this.size = size; this.style = style; @@ -30,8 +30,8 @@ public final class BogeyInstance { this.renderer = this.style.createRendererInstance(this.size); this.commonRenderer = this.style.getNewCommonRenderInstance(); - commonRenderer.ifPresent(bogeyRenderer -> bogeyRenderer.initialiseContraptionModelData(materialManager, bogey)); - renderer.initialiseContraptionModelData(materialManager, bogey); + commonRenderer.ifPresent(bogeyRenderer -> bogeyRenderer.initialiseContraptionModelData(context, bogey)); + renderer.initialiseContraptionModelData(context, bogey); } public void beginFrame(float wheelAngle, PoseStack ms) { @@ -59,7 +59,7 @@ public final class BogeyInstance { } @FunctionalInterface - interface BogeyInstanceFactory { - BogeyInstance create(CarriageBogey bogey, BogeySizes.BogeySize size, MaterialManager materialManager); + interface BogeyVisualFactory { + BogeyVisual create(CarriageBogey bogey, BogeySizes.BogeySize size, VisualizationContext context); } } diff --git a/src/main/java/com/simibubi/create/content/trains/bogey/StandardBogeyRenderer.java b/src/main/java/com/simibubi/create/content/trains/bogey/StandardBogeyRenderer.java index 8b2cc6f7ee..d7e3e835d5 100644 --- a/src/main/java/com/simibubi/create/content/trains/bogey/StandardBogeyRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/bogey/StandardBogeyRenderer.java @@ -7,7 +7,6 @@ import static com.simibubi.create.AllPartialModels.BOGEY_PISTON; import static com.simibubi.create.AllPartialModels.LARGE_BOGEY_WHEELS; import static com.simibubi.create.AllPartialModels.SMALL_BOGEY_WHEELS; -import com.jozufozu.flywheel.api.MaterialManager; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; @@ -16,14 +15,15 @@ import com.simibubi.create.content.trains.entity.CarriageBogey; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; public class StandardBogeyRenderer { public static class CommonStandardBogeyRenderer extends BogeyRenderer.CommonRenderer { @Override - public void initialiseContraptionModelData(MaterialManager materialManager, CarriageBogey carriageBogey) { - createModelInstance(materialManager, AllBlocks.SHAFT.getDefaultState() + public void initialiseContraptionModelData(VisualizationContext context, CarriageBogey carriageBogey) { + createModelInstance(context, AllBlocks.SHAFT.getDefaultState() .setValue(ShaftBlock.AXIS, Direction.Axis.Z), 2); } @@ -34,9 +34,9 @@ public class StandardBogeyRenderer { .setValue(ShaftBlock.AXIS, Direction.Axis.Z), ms, inInstancedContraption, 2); for (int i : Iterate.zeroAndOne) { shafts[i].translate(-.5f, .25f, i * -1) - .centre() - .rotateZ(wheelAngle) - .unCentre() + .center() + .rotateZDegrees(wheelAngle) + .uncenter() .render(ms, light, vb); } } @@ -45,9 +45,9 @@ public class StandardBogeyRenderer { public static class SmallStandardBogeyRenderer extends BogeyRenderer { @Override - public void initialiseContraptionModelData(MaterialManager materialManager, CarriageBogey carriageBogey) { - createModelInstance(materialManager, SMALL_BOGEY_WHEELS, 2); - createModelInstance(materialManager, BOGEY_FRAME); + public void initialiseContraptionModelData(VisualizationContext context, CarriageBogey carriageBogey) { + createModelInstance(context, SMALL_BOGEY_WHEELS, 2); + createModelInstance(context, BOGEY_FRAME); } @@ -68,7 +68,7 @@ public class StandardBogeyRenderer { ms.pushPose(); wheels[(side + 1)/2] .translate(0, 12 / 16f, side) - .rotateX(wheelAngle) + .rotateXDegrees(wheelAngle) .render(ms, light, vb); if (!inInstancedContraption) ms.popPose(); @@ -78,9 +78,9 @@ public class StandardBogeyRenderer { public static class LargeStandardBogeyRenderer extends BogeyRenderer { @Override - public void initialiseContraptionModelData(MaterialManager materialManager, CarriageBogey carriageBogey) { - createModelInstance(materialManager, LARGE_BOGEY_WHEELS, BOGEY_DRIVE, BOGEY_PISTON, BOGEY_PIN); - createModelInstance(materialManager, AllBlocks.SHAFT.getDefaultState() + public void initialiseContraptionModelData(VisualizationContext context, CarriageBogey carriageBogey) { + createModelInstance(context, LARGE_BOGEY_WHEELS, BOGEY_DRIVE, BOGEY_PISTON, BOGEY_PIN); + createModelInstance(context, AllBlocks.SHAFT.getDefaultState() .setValue(ShaftBlock.AXIS, Direction.Axis.X), 2); } @@ -99,9 +99,9 @@ public class StandardBogeyRenderer { for (int i : Iterate.zeroAndOne) { secondaryShafts[i] .translate(-.5f, .25f, .5f + i * -2) - .centre() - .rotateX(wheelAngle) - .unCentre() + .center() + .rotateXDegrees(wheelAngle) + .uncenter() .render(ms, light, vb); } @@ -117,14 +117,14 @@ public class StandardBogeyRenderer { getTransform(LARGE_BOGEY_WHEELS, ms, inInstancedContraption) .translate(0, 1, 0) - .rotateX(wheelAngle) + .rotateXDegrees(wheelAngle) .render(ms, light, vb); getTransform(BOGEY_PIN, ms, inInstancedContraption) .translate(0, 1, 0) - .rotateX(wheelAngle) + .rotateXDegrees(wheelAngle) .translate(0, 1 / 4f, 0) - .rotateX(-wheelAngle) + .rotateXDegrees(-wheelAngle) .render(ms, light, vb); if (!inInstancedContraption) diff --git a/src/main/java/com/simibubi/create/content/trains/display/FlapDisplayRenderer.java b/src/main/java/com/simibubi/create/content/trains/display/FlapDisplayRenderer.java index bab9d8b9e1..d79d46fdf7 100644 --- a/src/main/java/com/simibubi/create/content/trains/display/FlapDisplayRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/display/FlapDisplayRenderer.java @@ -4,7 +4,6 @@ import java.util.List; import org.joml.Matrix4f; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.font.GlyphInfo; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack.Pose; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.font.FontSet; @@ -56,11 +56,11 @@ public class FlapDisplayRenderer extends KineticBlockEntityRenderer lines = be.getLines(); ms.pushPose(); - TransformStack.cast(ms) - .centre() - .rotateY(AngleHelper.horizontalAngle(be.getBlockState() + TransformStack.of(ms) + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(be.getBlockState() .getValue(FlapDisplayBlock.HORIZONTAL_FACING))) - .unCentre() + .uncenter() .translate(0, 0, -3 / 16f); ms.translate(0, 1, 1); diff --git a/src/main/java/com/simibubi/create/content/trains/entity/CarriageBogey.java b/src/main/java/com/simibubi/create/content/trains/entity/CarriageBogey.java index fd2a16511c..0f776c3db5 100644 --- a/src/main/java/com/simibubi/create/content/trains/entity/CarriageBogey.java +++ b/src/main/java/com/simibubi/create/content/trains/entity/CarriageBogey.java @@ -5,13 +5,12 @@ import static com.simibubi.create.content.trains.bogey.AbstractBogeyBlockEntity. import javax.annotation.Nullable; -import com.jozufozu.flywheel.api.MaterialManager; import com.simibubi.create.AllBogeyStyles; import com.simibubi.create.Create; import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock; import com.simibubi.create.content.trains.bogey.AbstractBogeyBlockEntity; -import com.simibubi.create.content.trains.bogey.BogeyInstance; import com.simibubi.create.content.trains.bogey.BogeyStyle; +import com.simibubi.create.content.trains.bogey.BogeyVisual; import com.simibubi.create.content.trains.graph.DimensionPalette; import com.simibubi.create.content.trains.graph.TrackGraph; import com.simibubi.create.foundation.utility.AngleHelper; @@ -22,6 +21,7 @@ import com.simibubi.create.foundation.utility.RegisteredObjects; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; import net.minecraft.core.Direction.Axis; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; @@ -199,8 +199,8 @@ public class CarriageBogey { return new CarriageBogey(type, upsideDown, data, points.getFirst(), points.getSecond()); } - public BogeyInstance createInstance(MaterialManager materialManager) { - return this.getStyle().createInstance(this, type.getSize(), materialManager); + public BogeyVisual createVisual(VisualizationContext context) { + return this.getStyle().createVisual(this, type.getSize(), context); } public BogeyStyle getStyle() { diff --git a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraption.java b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraption.java index 8b7cc24962..5a6f1b47b4 100644 --- a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraption.java +++ b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraption.java @@ -5,7 +5,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import org.apache.commons.lang3.tuple.Pair; @@ -18,8 +17,6 @@ import com.simibubi.create.content.contraptions.ContraptionType; import com.simibubi.create.content.contraptions.MountedStorageManager; import com.simibubi.create.content.contraptions.actors.trainControls.ControlsBlock; import com.simibubi.create.content.contraptions.minecart.TrainCargoManager; -import com.simibubi.create.content.contraptions.render.ContraptionLighter; -import com.simibubi.create.content.contraptions.render.NonStationaryLighter; import com.simibubi.create.content.processing.burner.BlazeBurnerBlock; import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock; @@ -42,8 +39,6 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraft.world.phys.AABB; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.templates.FluidTank; @@ -243,13 +238,7 @@ public class CarriageContraption extends Contraption { return ContraptionType.CARRIAGE; } - @Override - @OnlyIn(Dist.CLIENT) - public ContraptionLighter makeLighter() { - return new NonStationaryLighter<>(this); - } - - public Direction getAssemblyDirection() { + public Direction getAssemblyDirection() { return assemblyDirection; } @@ -265,34 +254,34 @@ public class CarriageContraption extends Contraption { return secondBogeyPos; } - private Collection specialRenderedBEsOutsidePortal = new ArrayList<>(); + private Collection renderedBEsOutsidePortal = new ArrayList<>(); @Override - public Collection getRenderedBlocks() { + public RenderedBlocks getRenderedBlocks() { if (notInPortal()) return super.getRenderedBlocks(); - specialRenderedBEsOutsidePortal = new ArrayList<>(); - specialRenderedBlockEntities.stream() + renderedBEsOutsidePortal = new ArrayList<>(); + renderedBlockEntities.stream() .filter(be -> !isHiddenInPortal(be.getBlockPos())) - .forEach(specialRenderedBEsOutsidePortal::add); + .forEach(renderedBEsOutsidePortal::add); - Collection values = new ArrayList<>(); - for (Entry entry : blocks.entrySet()) { - BlockPos pos = entry.getKey(); - if (withinVisible(pos)) - values.add(entry.getValue()); - else if (atSeam(pos)) - values.add(new StructureBlockInfo(pos, Blocks.PURPLE_STAINED_GLASS.defaultBlockState(), null)); - } - return values; + Map values = new HashMap<>(); + blocks.forEach((pos, info) -> { + if (withinVisible(pos)) { + values.put(pos, info.state()); + } else if (atSeam(pos)) { + values.put(pos, Blocks.PURPLE_STAINED_GLASS.defaultBlockState()); + } + }); + return new RenderedBlocks(pos -> values.getOrDefault(pos, Blocks.AIR.defaultBlockState()), values.keySet()); } @Override - public Collection getSpecialRenderedBEs() { + public Collection getRenderedBEs() { if (notInPortal()) - return super.getSpecialRenderedBEs(); - return specialRenderedBEsOutsidePortal; + return super.getRenderedBEs(); + return renderedBEsOutsidePortal; } @Override diff --git a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntity.java b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntity.java index 16bff058d6..abfd3a669c 100644 --- a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntity.java @@ -737,10 +737,10 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { } @OnlyIn(Dist.CLIENT) - private WeakReference instanceHolder; + private WeakReference instanceHolder; @OnlyIn(Dist.CLIENT) - public void bindInstance(CarriageContraptionInstance instance) { + public void bindInstance(CarriageContraptionVisual instance) { this.instanceHolder = new WeakReference<>(instance); updateRenderedPortalCutoff(); } @@ -780,7 +780,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { // update hidden bogeys (if instanced) if (instanceHolder == null) return; - CarriageContraptionInstance instance = instanceHolder.get(); + CarriageContraptionVisual instance = instanceHolder.get(); if (instance == null) return; diff --git a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntityRenderer.java b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntityRenderer.java index bd53bcc81e..7d2d99e7ab 100644 --- a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionEntityRenderer.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.trains.entity; import java.util.Objects; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.render.ContraptionEntityRenderer; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.culling.Frustum; @@ -58,7 +58,7 @@ public class CarriageContraptionEntityRenderer extends ContraptionEntityRenderer : BlockPos.ZERO.relative(entity.getInitialOrientation() .getCounterClockWise(), bogeySpacing); - if (!Backend.canUseInstancing(entity.level()) && !entity.getContraption() + if (!VisualizationManager.supportsVisualization(entity.level()) && !entity.getContraption() .isHiddenInPortal(bogeyPos)) { ms.pushPose(); @@ -83,18 +83,18 @@ public class CarriageContraptionEntityRenderer extends ContraptionEntityRenderer float viewXRot, float partialTicks) { boolean selfUpsideDown = bogey.isUpsideDown(); boolean leadingUpsideDown = bogey.carriage.leadingBogey().isUpsideDown(); - TransformStack.cast(ms) - .rotateY(viewYRot + 90) - .rotateX(-viewXRot) - .rotateY(180) + TransformStack.of(ms) + .rotateYDegrees(viewYRot + 90) + .rotateXDegrees(-viewXRot) + .rotateYDegrees(180) .translate(0, 0, bogey.isLeading ? 0 : -bogeySpacing) - .rotateY(-180) - .rotateX(viewXRot) - .rotateY(-viewYRot - 90) - .rotateY(bogey.yaw.getValue(partialTicks)) - .rotateX(bogey.pitch.getValue(partialTicks)) + .rotateYDegrees(-180) + .rotateXDegrees(viewXRot) + .rotateYDegrees(-viewYRot - 90) + .rotateYDegrees(bogey.yaw.getValue(partialTicks)) + .rotateXDegrees(bogey.pitch.getValue(partialTicks)) .translate(0, .5f, 0) - .rotateZ(selfUpsideDown ? 180 : 0) + .rotateZDegrees(selfUpsideDown ? 180 : 0) .translateY(selfUpsideDown != leadingUpsideDown ? 2 : 0); } diff --git a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionInstance.java b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionInstance.java deleted file mode 100644 index 748a667232..0000000000 --- a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionInstance.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.simibubi.create.content.trains.entity; - -import org.joml.Vector3f; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; -import com.jozufozu.flywheel.util.AnimationTickHolder; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.trains.bogey.BogeyInstance; -import com.simibubi.create.content.trains.bogey.BogeyRenderer; -import com.simibubi.create.foundation.utility.Couple; -import com.simibubi.create.foundation.utility.Iterate; - -public class CarriageContraptionInstance extends EntityInstance implements DynamicInstance { - - private final PoseStack ms = new PoseStack(); - - private Carriage carriage; - private Couple bogeys; - private Couple bogeyHidden; - - public CarriageContraptionInstance(MaterialManager materialManager, CarriageContraptionEntity entity) { - super(materialManager, entity); - bogeyHidden = Couple.create(() -> false); - entity.bindInstance(this); - } - - @Override - public void init() { - carriage = entity.getCarriage(); - - if (carriage == null) - return; - - bogeys = carriage.bogeys.mapNotNullWithParam((bogey, manager) -> - bogey.getStyle().createInstance(bogey, bogey.type.getSize(), manager), materialManager); - updateLight(); - } - - public void setBogeyVisibility(boolean first, boolean visible) { - bogeyHidden.set(first, !visible); - } - - @Override - public void beginFrame() { - if (bogeys == null) { - if (entity.isReadyForRender()) - init(); - return; - } - - float partialTicks = AnimationTickHolder.getPartialTicks(); - - float viewYRot = entity.getViewYRot(partialTicks); - float viewXRot = entity.getViewXRot(partialTicks); - int bogeySpacing = carriage.bogeySpacing; - - ms.pushPose(); - - Vector3f instancePosition = getInstancePosition(partialTicks); - TransformStack.cast(ms) - .translate(instancePosition); - - for (boolean current : Iterate.trueAndFalse) { - BogeyInstance instance = bogeys.get(current); - if (instance == null) - continue; - if (bogeyHidden.get(current)) { - instance.beginFrame(0, null); - continue; - } - - ms.pushPose(); - CarriageBogey bogey = instance.bogey; - - CarriageContraptionEntityRenderer.translateBogey(ms, bogey, bogeySpacing, viewYRot, viewXRot, partialTicks); - ms.translate(0, -1.5 - 1 / 128f, 0); - - instance.beginFrame(bogey.wheelAngle.getValue(partialTicks), ms); - ms.popPose(); - } - - ms.popPose(); - } - - @Override - public void updateLight() { - if (bogeys == null) - return; - - bogeys.forEach(instance -> { - if (instance != null) - instance.updateLight(world, entity); - }); - } - - @Override - public void remove() { - if (bogeys == null) - return; - - bogeys.forEach(instance -> { - if (instance != null) { - instance.commonRenderer.ifPresent(BogeyRenderer::remove); - instance.renderer.remove(); - } - }); - } - - @Override - public boolean decreaseFramerateWithDistance() { - return false; - } -} diff --git a/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionVisual.java b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionVisual.java new file mode 100644 index 0000000000..376a99969d --- /dev/null +++ b/src/main/java/com/simibubi/create/content/trains/entity/CarriageContraptionVisual.java @@ -0,0 +1,118 @@ +package com.simibubi.create.content.trains.entity; + +import org.joml.Vector3f; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.content.contraptions.render.ContraptionVisual; +import com.simibubi.create.content.trains.bogey.BogeyRenderer; +import com.simibubi.create.content.trains.bogey.BogeyVisual; +import com.simibubi.create.foundation.utility.Couple; +import com.simibubi.create.foundation.utility.Iterate; + +import dev.engine_room.flywheel.api.visual.DynamicVisual; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.transform.TransformStack; + +public class CarriageContraptionVisual extends ContraptionVisual { + + private final PoseStack ms = new PoseStack(); + + private Carriage carriage; + private Couple bogeys; + private Couple bogeyHidden; + + public CarriageContraptionVisual(VisualizationContext context, CarriageContraptionEntity entity, float partialTick) { + super(context, entity, partialTick); + bogeyHidden = Couple.create(() -> false); + entity.bindInstance(this); + } + + @Override + protected void init(float pt) { + carriage = entity.getCarriage(); + + if (carriage != null) { + bogeys = carriage.bogeys.mapNotNullWithParam((bogey, manager) -> bogey.getStyle() + .createVisual(bogey, bogey.type.getSize(), manager), visualizationContext); + } + + super.init(pt); + } + + public void setBogeyVisibility(boolean first, boolean visible) { + bogeyHidden.set(first, !visible); + } + + @Override + public void beginFrame(DynamicVisual.Context ctx) { + super.beginFrame(ctx); + if (bogeys == null) { + if (entity.isReadyForRender()) { + init(ctx.partialTick()); + updateLight(ctx.partialTick()); + } + return; + } + + float partialTick = ctx.partialTick(); + + float viewYRot = entity.getViewYRot(partialTick); + float viewXRot = entity.getViewXRot(partialTick); + int bogeySpacing = carriage.bogeySpacing; + + ms.pushPose(); + + Vector3f instancePosition = getVisualPosition(partialTick); + TransformStack.of(ms) + .translate(instancePosition); + + for (boolean current : Iterate.trueAndFalse) { + BogeyVisual instance = bogeys.get(current); + if (instance == null) + continue; + if (bogeyHidden.get(current)) { + instance.beginFrame(0, null); + continue; + } + + ms.pushPose(); + CarriageBogey bogey = instance.bogey; + + CarriageContraptionEntityRenderer.translateBogey(ms, bogey, bogeySpacing, viewYRot, viewXRot, partialTick); + ms.translate(0, -1.5 - 1 / 128f, 0); + + instance.beginFrame(bogey.wheelAngle.getValue(partialTick), ms); + ms.popPose(); + } + + ms.popPose(); + } + + @Override + public void updateLight(float partialTick) { + super.updateLight(partialTick); + + if (bogeys == null) + return; + + bogeys.forEach(instance -> { + if (instance != null) + instance.updateLight(level, entity); + }); + } + + @Override + public void _delete() { + super._delete(); + + if (bogeys == null) + return; + + bogeys.forEach(instance -> { + if (instance != null) { + instance.commonRenderer.ifPresent(BogeyRenderer::remove); + instance.renderer.remove(); + } + }); + } +} diff --git a/src/main/java/com/simibubi/create/content/trains/entity/CarriageCouplingRenderer.java b/src/main/java/com/simibubi/create/content/trains/entity/CarriageCouplingRenderer.java index cecfe96db6..e3273d8d4a 100644 --- a/src/main/java/com/simibubi/create/content/trains/entity/CarriageCouplingRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/entity/CarriageCouplingRenderer.java @@ -72,8 +72,8 @@ public class CarriageCouplingRenderer { ms.pushPose(); ms.translate(anchor.x - camera.x, anchor.y - camera.y, anchor.z - camera.z); CachedBufferer.partial(AllPartialModels.TRAIN_COUPLING_HEAD, air) - .rotateY(-yRot) - .rotateX(xRot) + .rotateYDegrees(-yRot) + .rotateXDegrees(xRot) .light(lightCoords) .renderInto(ms, vb); @@ -84,8 +84,8 @@ public class CarriageCouplingRenderer { double stretch = ((anchor2.distanceTo(anchor) - 2 * margin) * 4) / couplingSegments; for (int j = 0; j < couplingSegments; j++) { CachedBufferer.partial(AllPartialModels.TRAIN_COUPLING_CABLE, air) - .rotateY(-yRot + 180) - .rotateX(-xRot) + .rotateYDegrees(-yRot + 180) + .rotateXDegrees(-xRot) .translate(0, 0, margin + 2 / 16f) .scale(1, 1, (float) stretch) .translate(0, 0, j / 4f) @@ -102,8 +102,8 @@ public class CarriageCouplingRenderer { .subtract(camera); ms.translate(translation.x, translation.y, translation.z); CachedBufferer.partial(AllPartialModels.TRAIN_COUPLING_HEAD, air) - .rotateY(-yRot + 180) - .rotateX(-xRot) + .rotateYDegrees(-yRot + 180) + .rotateXDegrees(-xRot) .light(lightCoords2) .renderInto(ms, vb); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java b/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java index e0d7c475cc..ea9185978b 100644 --- a/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java +++ b/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java @@ -15,14 +15,13 @@ import java.util.UUID; import javax.annotation.Nullable; -import com.simibubi.create.content.trains.graph.DiscoveredPath; - import org.apache.commons.lang3.mutable.MutableDouble; import org.apache.commons.lang3.mutable.MutableObject; import com.simibubi.create.Create; import com.simibubi.create.content.trains.entity.TravellingPoint.ITrackSelector; import com.simibubi.create.content.trains.graph.DimensionPalette; +import com.simibubi.create.content.trains.graph.DiscoveredPath; import com.simibubi.create.content.trains.graph.EdgeData; import com.simibubi.create.content.trains.graph.EdgePointType; import com.simibubi.create.content.trains.graph.TrackEdge; @@ -888,9 +887,9 @@ public class Navigation { c -> currentPath.add(Couple .deserializeEach(c.getList("Nodes", Tag.TAG_COMPOUND), c2 -> TrackNodeLocation.read(c2, dimensions)) .map(graph::locateNode))); - + removeBrokenPathEntries(); - + waitingForSignal = tag.contains("BlockingSignal") ? Pair.of(tag.getUUID("BlockingSignal"), tag.getBoolean("BlockingSignalSide")) : null; @@ -905,7 +904,7 @@ public class Navigation { * Trains might load or save with null entries in their path, this method avoids * that anomaly from causing NPEs. The underlying issue has not been found. */ - + boolean nullEntriesPresent = false; for (Iterator> iterator = currentPath.iterator(); iterator.hasNext();) { diff --git a/src/main/java/com/simibubi/create/content/trains/graph/DiscoveredPath.java b/src/main/java/com/simibubi/create/content/trains/graph/DiscoveredPath.java index 398b261e1b..2e9be4fe3a 100644 --- a/src/main/java/com/simibubi/create/content/trains/graph/DiscoveredPath.java +++ b/src/main/java/com/simibubi/create/content/trains/graph/DiscoveredPath.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.trains.graph; +import java.util.List; + import com.simibubi.create.content.trains.station.GlobalStation; import com.simibubi.create.foundation.utility.Couple; -import java.util.List; - public class DiscoveredPath { public List> path; public GlobalStation destination; diff --git a/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverBlockEntity.java b/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverBlockEntity.java index 48e01b499a..8d1322d80f 100644 --- a/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverBlockEntity.java @@ -4,7 +4,6 @@ import java.util.List; import javax.annotation.Nullable; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.contraptions.ITransformableBlockEntity; import com.simibubi.create.content.contraptions.StructureTransform; @@ -17,6 +16,7 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -73,7 +73,7 @@ public class TrackObserverBlockEntity extends SmartBlockEntity implements ITrans public TrackObserver getObserver() { return edgePoint.getEdgePoint(); } - + public ItemStack getFilter() { return filtering.getFilter(); } @@ -98,8 +98,8 @@ public class TrackObserverBlockEntity extends SmartBlockEntity implements ITrans @Override public void rotate(BlockState state, PoseStack ms) { - TransformStack.cast(ms) - .rotateX(90); + TransformStack.of(ms) + .rotateXDegrees(90); } @Override diff --git a/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverRenderer.java b/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverRenderer.java index f553023964..52bd4c06a6 100644 --- a/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/observer/TrackObserverRenderer.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.trains.observer; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.trains.track.ITrackBlock; import com.simibubi.create.content.trains.track.TrackTargetingBehaviour; import com.simibubi.create.content.trains.track.TrackTargetingBehaviour.RenderedTrackOverlayType; import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRenderer; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context; import net.minecraft.core.BlockPos; @@ -36,7 +36,7 @@ public class TrackObserverRenderer extends SmartBlockEntityRenderer= size) { if (!schedule.cyclic) diff --git a/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleScreen.java b/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleScreen.java index 2ffa5c6af7..0db102a3d5 100644 --- a/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleScreen.java +++ b/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleScreen.java @@ -15,7 +15,6 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL30; import com.google.common.collect.ImmutableList; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; @@ -49,6 +48,7 @@ import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; @@ -560,8 +560,8 @@ public class ScheduleScreen extends AbstractSimiContainerScreen { matrixStack.popPose(); if (xOffset + 16 > cardWidth - 26) { - TransformStack.cast(matrixStack) - .rotateZ(-90); + TransformStack.of(matrixStack) + .rotateZDegrees(-90); int zLevel = 200; graphics.fillGradient(-cardHeight + 2, 18, -2 - cardHeader, 28, zLevel, 0x44000000, 0x00000000); graphics.fillGradient(-cardHeight + 2, cardWidth - 26, -2 - cardHeader, cardWidth - 16, zLevel, 0x00000000, diff --git a/src/main/java/com/simibubi/create/content/trains/schedule/hat/TrainHatArmorLayer.java b/src/main/java/com/simibubi/create/content/trains/schedule/hat/TrainHatArmorLayer.java index 5d24d49eaa..dd30e409a2 100644 --- a/src/main/java/com/simibubi/create/content/trains/schedule/hat/TrainHatArmorLayer.java +++ b/src/main/java/com/simibubi/create/content/trains/schedule/hat/TrainHatArmorLayer.java @@ -1,6 +1,8 @@ package com.simibubi.create.content.trains.schedule.hat; -import com.jozufozu.flywheel.util.transform.TransformStack; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.Contraption; @@ -10,13 +12,13 @@ import com.simibubi.create.foundation.mixin.accessor.AgeableListModelAccessor; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.utility.Couple; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.model.AgeableListModel; import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.HierarchicalModel; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.ModelPart.Cube; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.client.renderer.entity.EntityRenderer; @@ -33,9 +35,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import java.util.ArrayList; -import java.util.List; - public class TrainHatArmorLayer> extends RenderLayer { public TrainHatArmorLayer(RenderLayerParent renderer) { @@ -49,10 +48,9 @@ public class TrainHatArmorLayer return; M entityModel = getParentModel(); - RenderType renderType = Sheets.cutoutBlockSheet(); ms.pushPose(); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); TrainHatInfo info = TrainHatInfoReloadListener.getHatInfoFor(entity.getType()); List partsToHead = new ArrayList<>(); @@ -86,12 +84,12 @@ public class TrainHatArmorLayer ms.scale(1, -1, -1); ms.translate(0, -2.25F / 16.0F, 0); - msr.rotateX(-8.5F); + msr.rotateXDegrees(-8.5F); BlockState air = Blocks.AIR.defaultBlockState(); CachedBufferer.partial(AllPartialModels.TRAIN_HAT, air) - .forEntityRender() + .disableDiffuse() .light(light) - .renderInto(ms, buffer.getBuffer(renderType)); + .renderInto(ms, buffer.getBuffer(Sheets.cutoutBlockSheet())); } ms.popPose(); diff --git a/src/main/java/com/simibubi/create/content/trains/signal/SignalRenderer.java b/src/main/java/com/simibubi/create/content/trains/signal/SignalRenderer.java index 6d5bb09eba..45ec840e5b 100644 --- a/src/main/java/com/simibubi/create/content/trains/signal/SignalRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/signal/SignalRenderer.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.trains.signal; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.trains.signal.SignalBlockEntity.OverlayState; @@ -12,6 +11,7 @@ import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRender import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -53,7 +53,7 @@ public class SignalRenderer extends SafeBlockEntityRenderer { return; ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(targetPosition.subtract(pos)); RenderedTrackOverlayType type = overlayState == OverlayState.DUAL ? RenderedTrackOverlayType.DUAL_SIGNAL : RenderedTrackOverlayType.SIGNAL; diff --git a/src/main/java/com/simibubi/create/content/trains/station/AbstractStationScreen.java b/src/main/java/com/simibubi/create/content/trains/station/AbstractStationScreen.java index ff5d1ef153..d97417bd02 100644 --- a/src/main/java/com/simibubi/create/content/trains/station/AbstractStationScreen.java +++ b/src/main/java/com/simibubi/create/content/trains/station/AbstractStationScreen.java @@ -3,8 +3,6 @@ package com.simibubi.create.content.trains.station; import java.lang.ref.WeakReference; import java.util.List; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.CreateClient; import com.simibubi.create.compat.computercraft.ComputerScreen; @@ -18,6 +16,8 @@ import com.simibubi.create.foundation.gui.element.GuiGameElement; import com.simibubi.create.foundation.gui.widget.IconButton; import com.simibubi.create.foundation.utility.Components; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -99,12 +99,12 @@ public abstract class AbstractStationScreen extends AbstractSimiScreen { private void renderAdditional(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks, int guiLeft, int guiTop, AllGuiTextures background) { PoseStack ms = graphics.pose(); ms.pushPose(); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); msr.pushPose() .translate(guiLeft + background.width + 4, guiTop + background.height + 4, 100) .scale(40) - .rotateX(-22) - .rotateY(63); + .rotateXDegrees(-22) + .rotateYDegrees(63); GuiGameElement.of(blockEntity.getBlockState() .setValue(BlockStateProperties.WATERLOGGED, false)) .render(graphics); diff --git a/src/main/java/com/simibubi/create/content/trains/station/AssemblyScreen.java b/src/main/java/com/simibubi/create/content/trains/station/AssemblyScreen.java index 28cdceeefb..8fa4a0ef16 100644 --- a/src/main/java/com/simibubi/create/content/trains/station/AssemblyScreen.java +++ b/src/main/java/com/simibubi/create/content/trains/station/AssemblyScreen.java @@ -3,7 +3,6 @@ package com.simibubi.create.content.trains.station; import java.lang.ref.WeakReference; import java.util.List; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllPackets; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.AssemblyException; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.gui.widget.IconButton; import com.simibubi.create.foundation.gui.widget.ScrollInput; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Renderable; import net.minecraft.network.chat.MutableComponent; diff --git a/src/main/java/com/simibubi/create/content/trains/station/StationBlockEntity.java b/src/main/java/com/simibubi/create/content/trains/station/StationBlockEntity.java index 7c76d6050d..a620fc1511 100644 --- a/src/main/java/com/simibubi/create/content/trains/station/StationBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/trains/station/StationBlockEntity.java @@ -13,8 +13,6 @@ import java.util.function.Consumer; import javax.annotation.Nullable; -import com.simibubi.create.content.trains.graph.DiscoveredPath; - import org.jetbrains.annotations.NotNull; import com.simibubi.create.AllBlocks; @@ -38,6 +36,7 @@ import com.simibubi.create.content.trains.entity.CarriageContraption; import com.simibubi.create.content.trains.entity.Train; import com.simibubi.create.content.trains.entity.TrainPacket; import com.simibubi.create.content.trains.entity.TravellingPoint; +import com.simibubi.create.content.trains.graph.DiscoveredPath; import com.simibubi.create.content.trains.graph.EdgePointType; import com.simibubi.create.content.trains.graph.TrackEdge; import com.simibubi.create.content.trains.graph.TrackGraph; @@ -623,13 +622,13 @@ public class StationBlockEntity extends SmartBlockEntity implements ITransformab BlockPos bogeyOffset = BlockPos.containing(track.getUpNormal(level, trackPosition, trackState)); TrackNodeLocation location = null; - Vec3 centre = Vec3.atBottomCenterOf(trackPosition) + Vec3 center = Vec3.atBottomCenterOf(trackPosition) .add(0, track.getElevationAtCenter(level, trackPosition, trackState), 0); Collection ends = track.getConnected(level, trackPosition, trackState, true, null); Vec3 targetOffset = Vec3.atLowerCornerOf(assemblyDirection.getNormal()); for (DiscoveredLocation end : ends) if (Mth.equal(0, targetOffset.distanceToSqr(end.getLocation() - .subtract(centre) + .subtract(center) .normalize()))) location = end; if (location == null) diff --git a/src/main/java/com/simibubi/create/content/trains/station/StationRenderer.java b/src/main/java/com/simibubi/create/content/trains/station/StationRenderer.java index c76a0d4939..9f0f2e2331 100644 --- a/src/main/java/com/simibubi/create/content/trains/station/StationRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/station/StationRenderer.java @@ -1,8 +1,5 @@ package com.simibubi.create.content.trains.station; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.Transform; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllPartialModels; @@ -14,6 +11,9 @@ import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRender import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.Transform; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -49,13 +49,13 @@ public class StationRenderer extends SafeBlockEntityRenderer GlobalStation station = be.getStation(); boolean isAssembling = be.getBlockState() .getValue(StationBlock.ASSEMBLING); - + if (!isAssembling || (station == null || station.getPresentTrain() != null) && !be.isVirtual()) { renderFlag( be.flag.getValue(partialTicks) > 0.75f ? AllPartialModels.STATION_ON : AllPartialModels.STATION_OFF, be, partialTicks, ms, buffer, light, overlay); ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(targetPosition.subtract(pos)); TrackTargetingBehaviour.render(level, targetPosition, target.getTargetDirection(), target.getTargetBezier(), ms, buffer, light, overlay, RenderedTrackOverlayType.STATION, 1); @@ -70,7 +70,7 @@ public class StationRenderer extends SafeBlockEntityRenderer if (be.isVirtual() && be.bogeyLocations == null) be.refreshAssemblyInfo(); - + if (direction == null || be.assemblyLength == 0 || be.bogeyLocations == null) return; @@ -118,7 +118,7 @@ public class StationRenderer extends SafeBlockEntityRenderer SuperByteBuffer flagBB = CachedBufferer.partial(flag, be.getBlockState()); transformFlag(flagBB, be, partialTicks, be.flagYRot, be.flagFlipped); flagBB.translate(0.5f / 16, 0, 0) - .rotateY(be.flagFlipped ? 0 : 180) + .rotateYDegrees(be.flagFlipped ? 0 : 180) .translate(-0.5f / 16, 0, 0) .light(light) .renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped())); @@ -134,11 +134,11 @@ public class StationRenderer extends SafeBlockEntityRenderer } float nudge = 1 / 512f; - flag.centre() - .rotateY(yRot) + flag.center() + .rotateYDegrees(yRot) .translate(nudge, 9.5f / 16f, flipped ? 14f / 16f - nudge : 2f / 16f + nudge) - .unCentre() - .rotateX((flipped ? 1 : -1) * (progress * 90 + 270)); + .uncenter() + .rotateXDegrees((flipped ? 1 : -1) * (progress * 90 + 270)); } @Override diff --git a/src/main/java/com/simibubi/create/content/trains/station/StationScreen.java b/src/main/java/com/simibubi/create/content/trains/station/StationScreen.java index ffbdb584f6..d990ddd126 100644 --- a/src/main/java/com/simibubi/create/content/trains/station/StationScreen.java +++ b/src/main/java/com/simibubi/create/content/trains/station/StationScreen.java @@ -4,7 +4,6 @@ import java.lang.ref.WeakReference; import java.util.List; import java.util.function.Consumer; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; @@ -26,6 +25,7 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.EditBox; @@ -252,7 +252,7 @@ public class StationScreen extends AbstractStationScreen { AllGuiTextures.STATION_EDIT_NAME.render(graphics, nameBoxX(text, nameBox) + font.width(text) + 5, y + 1); graphics.renderItem(AllBlocks.TRAIN_DOOR.asStack(), x + 14, y + 103); - + Train train = displayedTrain.get(); if (train == null) { MutableComponent header = Lang.translateDirect("station.idle"); diff --git a/src/main/java/com/simibubi/create/content/trains/track/AllPortalTracks.java b/src/main/java/com/simibubi/create/content/trains/track/AllPortalTracks.java index f252f7757a..f74dece9af 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/AllPortalTracks.java +++ b/src/main/java/com/simibubi/create/content/trains/track/AllPortalTracks.java @@ -11,7 +11,6 @@ import com.simibubi.create.foundation.utility.Pair; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/content/trains/track/BezierConnection.java b/src/main/java/com/simibubi/create/content/trains/track/BezierConnection.java index 6f07441985..51f59191e3 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/BezierConnection.java +++ b/src/main/java/com/simibubi/create/content/trains/track/BezierConnection.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.trains.track; import java.util.Iterator; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack.Pose; import com.simibubi.create.AllBlocks; @@ -11,6 +10,7 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction.Axis; import net.minecraft.core.particles.BlockParticleOption; @@ -34,7 +34,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BezierConnection implements Iterable { - public Couple tePositions; + public Couple bePositions; public Couple starts; public Couple axes; public Couple normals; @@ -59,7 +59,7 @@ public class BezierConnection implements Iterable { public BezierConnection(Couple positions, Couple starts, Couple axes, Couple normals, boolean primary, boolean girder, TrackMaterial material) { - tePositions = positions; + bePositions = positions; this.starts = starts; this.axes = axes; this.normals = normals; @@ -70,7 +70,7 @@ public class BezierConnection implements Iterable { } public BezierConnection secondary() { - BezierConnection bezierConnection = new BezierConnection(tePositions.swap(), starts.swap(), axes.swap(), + BezierConnection bezierConnection = new BezierConnection(bePositions.swap(), starts.swap(), axes.swap(), normals.swap(), !primary, hasGirder, trackMaterial); if (smoothing != null) bezierConnection.smoothing = smoothing.swap(); @@ -96,7 +96,7 @@ public class BezierConnection implements Iterable { } private boolean equalsSansMaterialInner(BezierConnection other) { - return this == other || (other != null && coupleEquals(this.tePositions, other.tePositions) + return this == other || (other != null && coupleEquals(this.bePositions, other.bePositions) && coupleEquals(this.starts, other.starts) && coupleEquals(this.axes, other.axes) && coupleEquals(this.normals, other.normals) && this.hasGirder == other.hasGirder); } @@ -116,7 +116,7 @@ public class BezierConnection implements Iterable { } public CompoundTag write(BlockPos localTo) { - Couple tePositions = this.tePositions.map(b -> b.subtract(localTo)); + Couple tePositions = this.bePositions.map(b -> b.subtract(localTo)); Couple starts = this.starts.map(v -> v.subtract(Vec3.atLowerCornerOf(localTo))); CompoundTag compound = new CompoundTag(); @@ -143,7 +143,7 @@ public class BezierConnection implements Iterable { } public void write(FriendlyByteBuf buffer) { - tePositions.forEach(buffer::writeBlockPos); + bePositions.forEach(buffer::writeBlockPos); starts.forEach(v -> VecHelper.write(v, buffer)); axes.forEach(v -> VecHelper.write(v, buffer)); normals.forEach(v -> VecHelper.write(v, buffer)); @@ -156,7 +156,7 @@ public class BezierConnection implements Iterable { } public BlockPos getKey() { - return tePositions.getSecond(); + return bePositions.getSecond(); } public boolean isPrimary() { @@ -346,7 +346,7 @@ public class BezierConnection implements Iterable { @Override public Iterator iterator() { resolve(); - var offset = Vec3.atLowerCornerOf(tePositions.getFirst()) + var offset = Vec3.atLowerCornerOf(bePositions.getFirst()) .scale(-1) .add(0, 3 / 16f, 0); return new Bezierator(this, offset); @@ -378,7 +378,7 @@ public class BezierConnection implements Iterable { if (!level.getGameRules() .getBoolean(GameRules.RULE_DOBLOCKDROPS)) return; - Vec3 origin = Vec3.atLowerCornerOf(tePositions.getFirst()); + Vec3 origin = Vec3.atLowerCornerOf(bePositions.getFirst()); for (Segment segment : this) { if (segment.index % 2 != 0 || segment.index == getSegmentCount()) continue; @@ -403,7 +403,7 @@ public class BezierConnection implements Iterable { new BlockParticleOption(ParticleTypes.BLOCK, AllBlocks.METAL_GIRDER.getDefaultState()); if (!(level instanceof ServerLevel slevel)) return; - Vec3 origin = Vec3.atLowerCornerOf(tePositions.getFirst()); + Vec3 origin = Vec3.atLowerCornerOf(bePositions.getFirst()); for (Segment segment : this) { for (int offset : Iterate.positiveAndNegative) { Vec3 v = segment.position.add(segment.normal.scale(14 / 16f * offset)) @@ -542,11 +542,11 @@ public class BezierConnection implements Iterable { angles.railTransforms = Couple.create(null, null); PoseStack poseStack = new PoseStack(); - TransformStack.cast(poseStack) + TransformStack.of(poseStack) .translate(prevMiddle) - .rotateYRadians(tieAngles.y) - .rotateXRadians(tieAngles.x) - .rotateZRadians(tieAngles.z) + .rotateY((float) tieAngles.y) + .rotateX((float) tieAngles.x) + .rotateZ((float) tieAngles.z) .translate(-1 / 2f, -2 / 16f - 1 / 256f, 0); angles.tieTransform = poseStack.last(); @@ -559,11 +559,11 @@ public class BezierConnection implements Iterable { Vec3 anglesI = TrackRenderer.getModelAngles(segment.normal, diff); poseStack = new PoseStack(); - TransformStack.cast(poseStack) + TransformStack.of(poseStack) .translate(prevI) - .rotateYRadians(anglesI.y) - .rotateXRadians(anglesI.x) - .rotateZRadians(anglesI.z) + .rotateY((float) anglesI.y) + .rotateX((float) anglesI.x) + .rotateZ((float) anglesI.z) .translate(0, -2 / 16f - 1 / 256f, -1 / 32f) .scale(1, 1, (float) diff.length() * scale); angles.railTransforms.set(first, poseStack.last()); @@ -634,11 +634,11 @@ public class BezierConnection implements Iterable { Vec3 beamAngles = TrackRenderer.getModelAngles(segment.normal, beamDiff); PoseStack poseStack = new PoseStack(); - TransformStack.cast(poseStack) + TransformStack.of(poseStack) .translate(previousBeam) - .rotateYRadians(beamAngles.y) - .rotateXRadians(beamAngles.x) - .rotateZRadians(beamAngles.z) + .rotateY((float) beamAngles.y) + .rotateX((float) beamAngles.x) + .rotateZ((float) beamAngles.z) .translate(0, 2 / 16f + (segment.index % 2 == 0 ? 1 : -1) / 2048f - 1 / 1024f, -1 / 32f) .scale(1, 1, (float) beamDiff.length() * scale); angles.beams.set(first, poseStack.last()); @@ -653,11 +653,11 @@ public class BezierConnection implements Iterable { Vec3 capAngles = TrackRenderer.getModelAngles(segment.normal, diff); poseStack = new PoseStack(); - TransformStack.cast(poseStack) + TransformStack.of(poseStack) .translate(previous) - .rotateYRadians(capAngles.y) - .rotateXRadians(capAngles.x) - .rotateZRadians(capAngles.z) + .rotateY((float) capAngles.y) + .rotateX((float) capAngles.x) + .rotateZ((float) capAngles.z) .translate(0, 2 / 16f + (segment.index % 2 == 0 ? 1 : -1) / 2048f - 1 / 1024f, -1 / 32f) .rotateZ(top ? 0 : 0) .scale(1, 1, (float) diff.length() * scale); diff --git a/src/main/java/com/simibubi/create/content/trains/track/ITrackBlock.java b/src/main/java/com/simibubi/create/content/trains/track/ITrackBlock.java index c5c2d57a1a..8b4f698074 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/ITrackBlock.java +++ b/src/main/java/com/simibubi/create/content/trains/track/ITrackBlock.java @@ -8,7 +8,6 @@ import java.util.function.Function; import javax.annotation.Nullable; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.trains.graph.TrackNodeLocation; import com.simibubi.create.content.trains.graph.TrackNodeLocation.DiscoveredLocation; @@ -16,6 +15,7 @@ import com.simibubi.create.content.trains.track.TrackTargetingBehaviour.Rendered import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Pair; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.AxisDirection; diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackBlock.java b/src/main/java/com/simibubi/create/content/trains/track/TrackBlock.java index 046ea0d908..7fbdf20ad7 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackBlock.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackBlock.java @@ -24,8 +24,6 @@ import com.simibubi.create.foundation.block.IHaveBigOutline; import org.jetbrains.annotations.Nullable; import com.google.common.base.Predicates; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockEntityTypes; import com.simibubi.create.AllBlocks; @@ -54,6 +52,8 @@ import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.ChatFormatting; @@ -371,7 +371,7 @@ public class TrackBlock extends Block Map connections = trackBE.getConnections(); connections.forEach((connectedPos, bc) -> ITrackBlock.addToListIfConnected(connectedTo, list, - (d, b) -> d == 1 ? Vec3.atLowerCornerOf(bc.tePositions.get(b)) : bc.starts.get(b), bc.normals::get, + (d, b) -> d == 1 ? Vec3.atLowerCornerOf(bc.bePositions.get(b)) : bc.starts.get(b), bc.normals::get, b -> world instanceof Level l ? l.dimension() : Level.OVERWORLD, bc::yOffsetAt, null, bc, (b, v) -> ITrackBlock.getMaterialSimple(world, v, bc.getMaterial()))); @@ -654,8 +654,8 @@ public class TrackBlock extends Block @OnlyIn(Dist.CLIENT) public PartialModel prepareAssemblyOverlay(BlockGetter world, BlockPos pos, BlockState state, Direction direction, PoseStack ms) { - TransformStack.cast(ms) - .rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction))); + TransformStack.of(ms) + .rotateCentered(AngleHelper.rad(AngleHelper.horizontalAngle(direction)), Direction.UP); return AllPartialModels.TRACK_ASSEMBLING_OVERLAY; } @@ -663,7 +663,7 @@ public class TrackBlock extends Block @OnlyIn(Dist.CLIENT) public PartialModel prepareTrackOverlay(BlockGetter world, BlockPos pos, BlockState state, BezierTrackPointLocation bezierPoint, AxisDirection direction, PoseStack ms, RenderedTrackOverlayType type) { - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); Vec3 axis = null; Vec3 diff = null; @@ -702,17 +702,17 @@ public class TrackBlock extends Block Vec3 angles = TrackRenderer.getModelAngles(normal, diff); - msr.centre() - .rotateYRadians(angles.y) - .rotateXRadians(angles.x) - .unCentre(); + msr.center() + .rotateY((float) angles.y) + .rotateX((float) angles.x) + .uncenter(); if (axis != null) msr.translate(0, axis.y != 0 ? 7 / 16f : 0, axis.y != 0 ? direction.getStep() * 2.5f / 16f : 0); else { msr.translate(0, 4 / 16f, 0); if (direction == AxisDirection.NEGATIVE) - msr.rotateCentered(Direction.UP, Mth.PI); + msr.rotateCentered(Mth.PI, Direction.UP); } if (bezierPoint == null && world.getBlockEntity(pos) instanceof TrackBlockEntity trackTE @@ -720,9 +720,9 @@ public class TrackBlock extends Block double yOffset = 0; for (BezierConnection bc : trackTE.connections.values()) yOffset += bc.starts.getFirst().y - pos.getY(); - msr.centre() - .rotateX(-direction.getStep() * trackTE.tilt.smoothingAngle.get()) - .unCentre() + msr.center() + .rotateXDegrees((float) (-direction.getStep() * trackTE.tilt.smoothingAngle.get())) + .uncenter() .translate(0, yOffset / 2, 0); } diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackBlockEntity.java b/src/main/java/com/simibubi/create/content/trains/track/TrackBlockEntity.java index 6cec632cb0..43e8a7d09c 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackBlockEntity.java @@ -8,7 +8,6 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.Set; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; import com.simibubi.create.AllTags; @@ -23,6 +22,7 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction.Axis; import net.minecraft.core.registries.Registries; @@ -93,7 +93,7 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable BlockPos key = entry.getKey(); BezierConnection bc = entry.getValue(); - if (!key.equals(bc.getKey()) || !worldPosition.equals(bc.tePositions.getFirst())) { + if (!key.equals(bc.getKey()) || !worldPosition.equals(bc.bePositions.getFirst())) { invalid.add(key); continue; } @@ -159,7 +159,7 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable for (BezierConnection bezierConnection : connections.values()) { if (!(level.getBlockEntity(bezierConnection.getKey())instanceof TrackBlockEntity tbe)) return; - tbe.removeConnection(bezierConnection.tePositions.getFirst()); + tbe.removeConnection(bezierConnection.bePositions.getFirst()); if (!dropAndDiscard) continue; if (!cancelDrops) @@ -225,7 +225,7 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 16); } - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> VisualizationHelper.queueUpdate(this)); if (hasInteractableConnections()) registerToCurveInteraction(); @@ -282,10 +282,10 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable newConnection.normals.replace(transform::applyWithoutOffsetUncentered); newConnection.axes.replace(transform::applyWithoutOffsetUncentered); - BlockPos diff = newConnection.tePositions.getSecond() - .subtract(newConnection.tePositions.getFirst()); - newConnection.tePositions - .setSecond(BlockPos.containing(Vec3.atCenterOf(newConnection.tePositions.getFirst()) + BlockPos diff = newConnection.bePositions.getSecond() + .subtract(newConnection.bePositions.getFirst()); + newConnection.bePositions + .setSecond(BlockPos.containing(Vec3.atCenterOf(newConnection.bePositions.getFirst()) .add(transform.applyWithoutOffsetUncentered(Vec3.atLowerCornerOf(diff))))); Vec3 beVec = Vec3.atLowerCornerOf(worldPosition); @@ -364,7 +364,7 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable public void manageFakeTracksAlong(BezierConnection bc, boolean remove) { Map, Double> yLevels = new HashMap<>(); - BlockPos tePosition = bc.tePositions.getFirst(); + BlockPos tePosition = bc.bePositions.getFirst(); Vec3 end1 = bc.starts.getFirst() .subtract(Vec3.atLowerCornerOf(tePosition)) .add(0, 3 / 16f, 0); diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackBlockOutline.java b/src/main/java/com/simibubi/create/content/trains/track/TrackBlockOutline.java index 3962422574..6ce8343899 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackBlockOutline.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackBlockOutline.java @@ -5,7 +5,6 @@ import java.util.Map; import java.util.Optional; import java.util.function.Consumer; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllShapes; @@ -17,6 +16,7 @@ import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.WorldAttached; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.MultiBufferSource; @@ -154,11 +154,11 @@ public class TrackBlockOutline { Vec3 vec = result.vec() .subtract(camera); Vec3 angles = result.angles(); - TransformStack.cast(ms) + TransformStack.of(ms) .pushPose() .translate(vec.x, vec.y + .125f, vec.z) - .rotateYRadians(angles.y) - .rotateXRadians(angles.x) + .rotateY((float) angles.y) + .rotateX((float) angles.x) .translate(-.5, -.125f, -.5); boolean holdingTrack = AllTags.AllBlockTags.TRACKS.matches(Minecraft.getInstance().player.getMainHandItem()); @@ -194,7 +194,7 @@ public class TrackBlockOutline { boolean canConnectFrom = !shape.isJunction() && !(mc.level.getBlockEntity(pos)instanceof TrackBlockEntity tbe && tbe.isTilted()); - walkShapes(shape, TransformStack.cast(ms), s -> { + walkShapes(shape, TransformStack.of(ms), s -> { renderShape(s, ms, vb, holdingTrack ? canConnectFrom : null); event.setCanceled(true); }); @@ -259,24 +259,24 @@ public class TrackBlockOutline { for (Direction d : Iterate.horizontalDirections) { if (TrackShape.asPortal(d) != shape) continue; - msr.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(d))); + msr.rotateCentered(AngleHelper.rad(AngleHelper.horizontalAngle(d)), Direction.UP); renderer.accept(LONG_ORTHO_OFFSET); return; } } if (shape == TrackShape.PD || shape == TrackShape.CR_PDX || shape == TrackShape.CR_PDZ) { - msr.rotateCentered(Direction.UP, angle45); + msr.rotateCentered(angle45, Direction.UP); renderer.accept(LONG_ORTHO); } else if (shape == TrackShape.ND || shape == TrackShape.CR_NDX || shape == TrackShape.CR_NDZ) { - msr.rotateCentered(Direction.UP, -Mth.PI / 4); + msr.rotateCentered(-Mth.PI / 4, Direction.UP); renderer.accept(LONG_ORTHO); } if (shape == TrackShape.CR_O) renderer.accept(AllShapes.TRACK_CROSS); else if (shape == TrackShape.CR_D) { - msr.rotateCentered(Direction.UP, angle45); + msr.rotateCentered(angle45, Direction.UP); renderer.accept(LONG_CROSS); } @@ -284,8 +284,8 @@ public class TrackBlockOutline { return; msr.translate(0, 1, 0); - msr.rotateCentered(Direction.UP, Mth.PI - AngleHelper.rad(shape.getModelRotation())); - msr.rotateXRadians(angle45); + msr.rotateCentered(Mth.PI - AngleHelper.rad(shape.getModelRotation()), Direction.UP); + msr.rotateX(angle45); msr.translate(0, -3 / 16f, 1 / 16f); renderer.accept(LONG_ORTHO); } diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackInstance.java b/src/main/java/com/simibubi/create/content/trains/track/TrackInstance.java deleted file mode 100644 index fd785c560e..0000000000 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackInstance.java +++ /dev/null @@ -1,240 +0,0 @@ -package com.simibubi.create.content.trains.track; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import javax.annotation.Nullable; - -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; -import com.jozufozu.flywheel.core.Materials; -import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.light.LightUpdater; -import com.jozufozu.flywheel.util.box.GridAlignedBB; -import com.jozufozu.flywheel.util.box.ImmutableBox; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.PoseStack.Pose; -import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.trains.track.BezierConnection.GirderAngles; -import com.simibubi.create.content.trains.track.BezierConnection.SegmentAngles; -import com.simibubi.create.foundation.utility.Couple; -import com.simibubi.create.foundation.utility.Iterate; - -import net.minecraft.client.renderer.RenderType; -import net.minecraft.core.BlockPos; - -public class TrackInstance extends BlockEntityInstance { - - private List instances; - - public TrackInstance(MaterialManager materialManager, TrackBlockEntity track) { - super(materialManager, track); - - update(); - } - - @Override - public void update() { - if (blockEntity.connections.isEmpty()) - return; - - remove(); - instances = blockEntity.connections.values() - .stream() - .map(this::createInstance) - .filter(Objects::nonNull) - .toList(); - LightUpdater.get(world) - .addListener(this); - } - - @Override - public ImmutableBox getVolume() { - List out = new ArrayList<>(); - out.addAll(blockEntity.connections.keySet()); - out.addAll(blockEntity.connections.keySet()); - return GridAlignedBB.containingAll(out); - } - - @Override - public void updateLight() { - if (instances == null) - return; - instances.forEach(BezierTrackInstance::updateLight); - } - - @Nullable - private BezierTrackInstance createInstance(BezierConnection bc) { - if (!bc.isPrimary()) - return null; - return new BezierTrackInstance(bc); - } - - @Override - public void remove() { - if (instances == null) - return; - instances.forEach(BezierTrackInstance::delete); - } - - private class BezierTrackInstance { - - private final ModelData[] ties; - private final ModelData[] left; - private final ModelData[] right; - private final BlockPos[] tiesLightPos; - private final BlockPos[] leftLightPos; - private final BlockPos[] rightLightPos; - - private @Nullable GirderInstance girder; - - private BezierTrackInstance(BezierConnection bc) { - BlockPos tePosition = bc.tePositions.getFirst(); - girder = bc.hasGirder ? new GirderInstance(bc) : null; - - PoseStack pose = new PoseStack(); - TransformStack.cast(pose) - .translate(getInstancePosition()); - - var mat = materialManager.cutout(RenderType.cutoutMipped()) - .material(Materials.TRANSFORMED); - - int segCount = bc.getSegmentCount(); - ties = new ModelData[segCount]; - left = new ModelData[segCount]; - right = new ModelData[segCount]; - tiesLightPos = new BlockPos[segCount]; - leftLightPos = new BlockPos[segCount]; - rightLightPos = new BlockPos[segCount]; - - TrackMaterial.TrackModelHolder modelHolder = bc.getMaterial().getModelHolder(); - - mat.getModel(modelHolder.tie()) - .createInstances(ties); - mat.getModel(modelHolder.segment_left()) - .createInstances(left); - mat.getModel(modelHolder.segment_right()) - .createInstances(right); - - SegmentAngles[] segments = bc.getBakedSegments(); - for (int i = 1; i < segments.length; i++) { - SegmentAngles segment = segments[i]; - var modelIndex = i - 1; - - ties[modelIndex].setTransform(pose) - .mulPose(segment.tieTransform.pose()) - .mulNormal(segment.tieTransform.normal()); - tiesLightPos[modelIndex] = segment.lightPosition.offset(tePosition); - - for (boolean first : Iterate.trueAndFalse) { - Pose transform = segment.railTransforms.get(first); - (first ? this.left : this.right)[modelIndex].setTransform(pose) - .mulPose(transform.pose()) - .mulNormal(transform.normal()); - (first ? leftLightPos : rightLightPos)[modelIndex] = segment.lightPosition.offset(tePosition); - } - } - - updateLight(); - } - - void delete() { - for (ModelData d : ties) - d.delete(); - for (ModelData d : left) - d.delete(); - for (ModelData d : right) - d.delete(); - if (girder != null) - girder.delete(); - } - - void updateLight() { - for (int i = 0; i < ties.length; i++) - ties[i].updateLight(world, tiesLightPos[i]); - for (int i = 0; i < left.length; i++) - left[i].updateLight(world, leftLightPos[i]); - for (int i = 0; i < right.length; i++) - right[i].updateLight(world, rightLightPos[i]); - if (girder != null) - girder.updateLight(); - } - - private class GirderInstance { - - private final Couple beams; - private final Couple> beamCaps; - private final BlockPos[] lightPos; - - private GirderInstance(BezierConnection bc) { - BlockPos tePosition = bc.tePositions.getFirst(); - PoseStack pose = new PoseStack(); - TransformStack.cast(pose) - .translate(getInstancePosition()) - .nudge((int) bc.tePositions.getFirst() - .asLong()); - - var mat = materialManager.cutout(RenderType.cutoutMipped()) - .material(Materials.TRANSFORMED); - - int segCount = bc.getSegmentCount(); - beams = Couple.create(() -> new ModelData[segCount]); - beamCaps = Couple.create(() -> Couple.create(() -> new ModelData[segCount])); - lightPos = new BlockPos[segCount]; - beams.forEach(mat.getModel(AllPartialModels.GIRDER_SEGMENT_MIDDLE)::createInstances); - beamCaps.forEachWithContext((c, top) -> c.forEach(mat.getModel(top ? AllPartialModels.GIRDER_SEGMENT_TOP - : AllPartialModels.GIRDER_SEGMENT_BOTTOM)::createInstances)); - - GirderAngles[] bakedGirders = bc.getBakedGirders(); - for (int i = 1; i < bakedGirders.length; i++) { - GirderAngles segment = bakedGirders[i]; - var modelIndex = i - 1; - lightPos[modelIndex] = segment.lightPosition.offset(tePosition); - - for (boolean first : Iterate.trueAndFalse) { - Pose beamTransform = segment.beams.get(first); - beams.get(first)[modelIndex].setTransform(pose) - .mulPose(beamTransform.pose()) - .mulNormal(beamTransform.normal()); - for (boolean top : Iterate.trueAndFalse) { - Pose beamCapTransform = segment.beamCaps.get(top) - .get(first); - beamCaps.get(top) - .get(first)[modelIndex].setTransform(pose) - .mulPose(beamCapTransform.pose()) - .mulNormal(beamCapTransform.normal()); - } - } - } - - updateLight(); - } - - void delete() { - beams.forEach(arr -> { - for (ModelData d : arr) - d.delete(); - }); - beamCaps.forEach(c -> c.forEach(arr -> { - for (ModelData d : arr) - d.delete(); - })); - } - - void updateLight() { - beams.forEach(arr -> { - for (int i = 0; i < arr.length; i++) - arr[i].updateLight(world, lightPos[i]); - }); - beamCaps.forEach(c -> c.forEach(arr -> { - for (int i = 0; i < arr.length; i++) - arr[i].updateLight(world, lightPos[i]); - })); - } - - } - - } -} diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackMaterial.java b/src/main/java/com/simibubi/create/content/trains/track/TrackMaterial.java index 0c8a3a10cf..7ae7af4b19 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackMaterial.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackMaterial.java @@ -10,12 +10,12 @@ import java.util.function.Supplier; import org.jetbrains.annotations.Nullable; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.Create; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; @@ -163,7 +163,7 @@ public class TrackMaterial { } @OnlyIn(Dist.CLIENT) - public record TrackModelHolder(PartialModel tie, PartialModel segment_left, PartialModel segment_right) { + public record TrackModelHolder(PartialModel tie, PartialModel leftSegment, PartialModel rightSegment) { static final TrackModelHolder DEFAULT = new TrackModelHolder(AllPartialModels.TRACK_TIE, AllPartialModels.TRACK_SEGMENT_LEFT, AllPartialModels.TRACK_SEGMENT_RIGHT); } diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackMaterialFactory.java b/src/main/java/com/simibubi/create/content/trains/track/TrackMaterialFactory.java index 67e048caa8..d5d7054649 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackMaterialFactory.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackMaterialFactory.java @@ -5,10 +5,10 @@ import java.util.stream.Stream; import org.jetbrains.annotations.Nullable; -import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllTags; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; @@ -100,9 +100,9 @@ public class TrackMaterialFactory { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { String namespace = id.getNamespace(); String prefix = "block/track/" + id.getPath() + "/"; - tieModel = new PartialModel(new ResourceLocation(namespace, prefix + "tie")); - leftSegmentModel = new PartialModel(new ResourceLocation(namespace, prefix + "segment_left")); - rightSegmentModel = new PartialModel(new ResourceLocation(namespace, prefix + "segment_right")); + tieModel = PartialModel.of(new ResourceLocation(namespace, prefix + "tie")); + leftSegmentModel = PartialModel.of(new ResourceLocation(namespace, prefix + "segment_left")); + rightSegmentModel = PartialModel.of(new ResourceLocation(namespace, prefix + "segment_right")); }); return this; } diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackPaver.java b/src/main/java/com/simibubi/create/content/trains/track/TrackPaver.java index 3a2058e6e1..bb7ced1432 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackPaver.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackPaver.java @@ -99,7 +99,7 @@ public class TrackPaver { } Map, Double> yLevels = new HashMap<>(); - BlockPos tePosition = bc.tePositions.getFirst(); + BlockPos tePosition = bc.bePositions.getFirst(); Vec3 end1 = bc.starts.getFirst() .subtract(Vec3.atLowerCornerOf(tePosition)) .add(0, 3 / 16f, 0); diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackPlacement.java b/src/main/java/com/simibubi/create/content/trains/track/TrackPlacement.java index e521582e0d..e6cc6cf032 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackPlacement.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackPlacement.java @@ -6,7 +6,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import com.jozufozu.flywheel.util.Color; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.AllTags; import com.simibubi.create.CreateClient; @@ -14,6 +13,7 @@ import com.simibubi.create.content.equipment.blueprint.BlueprintOverlayRenderer; import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.BlockHelper; +import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackRenderer.java b/src/main/java/com/simibubi/create/content/trains/track/TrackRenderer.java index 65ef7ea1e7..3ca20016f7 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackRenderer.java @@ -4,7 +4,6 @@ import static com.simibubi.create.AllPartialModels.GIRDER_SEGMENT_BOTTOM; import static com.simibubi.create.AllPartialModels.GIRDER_SEGMENT_MIDDLE; import static com.simibubi.create.AllPartialModels.GIRDER_SEGMENT_TOP; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack.Pose; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -36,7 +36,7 @@ public class TrackRenderer extends SafeBlockEntityRenderer { protected void renderSafe(TrackBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { Level level = be.getLevel(); - if (Backend.canUseInstancing(level)) + if (VisualizationManager.supportsVisualization(level)) return; VertexConsumer vb = buffer.getBuffer(RenderType.cutoutMipped()); be.connections.values() @@ -48,15 +48,15 @@ public class TrackRenderer extends SafeBlockEntityRenderer { return; ms.pushPose(); - BlockPos tePosition = bc.tePositions.getFirst(); + BlockPos bePosition = bc.bePositions.getFirst(); BlockState air = Blocks.AIR.defaultBlockState(); SegmentAngles[] segments = bc.getBakedSegments(); - renderGirder(level, bc, ms, vb, tePosition); + renderGirder(level, bc, ms, vb, bePosition); for (int i = 1; i < segments.length; i++) { SegmentAngles segment = segments[i]; - int light = LevelRenderer.getLightColor(level, segment.lightPosition.offset(tePosition)); + int light = LevelRenderer.getLightColor(level, segment.lightPosition.offset(bePosition)); TrackMaterial.TrackModelHolder modelHolder = bc.getMaterial().getModelHolder(); @@ -68,7 +68,7 @@ public class TrackRenderer extends SafeBlockEntityRenderer { for (boolean first : Iterate.trueAndFalse) { Pose transform = segment.railTransforms.get(first); - CachedBufferer.partial(first ? modelHolder.segment_left() : modelHolder.segment_right(), air) + CachedBufferer.partial(first ? modelHolder.leftSegment() : modelHolder.rightSegment(), air) .mulPose(transform.pose()) .mulNormal(transform.normal()) .light(light) diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingBehaviour.java b/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingBehaviour.java index 6c490711d5..abba938ee2 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingBehaviour.java @@ -5,7 +5,6 @@ import java.util.UUID; import javax.annotation.Nullable; -import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.StructureTransform; @@ -28,6 +27,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingClient.java b/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingClient.java index 26fc72bdb1..b68bc4be0c 100644 --- a/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingClient.java +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackTargetingClient.java @@ -1,7 +1,6 @@ package com.simibubi.create.content.trains.track; import com.google.common.base.Objects; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.content.trains.graph.EdgePointType; @@ -11,6 +10,7 @@ import com.simibubi.create.content.trains.track.TrackTargetingBehaviour.Rendered import com.simibubi.create.content.trains.track.TrackTargetingBlockItem.OverlapResult; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.LevelRenderer; @@ -128,7 +128,7 @@ public class TrackTargetingClient { : lastType == EdgePointType.OBSERVER ? RenderedTrackOverlayType.OBSERVER : RenderedTrackOverlayType.STATION; ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(Vec3.atLowerCornerOf(pos) .subtract(camera)); TrackTargetingBehaviour.render(mc.level, pos, direction, lastHoveredBezierSegment, ms, buffer, light, diff --git a/src/main/java/com/simibubi/create/content/trains/track/TrackVisual.java b/src/main/java/com/simibubi/create/content/trains/track/TrackVisual.java new file mode 100644 index 0000000000..5a1edb944d --- /dev/null +++ b/src/main/java/com/simibubi/create/content/trains/track/TrackVisual.java @@ -0,0 +1,292 @@ +package com.simibubi.create.content.trains.track; + +import java.util.List; +import java.util.Objects; +import java.util.function.Consumer; + +import javax.annotation.Nullable; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.PoseStack.Pose; +import com.simibubi.create.AllPartialModels; +import com.simibubi.create.content.trains.track.BezierConnection.GirderAngles; +import com.simibubi.create.content.trains.track.BezierConnection.SegmentAngles; +import com.simibubi.create.foundation.utility.Couple; +import com.simibubi.create.foundation.utility.Iterate; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.visualization.VisualizationContext; +import dev.engine_room.flywheel.lib.instance.FlatLit; +import dev.engine_room.flywheel.lib.instance.InstanceTypes; +import dev.engine_room.flywheel.lib.instance.TransformedInstance; +import dev.engine_room.flywheel.lib.model.Models; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; +import it.unimi.dsi.fastutil.longs.LongArraySet; +import it.unimi.dsi.fastutil.longs.LongSet; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LightLayer; + +public class TrackVisual extends AbstractBlockEntityVisual { + + private final List visuals; + + public TrackVisual(VisualizationContext context, TrackBlockEntity track, float partialTick) { + super(context, track, partialTick); + + visuals = blockEntity.connections.values() + .stream() + .map(this::createInstance) + .filter(Objects::nonNull) + .toList(); + } + + @Override + public void update(float pt) { + if (blockEntity.connections.isEmpty()) + return; + + _delete(); + lightSections.sections(collectLightSections()); + } + + @Override + public void updateLight(float partialTick) { + if (visuals == null) + return; + visuals.forEach(BezierTrackVisual::updateLight); + } + + @Nullable + private BezierTrackVisual createInstance(BezierConnection bc) { + if (!bc.isPrimary()) + return null; + return new BezierTrackVisual(bc); + } + + @Override + public void _delete() { + if (visuals == null) + return; + visuals.forEach(BezierTrackVisual::delete); + } + + public LongSet collectLightSections() { + LongSet longSet = new LongArraySet(); + + if (blockEntity.connections.isEmpty()) { + return LongSet.of(); + } + int minX = Integer.MAX_VALUE; + int minY = Integer.MAX_VALUE; + int minZ = Integer.MAX_VALUE; + int maxX = Integer.MIN_VALUE; + int maxY = Integer.MIN_VALUE; + int maxZ = Integer.MIN_VALUE; + for (BlockPos pos : blockEntity.connections.keySet()) { + minX = Math.min(minX, pos.getX()); + minY = Math.min(minY, pos.getY()); + minZ = Math.min(minZ, pos.getZ()); + maxX = Math.max(maxX, pos.getX()); + maxY = Math.max(maxY, pos.getY()); + maxZ = Math.max(maxZ, pos.getZ()); + } + SectionPos.betweenClosedStream(SectionPos.blockToSectionCoord(minX), SectionPos.blockToSectionCoord(minY), SectionPos.blockToSectionCoord(minZ), SectionPos.blockToSectionCoord(maxX), SectionPos.blockToSectionCoord(maxY), SectionPos.blockToSectionCoord(maxZ)) + .mapToLong(SectionPos::asLong) + .forEach(longSet::add); + + return longSet; + } + + @Override + public void collectCrumblingInstances(Consumer consumer) { + if (visuals == null) + return; + for (BezierTrackVisual instance : visuals) { + instance.collectCrumblingInstances(consumer); + } + } + + private class BezierTrackVisual { + + private final TransformedInstance[] ties; + private final TransformedInstance[] left; + private final TransformedInstance[] right; + private final BlockPos[] tiesLightPos; + private final BlockPos[] leftLightPos; + private final BlockPos[] rightLightPos; + + private @Nullable GirderVisual girder; + + private BezierTrackVisual(BezierConnection bc) { + BlockPos tePosition = bc.bePositions.getFirst(); + girder = bc.hasGirder ? new GirderVisual(bc) : null; + + PoseStack pose = new PoseStack(); + TransformStack.of(pose) + .translate(getVisualPosition()); + + int segCount = bc.getSegmentCount(); + ties = new TransformedInstance[segCount]; + left = new TransformedInstance[segCount]; + right = new TransformedInstance[segCount]; + tiesLightPos = new BlockPos[segCount]; + leftLightPos = new BlockPos[segCount]; + rightLightPos = new BlockPos[segCount]; + + TrackMaterial.TrackModelHolder modelHolder = bc.getMaterial().getModelHolder(); + + instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.tie())) + .createInstances(ties); + instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.leftSegment())) + .createInstances(left); + instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.rightSegment())) + .createInstances(right); + + SegmentAngles[] segments = bc.getBakedSegments(); + for (int i = 1; i < segments.length; i++) { + SegmentAngles segment = segments[i]; + var modelIndex = i - 1; + + ties[modelIndex].setTransform(pose) + .transform(segment.tieTransform) + .setChanged(); + tiesLightPos[modelIndex] = segment.lightPosition.offset(tePosition); + + for (boolean first : Iterate.trueAndFalse) { + Pose transform = segment.railTransforms.get(first); + (first ? this.left : this.right)[modelIndex].setTransform(pose) + .transform(transform) + .setChanged(); + (first ? leftLightPos : rightLightPos)[modelIndex] = segment.lightPosition.offset(tePosition); + } + } + + updateLight(); + } + + void delete() { + for (var d : ties) + d.delete(); + for (var d : left) + d.delete(); + for (var d : right) + d.delete(); + if (girder != null) + girder.delete(); + } + + void updateLight() { + for (int i = 0; i < ties.length; i++) + TrackVisual.updateLight(ties[i], level, tiesLightPos[i]); + for (int i = 0; i < left.length; i++) + TrackVisual.updateLight(left[i], level, leftLightPos[i]); + for (int i = 0; i < right.length; i++) + TrackVisual.updateLight(right[i], level, rightLightPos[i]); + if (girder != null) + girder.updateLight(); + } + + public void collectCrumblingInstances(Consumer consumer) { + for (var d : ties) + consumer.accept(d); + for (var d : left) + consumer.accept(d); + for (var d : right) + consumer.accept(d); + if (girder != null) + girder.collectCrumblingInstances(consumer); + } + + private class GirderVisual { + + private final Couple beams; + private final Couple> beamCaps; + private final BlockPos[] lightPos; + + private GirderVisual(BezierConnection bc) { + BlockPos tePosition = bc.bePositions.getFirst(); + PoseStack pose = new PoseStack(); + TransformStack.of(pose) + .translate(getVisualPosition()) + .nudge((int) bc.bePositions.getFirst() + .asLong()); + + int segCount = bc.getSegmentCount(); + beams = Couple.create(() -> new TransformedInstance[segCount]); + beamCaps = Couple.create(() -> Couple.create(() -> new TransformedInstance[segCount])); + lightPos = new BlockPos[segCount]; + beams.forEach(instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.GIRDER_SEGMENT_MIDDLE))::createInstances); + beamCaps.forEachWithContext((c, top) -> { + var partialModel = Models.partial(top ? AllPartialModels.GIRDER_SEGMENT_TOP : AllPartialModels.GIRDER_SEGMENT_BOTTOM); + c.forEach(instancerProvider.instancer(InstanceTypes.TRANSFORMED, partialModel)::createInstances); + }); + + GirderAngles[] bakedGirders = bc.getBakedGirders(); + for (int i = 1; i < bakedGirders.length; i++) { + GirderAngles segment = bakedGirders[i]; + var modelIndex = i - 1; + lightPos[modelIndex] = segment.lightPosition.offset(tePosition); + + for (boolean first : Iterate.trueAndFalse) { + Pose beamTransform = segment.beams.get(first); + beams.get(first)[modelIndex].setTransform(pose) + .transform(beamTransform) + .setChanged(); + for (boolean top : Iterate.trueAndFalse) { + Pose beamCapTransform = segment.beamCaps.get(top) + .get(first); + beamCaps.get(top) + .get(first)[modelIndex].setTransform(pose) + .transform(beamCapTransform) + .setChanged(); + } + } + } + + updateLight(); + } + + void delete() { + beams.forEach(arr -> { + for (var d : arr) + d.delete(); + }); + beamCaps.forEach(c -> c.forEach(arr -> { + for (var d : arr) + d.delete(); + })); + } + + void updateLight() { + beams.forEach(arr -> { + for (int i = 0; i < arr.length; i++) + TrackVisual.updateLight(arr[i], level, lightPos[i]); + }); + beamCaps.forEach(c -> c.forEach(arr -> { + for (int i = 0; i < arr.length; i++) + TrackVisual.updateLight(arr[i], level, lightPos[i]); + })); + } + + public void collectCrumblingInstances(Consumer consumer) { + beams.forEach(arr -> { + for (var d : arr) + consumer.accept(d); + }); + beamCaps.forEach(c -> c.forEach(arr -> { + for (var d : arr) + consumer.accept(d); + })); + } + } + + } + + private static void updateLight(FlatLit instance, Level level, BlockPos pos) { + instance.light(level.getBrightness(LightLayer.BLOCK, pos), level.getBrightness(LightLayer.SKY, pos)) + .setChanged(); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java index 537ff9d68f..8d3d3a948d 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.block.render; -import com.jozufozu.flywheel.core.StitchedSprite; +import com.simibubi.create.foundation.render.StitchedSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxRenderer.java b/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxRenderer.java index 7774df305f..fc60eb4e41 100644 --- a/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxRenderer.java @@ -2,10 +2,10 @@ package com.simibubi.create.foundation.blockEntity.behaviour; import org.joml.Matrix3f; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.kinetics.simpleRelays.AbstractSimpleShaftBlock; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ItemRenderer; @@ -47,17 +47,17 @@ public class ValueBoxRenderer { int itemLight = Mth.floor(sl + .5) << 20 | (Mth.floor(bl + .5) & 0xf) << 4; ms.pushPose(); - TransformStack.cast(ms) - .rotateX(230); + TransformStack.of(ms) + .rotateXDegrees(230); Matrix3f copy = new Matrix3f(ms.last() .normal()); ms.popPose(); ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(0, 0, -1 / 4f) .translate(0, 0, 1 / 32f + .001) - .rotateY(180); + .rotateYDegrees(180); PoseStack squashedMS = new PoseStack(); squashedMS.last() diff --git a/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxTransform.java b/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxTransform.java index 8a410a5845..0082e4b27b 100644 --- a/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxTransform.java +++ b/src/main/java/com/simibubi/create/foundation/blockEntity/behaviour/ValueBoxTransform.java @@ -4,11 +4,11 @@ import java.util.function.Function; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.world.level.block.state.BlockState; @@ -42,7 +42,7 @@ public abstract class ValueBoxTransform { public boolean shouldRender(BlockState state) { return !state.isAir() && getLocalOffset(state) != null; } - + public int getOverrideColor() { return -1; } @@ -112,9 +112,9 @@ public abstract class ValueBoxTransform { public void rotate(BlockState state, PoseStack ms) { float yRot = AngleHelper.horizontalAngle(getSide()) + 180; float xRot = getSide() == Direction.UP ? 90 : getSide() == Direction.DOWN ? 270 : 0; - TransformStack.cast(ms) - .rotateY(yRot) - .rotateX(xRot); + TransformStack.of(ms) + .rotateYDegrees(yRot) + .rotateXDegrees(xRot); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/ColoredOverlayBlockEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/ColoredOverlayBlockEntityRenderer.java index d45608e71f..175bbcc760 100644 --- a/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/ColoredOverlayBlockEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/blockEntity/renderer/ColoredOverlayBlockEntityRenderer.java @@ -1,9 +1,9 @@ package com.simibubi.create.foundation.blockEntity.renderer; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperByteBuffer; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -18,7 +18,7 @@ public abstract class ColoredOverlayBlockEntityRenderer e protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.canUseInstancing(be.getLevel())) return; + if (VisualizationManager.supportsVisualization(be.getLevel())) return; SuperByteBuffer render = render(getOverlayBuffer(be), getColor(be, partialTicks), light); render.renderInto(ms, buffer.getBuffer(RenderType.solid())); diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateBlockEntityBuilder.java b/src/main/java/com/simibubi/create/foundation/data/CreateBlockEntityBuilder.java index 5abb51ebd2..8f61275bdc 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateBlockEntityBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateBlockEntityBuilder.java @@ -2,14 +2,10 @@ package com.simibubi.create.foundation.data; import java.util.ArrayList; import java.util.Collection; -import java.util.function.BiFunction; import java.util.function.Supplier; import javax.annotation.Nullable; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; -import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; import com.simibubi.create.Create; import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.builders.BlockEntityBuilder; @@ -17,6 +13,7 @@ import com.tterrag.registrate.builders.BuilderCallback; import com.tterrag.registrate.util.OneTimeEventReceiver; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import dev.engine_room.flywheel.lib.visualization.SimpleBlockEntityVisualizer; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -28,7 +25,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class CreateBlockEntityBuilder extends BlockEntityBuilder { @Nullable - private NonNullSupplier>> instanceFactory; + private NonNullSupplier> visualFactory; private NonNullPredicate renderNormally; private Collection>>> deferredValidBlocks = @@ -59,39 +56,38 @@ public class CreateBlockEntityBuilder extends BlockEnt return super.createEntry(); } - public CreateBlockEntityBuilder instance( - NonNullSupplier>> instanceFactory) { - return instance(instanceFactory, true); + public CreateBlockEntityBuilder visual( + NonNullSupplier> visualFactory) { + return visual(visualFactory, true); } - public CreateBlockEntityBuilder instance( - NonNullSupplier>> instanceFactory, + public CreateBlockEntityBuilder visual( + NonNullSupplier> visualFactory, boolean renderNormally) { - return instance(instanceFactory, be -> renderNormally); + return visual(visualFactory, be -> renderNormally); } - public CreateBlockEntityBuilder instance( - NonNullSupplier>> instanceFactory, + public CreateBlockEntityBuilder visual( + NonNullSupplier> visualFactory, NonNullPredicate renderNormally) { - if (this.instanceFactory == null) { - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerInstance); + if (this.visualFactory == null) { + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerVisualizer); } - this.instanceFactory = instanceFactory; + this.visualFactory = visualFactory; this.renderNormally = renderNormally; return this; } - protected void registerInstance() { + protected void registerVisualizer() { OneTimeEventReceiver.addModListener(Create.REGISTRATE, FMLClientSetupEvent.class, $ -> { - NonNullSupplier>> instanceFactory = - this.instanceFactory; - if (instanceFactory != null) { + var visualFactory = this.visualFactory; + if (visualFactory != null) { NonNullPredicate renderNormally = this.renderNormally; - InstancedRenderRegistry.configure(getEntry()) - .factory(instanceFactory.get()) - .skipRender(be -> !renderNormally.test(be)) + SimpleBlockEntityVisualizer.builder(getEntry()) + .factory(visualFactory.get()) + .skipVanillaRender(be -> !renderNormally.test(be)) .apply(); } }); diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java b/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java index 2fbde67eba..944508939c 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateEntityBuilder.java @@ -1,13 +1,8 @@ package com.simibubi.create.foundation.data; -import java.util.function.BiFunction; - import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; -import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; import com.simibubi.create.Create; import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.builders.BuilderCallback; @@ -15,6 +10,7 @@ import com.tterrag.registrate.builders.EntityBuilder; import com.tterrag.registrate.util.OneTimeEventReceiver; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import dev.engine_room.flywheel.lib.visualization.SimpleEntityVisualizer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; @@ -27,7 +23,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class CreateEntityBuilder extends EntityBuilder { @Nullable - private NonNullSupplier>> instanceFactory; + private NonNullSupplier> visualFactory; private NonNullPredicate renderNormally; public static EntityBuilder create(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, EntityType.EntityFactory factory, MobCategory classification) { @@ -38,37 +34,35 @@ public class CreateEntityBuilder extends EntityBuilder instance(NonNullSupplier>> instanceFactory) { - return instance(instanceFactory, true); + public CreateEntityBuilder visual(NonNullSupplier> visualFactory) { + return visual(visualFactory, true); } - public CreateEntityBuilder instance(NonNullSupplier>> instanceFactory, boolean renderNormally) { - return instance(instanceFactory, be -> renderNormally); + public CreateEntityBuilder visual(NonNullSupplier> visualFactory, boolean renderNormally) { + return visual(visualFactory, entity -> renderNormally); } - public CreateEntityBuilder instance(NonNullSupplier>> instanceFactory, NonNullPredicate renderNormally) { - if (this.instanceFactory == null) { - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerInstance); + public CreateEntityBuilder visual(NonNullSupplier> visualFactory, NonNullPredicate renderNormally) { + if (this.visualFactory == null) { + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerVisualizer); } - this.instanceFactory = instanceFactory; + this.visualFactory = visualFactory; this.renderNormally = renderNormally; return this; } - protected void registerInstance() { + protected void registerVisualizer() { OneTimeEventReceiver.addModListener(Create.REGISTRATE, FMLClientSetupEvent.class, $ -> { - NonNullSupplier>> instanceFactory = this.instanceFactory; - if (instanceFactory != null) { + var visualFactory = this.visualFactory; + if (visualFactory != null) { NonNullPredicate renderNormally = this.renderNormally; - InstancedRenderRegistry.configure(getEntry()) - .factory(instanceFactory.get()) - .skipRender(be -> !renderNormally.test(be)) + SimpleEntityVisualizer.builder(getEntry()) + .factory(visualFactory.get()) + .skipVanillaRender(entity -> !renderNormally.test(entity)) .apply(); } - }); } - } diff --git a/src/main/java/com/simibubi/create/foundation/events/ClientEvents.java b/src/main/java/com/simibubi/create/foundation/events/ClientEvents.java index ab5fcd6d31..f41ba8c3bb 100644 --- a/src/main/java/com/simibubi/create/foundation/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/foundation/events/ClientEvents.java @@ -13,7 +13,7 @@ import com.simibubi.create.content.contraptions.minecart.CouplingHandlerClient; import com.simibubi.create.content.contraptions.minecart.CouplingPhysics; import com.simibubi.create.content.contraptions.minecart.CouplingRenderer; import com.simibubi.create.content.contraptions.minecart.capability.CapabilityMinecartController; -import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfoManager; import com.simibubi.create.content.decoration.girder.GirderWrenchBehavior; import com.simibubi.create.content.equipment.armor.BacktankArmorLayer; import com.simibubi.create.content.equipment.armor.DivingHelmetItem; @@ -158,7 +158,7 @@ public class ClientEvents { PlacementHelpers.tick(); CreateClient.OUTLINER.tickOutlines(); CreateClient.GHOST_BLOCKS.tickGhosts(); - ContraptionRenderDispatcher.tick(world); + ContraptionRenderInfoManager.tickFor(world); BlueprintOverlayRenderer.tick(); ToolboxHandlerClient.clientTick(); TrackTargetingClient.clientTick(); diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java index a4cc110864..423008240f 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.foundation.fluid; import java.util.function.Function; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack.Pose; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -33,7 +33,7 @@ import net.minecraftforge.fluids.FluidType; public class FluidRenderer { public static VertexConsumer getFluidBuilder(MultiBufferSource buffer) { - return buffer.getBuffer(RenderTypes.getFluid()); + return buffer.getBuffer(RenderTypes.fluid()); } public static void renderFluidStream(FluidStack fluidStack, Direction direction, float radius, float progress, @@ -59,12 +59,12 @@ public class FluidRenderer { if (inbound) direction = direction.getOpposite(); - TransformStack msr = TransformStack.cast(ms); + var msr = TransformStack.of(ms); ms.pushPose(); - msr.centre() - .rotateY(AngleHelper.horizontalAngle(direction)) - .rotateX(direction == Direction.UP ? 180 : direction == Direction.DOWN ? 0 : 270) - .unCentre(); + msr.center() + .rotateYDegrees(AngleHelper.horizontalAngle(direction)) + .rotateXDegrees(direction == Direction.UP ? 180 : direction == Direction.DOWN ? 0 : 270) + .uncenter(); ms.translate(.5, 0, .5); float h = radius; @@ -78,7 +78,7 @@ public class FluidRenderer { ms.pushPose(); renderFlowingTiledFace(Direction.SOUTH, hMin, yMin, hMax, yMax, h, builder, ms, light, color, flowTexture); ms.popPose(); - msr.rotateY(90); + msr.rotateYDegrees(90); } if (progress != 1) @@ -110,9 +110,9 @@ public class FluidRenderer { Vec3 center = new Vec3(xMin + (xMax - xMin) / 2, yMin + (yMax - yMin) / 2, zMin + (zMax - zMin) / 2); ms.pushPose(); if (fluidAttributes.isLighterThanAir()) - TransformStack.cast(ms) + TransformStack.of(ms) .translate(center) - .rotateX(180) + .rotateXDegrees(180) .translateBack(center); for (Direction side : Iterate.directions) { diff --git a/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java b/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java index 2618fd9bf6..86f8bbb28a 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java +++ b/src/main/java/com/simibubi/create/foundation/gui/CustomLightingSettings.java @@ -1,6 +1,5 @@ package com.simibubi.create.foundation.gui; -import org.joml.Matrix4f; import org.joml.Vector3f; import com.mojang.blaze3d.systems.RenderSystem; @@ -10,7 +9,6 @@ public class CustomLightingSettings implements ILightingSettings { private Vector3f light1; private Vector3f light2; - private Matrix4f lightMatrix; protected CustomLightingSettings(float yRot, float xRot) { init(yRot, xRot, 0, 0, false); @@ -32,14 +30,11 @@ public class CustomLightingSettings implements ILightingSettings { } else { light2 = new Vector3f(); } - - lightMatrix = new Matrix4f(); - lightMatrix.identity(); } @Override public void applyLighting() { - RenderSystem.setupLevelDiffuseLighting(light1, light2, lightMatrix); + RenderSystem.setShaderLights(light1, light2); } public static Builder builder() { diff --git a/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java index 50cc389cb3..568e0e08b9 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java @@ -2,8 +2,6 @@ package com.simibubi.create.foundation.gui.element; import javax.annotation.Nullable; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.core.model.ModelUtil; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager.DestFactor; import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; @@ -14,9 +12,11 @@ import com.mojang.math.Axis; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.gui.ILightingSettings; import com.simibubi.create.foundation.gui.UIRenderHelper; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.LightTexture; @@ -171,8 +171,7 @@ public class GuiGameElement { Minecraft mc = Minecraft.getInstance(); BlockRenderDispatcher blockRenderer = mc.getBlockRenderer(); - MultiBufferSource.BufferSource buffer = mc.renderBuffers() - .bufferSource(); + MultiBufferSource.BufferSource buffer = graphics.bufferSource(); transformMatrix(matrixStack); @@ -188,19 +187,19 @@ public class GuiGameElement { RenderType renderType = Sheets.translucentCullBlockSheet(); blockRenderer.getModelRenderer() .renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel, 1, 1, 1, - LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, ModelUtil.VIRTUAL_DATA, null); + LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, VirtualRenderHelper.VIRTUAL_DATA, null); } else { int color = Minecraft.getInstance() .getBlockColors() .getColor(blockState, null, null, 0); Color rgb = new Color(color == -1 ? this.color : color); - for (RenderType chunkType : blockModel.getRenderTypes(blockState, RandomSource.create(42L), ModelUtil.VIRTUAL_DATA)) { + for (RenderType chunkType : blockModel.getRenderTypes(blockState, RandomSource.create(42L), VirtualRenderHelper.VIRTUAL_DATA)) { RenderType renderType = RenderTypeHelper.getEntityRenderType(chunkType, true); blockRenderer.getModelRenderer() .renderModel(ms.last(), buffer.getBuffer(renderType), blockState, blockModel, rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(), - LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, ModelUtil.VIRTUAL_DATA, chunkType); + LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, VirtualRenderHelper.VIRTUAL_DATA, chunkType); } } @@ -264,11 +263,11 @@ public class GuiGameElement { PoseStack matrixStack = graphics.pose(); prepareMatrix(matrixStack); transformMatrix(matrixStack); - renderItemIntoGUI(matrixStack, stack, customLighting == null); + renderItemIntoGUI(graphics, matrixStack, stack, customLighting == null); cleanUpMatrix(matrixStack); } - public static void renderItemIntoGUI(PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) { + public static void renderItemIntoGUI(GuiGraphics graphics, PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) { ItemRenderer renderer = Minecraft.getInstance().getItemRenderer(); BakedModel bakedModel = renderer.getModel(stack, null, null, 0); @@ -282,7 +281,7 @@ public class GuiGameElement { matrixStack.translate(0, 0, 100.0F); matrixStack.translate(8.0F, -8.0F, 0.0F); matrixStack.scale(16.0F, 16.0F, 16.0F); - MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource(); + MultiBufferSource.BufferSource buffer = graphics.bufferSource(); boolean flatLighting = !bakedModel.usesBlockLight(); if (useDefaultLighting && flatLighting) { Lighting.setupForFlatItems(); @@ -291,7 +290,7 @@ public class GuiGameElement { renderer.render(stack, ItemDisplayContext.GUI, false, matrixStack, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, bakedModel); RenderSystem.disableDepthTest(); buffer.endBatch(); - + RenderSystem.enableDepthTest(); if (useDefaultLighting && flatLighting) { Lighting.setupFor3DItems(); diff --git a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java index 9a07c3b006..b03db2b94e 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java @@ -8,6 +8,7 @@ import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; @@ -41,19 +42,19 @@ public class PartialItemModelRenderer { } public void render(BakedModel model, int light) { - render(model, RenderTypes.getItemPartialTranslucent(), light); + render(model, Sheets.translucentCullBlockSheet(), light); } public void renderSolid(BakedModel model, int light) { - render(model, RenderTypes.getItemPartialSolid(), light); - } - - public void renderSolidGlowing(BakedModel model, int light) { - render(model, RenderTypes.getGlowingSolid(), light); + render(model, Sheets.solidBlockSheet(), light); } public void renderGlowing(BakedModel model, int light) { - render(model, RenderTypes.getGlowingTranslucent(), light); + render(model, RenderTypes.itemGlowingTranslucent(), light); + } + + public void renderSolidGlowing(BakedModel model, int light) { + render(model, RenderTypes.itemGlowingSolid(), light); } public void render(BakedModel model, RenderType type, int light) { diff --git a/src/main/java/com/simibubi/create/foundation/mixin/accessor/BufferBuilderAccessor.java b/src/main/java/com/simibubi/create/foundation/mixin/accessor/BufferBuilderAccessor.java new file mode 100644 index 0000000000..22df2610ce --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/accessor/BufferBuilderAccessor.java @@ -0,0 +1,12 @@ +package com.simibubi.create.foundation.mixin.accessor; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import com.mojang.blaze3d.vertex.BufferBuilder; + +@Mixin(BufferBuilder.class) +public interface BufferBuilderAccessor { + @Accessor("vertices") + int create$getVertices(); +} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/accessor/RenderSystemAccessor.java b/src/main/java/com/simibubi/create/foundation/mixin/accessor/RenderSystemAccessor.java new file mode 100644 index 0000000000..96b9ec1d1c --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/accessor/RenderSystemAccessor.java @@ -0,0 +1,15 @@ +package com.simibubi.create.foundation.mixin.accessor; + +import org.joml.Vector3f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import com.mojang.blaze3d.systems.RenderSystem; + +@Mixin(RenderSystem.class) +public interface RenderSystemAccessor { + @Accessor("shaderLightDirections") + static Vector3f[] create$getShaderLightDirections() { + throw new AssertionError(); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/outliner/AABBOutline.java b/src/main/java/com/simibubi/create/foundation/outliner/AABBOutline.java index ed94ace116..555a6704cf 100644 --- a/src/main/java/com/simibubi/create/foundation/outliner/AABBOutline.java +++ b/src/main/java/com/simibubi/create/foundation/outliner/AABBOutline.java @@ -70,7 +70,7 @@ public class AABBOutline extends Outline { if (lineWidth == 0) return; - VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid()); + VertexConsumer consumer = buffer.getBuffer(RenderTypes.outlineSolid()); renderBoxEdges(ms, consumer, minPos, maxPos, lineWidth, color, lightmap, disableLineNormals); } @@ -94,7 +94,7 @@ public class AABBOutline extends Outline { return; AllSpecialTextures faceTexture = optionalFaceTexture.get(); - RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), cull); + RenderType renderType = RenderTypes.outlineTranslucent(faceTexture.getLocation(), cull); VertexConsumer consumer = buffer.getLateBuffer(renderType); float alphaMult = highlighted ? 1 : 0.5f; diff --git a/src/main/java/com/simibubi/create/foundation/outliner/BlockClusterOutline.java b/src/main/java/com/simibubi/create/foundation/outliner/BlockClusterOutline.java index 59b8a4d00e..fc8b463167 100644 --- a/src/main/java/com/simibubi/create/foundation/outliner/BlockClusterOutline.java +++ b/src/main/java/com/simibubi/create/foundation/outliner/BlockClusterOutline.java @@ -63,7 +63,7 @@ public class BlockClusterOutline extends Outline { AllSpecialTextures faceTexture = optionalFaceTexture.get(); PoseStack.Pose pose = ms.last(); - RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), true); + RenderType renderType = RenderTypes.outlineTranslucent(faceTexture.getLocation(), true); VertexConsumer consumer = buffer.getLateBuffer(renderType); cluster.visibleFaces.forEach((face, axisDirection) -> { @@ -89,7 +89,7 @@ public class BlockClusterOutline extends Outline { cluster.anchor.getZ() - camera.z); PoseStack.Pose pose = ms.last(); - VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid()); + VertexConsumer consumer = buffer.getBuffer(RenderTypes.outlineSolid()); cluster.visibleEdges.forEach(edge -> { BlockPos pos = edge.pos; diff --git a/src/main/java/com/simibubi/create/foundation/outliner/ItemOutline.java b/src/main/java/com/simibubi/create/foundation/outliner/ItemOutline.java index 1cd41af438..745582a0b3 100644 --- a/src/main/java/com/simibubi/create/foundation/outliner/ItemOutline.java +++ b/src/main/java/com/simibubi/create/foundation/outliner/ItemOutline.java @@ -1,9 +1,9 @@ package com.simibubi.create.foundation.outliner; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -26,7 +26,7 @@ public class ItemOutline extends Outline { Minecraft mc = Minecraft.getInstance(); ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(pos.x - camera.x, pos.y - camera.y, pos.z - camera.z) .scale(params.alpha); diff --git a/src/main/java/com/simibubi/create/foundation/outliner/LineOutline.java b/src/main/java/com/simibubi/create/foundation/outliner/LineOutline.java index 09cd2a6a00..aad99f336e 100644 --- a/src/main/java/com/simibubi/create/foundation/outliner/LineOutline.java +++ b/src/main/java/com/simibubi/create/foundation/outliner/LineOutline.java @@ -34,7 +34,7 @@ public class LineOutline extends Outline { if (width == 0) return; - VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid()); + VertexConsumer consumer = buffer.getBuffer(RenderTypes.outlineSolid()); params.loadColor(colorTemp); Vector4f color = colorTemp; int lightmap = params.lightmap; diff --git a/src/main/java/com/simibubi/create/foundation/outliner/Outline.java b/src/main/java/com/simibubi/create/foundation/outliner/Outline.java index 269a22b6b9..44ee2cfd5c 100644 --- a/src/main/java/com/simibubi/create/foundation/outliner/Outline.java +++ b/src/main/java/com/simibubi/create/foundation/outliner/Outline.java @@ -10,7 +10,6 @@ import org.joml.Vector3d; import org.joml.Vector3f; import org.joml.Vector4f; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllSpecialTextures; @@ -18,6 +17,7 @@ import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.Direction; @@ -58,10 +58,10 @@ public abstract class Outline { float vAngle = AngleHelper.deg(Mth.atan2(hDistance, diff.y())) - 90; poseStack.pushPose(); - TransformStack.cast(poseStack) + TransformStack.of(poseStack) .translate(start.x - camera.x, start.y - camera.y, start.z - camera.z) - .rotateY(hAngle) - .rotateX(vAngle); + .rotateYDegrees(hAngle) + .rotateXDegrees(vAngle); bufferCuboidLine(poseStack.last(), consumer, new Vector3f(), Direction.SOUTH, length, width, color, lightmap, disableNormals); poseStack.popPose(); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java index 7bf288b16c..d35b796718 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -20,8 +20,6 @@ import org.apache.commons.lang3.mutable.MutableObject; import org.joml.Matrix4f; import org.joml.Vector4f; -import com.jozufozu.flywheel.util.DiffuseLightCalculator; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.outliner.Outliner; @@ -32,7 +30,6 @@ import com.simibubi.create.foundation.ponder.element.WorldSectionElement; import com.simibubi.create.foundation.ponder.instruction.HideAllInstruction; import com.simibubi.create.foundation.ponder.instruction.PonderInstruction; import com.simibubi.create.foundation.ponder.ui.PonderUI; -import com.simibubi.create.foundation.render.ForcedDiffuseState; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pair; @@ -40,6 +37,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.infrastructure.ponder.PonderIndex; +import dev.engine_room.flywheel.lib.transform.TransformStack; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.client.Camera; @@ -236,7 +234,6 @@ public class PonderScene { } public void renderScene(SuperRenderTypeBuffer buffer, PoseStack ms, float pt) { - ForcedDiffuseState.pushCalculator(DiffuseLightCalculator.DEFAULT); ms.pushPose(); Minecraft mc = Minecraft.getInstance(); @@ -256,7 +253,6 @@ public class PonderScene { outliner.renderOutlines(ms, buffer, Vec3.ZERO, pt); ms.popPose(); - ForcedDiffuseState.popCalculator(); } public void renderOverlay(PonderUI screen, GuiGraphics graphics, float partialTicks) { @@ -462,7 +458,7 @@ public class PonderScene { public int getBasePlateOffsetZ() { return basePlateOffsetZ; } - + public boolean shouldHidePlatformShadow() { return hidePlatformShadow; } @@ -524,14 +520,14 @@ public class PonderScene { public PoseStack apply(PoseStack ms, float pt) { ms.translate(width / 2, height / 2, 200 + offset); - TransformStack.cast(ms) - .rotateX(-35) - .rotateY(55) + TransformStack.of(ms) + .rotateXDegrees(-35) + .rotateYDegrees(55) .translate(offset, 0, 0) - .rotateY(-55) - .rotateX(35) - .rotateX(xRotation.getValue(pt)) - .rotateY(yRotation.getValue(pt)); + .rotateYDegrees(-55) + .rotateXDegrees(35) + .rotateXDegrees(xRotation.getValue(pt)) + .rotateYDegrees(yRotation.getValue(pt)); UIRenderHelper.flipForGuiRender(ms); float f = 30 * scaleFactor; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/element/AnimatedSceneElement.java b/src/main/java/com/simibubi/create/foundation/ponder/element/AnimatedSceneElement.java index a8c8b7258f..cae7342d11 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/element/AnimatedSceneElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/element/AnimatedSceneElement.java @@ -1,10 +1,10 @@ package com.simibubi.create.foundation.ponder.element; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -61,7 +61,7 @@ public abstract class AnimatedSceneElement extends PonderSceneElement { protected float applyFade(PoseStack ms, float pt) { float currentFade = fade.getValue(pt); if (fadeVec != null) - TransformStack.cast(ms) + TransformStack.of(ms) .translate(fadeVec.scale(-1 + currentFade)); return currentFade; } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/element/MinecartElement.java b/src/main/java/com/simibubi/create/foundation/ponder/element/MinecartElement.java index deded12107..2d1b6fa768 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/element/MinecartElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/element/MinecartElement.java @@ -1,11 +1,11 @@ package com.simibubi.create.foundation.ponder.element; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; @@ -103,8 +103,8 @@ public class MinecartElement extends AnimatedSceneElement { ms.translate(Mth.lerp(pt, entity.xo, entity.getX()), Mth.lerp(pt, entity.yo, entity.getY()), Mth.lerp(pt, entity.zo, entity.getZ())); - TransformStack.cast(ms) - .rotateY(rotation.getValue(pt)); + TransformStack.of(ms) + .rotateYDegrees(rotation.getValue(pt)); entityrenderermanager.render(entity, 0, 0, 0, 0, pt, ms, buffer, lightCoordsFromFade(fade)); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/element/ParrotElement.java b/src/main/java/com/simibubi/create/foundation/ponder/element/ParrotElement.java index 1a7dd72116..2f4aefbe58 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/element/ParrotElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/element/ParrotElement.java @@ -2,7 +2,6 @@ package com.simibubi.create.foundation.ponder.element; import java.util.function.Supplier; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; @@ -12,6 +11,7 @@ import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.ponder.ui.PonderUI; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; @@ -111,7 +111,7 @@ public class ParrotElement extends AnimatedSceneElement { entity.xRotO = entity.getXRot(); entity.yRotO = entity.getYRot(); } - + public void setConductor(boolean isConductor) { if (entity == null) { deferConductor = isConductor; @@ -147,8 +147,8 @@ public class ParrotElement extends AnimatedSceneElement { ms.translate(Mth.lerp(pt, entity.xo, entity.getX()), Mth.lerp(pt, entity.yo, entity.getY()), Mth.lerp(pt, entity.zo, entity.getZ())); - TransformStack.cast(ms) - .rotateY(AngleHelper.angleLerp(pt, entity.yRotO, entity.getYRot())); + TransformStack.of(ms) + .rotateYDegrees(AngleHelper.angleLerp(pt, entity.yRotO, entity.getYRot())); entityrenderermanager.render(entity, 0, 0, 0, 0, pt, ms, buffer, lightCoordsFromFade(fade)); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java b/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java index bcd89004e2..820f4d6667 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java @@ -6,22 +6,16 @@ import java.util.Map; import java.util.Map.Entry; import java.util.function.Consumer; -import com.jozufozu.flywheel.core.model.ModelUtil; -import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferedData; -import com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer; -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormat; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.outliner.AABBOutline; import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.ponder.Selection; import com.simibubi.create.foundation.render.BlockEntityRenderHelper; +import com.simibubi.create.foundation.render.ShadedBlockSbbBuilder; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; @@ -29,6 +23,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.model.ModelUtil; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.MultiBufferSource; @@ -229,7 +225,7 @@ public class WorldSectionElement extends AnimatedSceneElement { } public void transformMS(PoseStack ms, float pt) { - TransformStack.cast(ms) + TransformStack.of(ms) .translate(VecHelper.lerp(pt, prevAnimatedOffset, animatedOffset)); if (!animatedRotation.equals(Vec3.ZERO) || !prevAnimatedRotation.equals(Vec3.ZERO)) { if (centerOfRotation == null) @@ -237,18 +233,18 @@ public class WorldSectionElement extends AnimatedSceneElement { double rotX = Mth.lerp(pt, prevAnimatedRotation.x, animatedRotation.x); double rotZ = Mth.lerp(pt, prevAnimatedRotation.z, animatedRotation.z); double rotY = Mth.lerp(pt, prevAnimatedRotation.y, animatedRotation.y); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(centerOfRotation) - .rotateX(rotX) - .rotateZ(rotZ) - .rotateY(rotY) + .rotateX((float) rotX) + .rotateZ((float) rotZ) + .rotateY((float) rotY) .translateBack(centerOfRotation); if (stabilizationAnchor != null) { - TransformStack.cast(ms) + TransformStack.of(ms) .translate(stabilizationAnchor) - .rotateX(-rotX) - .rotateZ(-rotZ) - .rotateY(-rotY) + .rotateX((float) -rotX) + .rotateZ((float) -rotZ) + .rotateY((float) -rotY) .translateBack(stabilizationAnchor); } } @@ -309,7 +305,7 @@ public class WorldSectionElement extends AnimatedSceneElement { public void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) { int light = -1; if (fade != 1) - light = (int) (Mth.lerp(fade, 5, 14)); + light = (int) (Mth.lerp(fade, 5, 15)); if (redraw) { renderedBlockEntities = null; tickableBlockEntities = null; @@ -363,14 +359,14 @@ public class WorldSectionElement extends AnimatedSceneElement { if (redraw) bufferCache.invalidate(DOC_WORLD_SECTION, key); - SuperByteBuffer contraptionBuffer = + SuperByteBuffer structureBuffer = bufferCache.get(DOC_WORLD_SECTION, key, () -> buildStructureBuffer(world, type)); - if (contraptionBuffer.isEmpty()) + if (structureBuffer.isEmpty()) return; - transformMS(contraptionBuffer.getTransforms(), pt); + transformMS(structureBuffer.getTransforms(), pt); int light = lightCoordsFromFade(fade); - contraptionBuffer + structureBuffer .light(light) .renderInto(ms, buffer.getBuffer(type)); } @@ -414,22 +410,22 @@ public class WorldSectionElement extends AnimatedSceneElement { PoseStack poseStack = objects.poseStack; RandomSource random = objects.random; - ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper; - BufferBuilder shadedBuilder = objects.shadedBuilder; - BufferBuilder unshadedBuilder = objects.unshadedBuilder; - shadedBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - unshadedBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - shadeSeparatingWrapper.prepare(shadedBuilder, unshadedBuilder); + ShadedBlockSbbBuilder sbbBuilder = objects.sbbBuilder; + sbbBuilder.begin(); world.setMask(this.section); + world.pushFakeLight(0); ModelBlockRenderer.enableCaching(); section.forEach(pos -> { BlockState state = world.getBlockState(pos); FluidState fluidState = world.getFluidState(pos); - poseStack.pushPose(); - poseStack.translate(pos.getX(), pos.getY(), pos.getZ()); + if (!fluidState.isEmpty() && ItemBlockRenderTypes.getRenderLayer(fluidState) == layer) { + // FIXME: The fluid renderer modulos translation to 0-15 on all axes, + // so fluids at positions outside this range will render at the wrong spot. + dispatcher.renderLiquid(pos, world, sbbBuilder.unwrap(true), state, fluidState); + } if (state.getRenderShape() == RenderShape.MODEL) { BakedModel model = dispatcher.getBlockModel(state); @@ -438,34 +434,27 @@ public class WorldSectionElement extends AnimatedSceneElement { modelData = model.getModelData(world, pos, state, modelData); long seed = state.getSeed(pos); random.setSeed(seed); + if (model.getRenderTypes(state, random, modelData).contains(layer)) { - renderer.tesselateBlock(world, model, state, pos, poseStack, shadeSeparatingWrapper, true, + poseStack.pushPose(); + poseStack.translate(pos.getX(), pos.getY(), pos.getZ()); + renderer.tesselateBlock(world, model, state, pos, poseStack, sbbBuilder, true, random, seed, OverlayTexture.NO_OVERLAY, modelData, layer); + poseStack.popPose(); } } - - if (!fluidState.isEmpty() && ItemBlockRenderTypes.getRenderLayer(fluidState) == layer) - dispatcher.renderLiquid(pos, world, shadedBuilder, state, fluidState); - - poseStack.popPose(); }); ModelBlockRenderer.clearCache(); + world.popLight(); world.clearMask(); - shadeSeparatingWrapper.clear(); - ShadeSeparatedBufferedData bufferedData = ModelUtil.endAndCombine(shadedBuilder, unshadedBuilder); - - SuperByteBuffer sbb = new SuperByteBuffer(bufferedData); - bufferedData.release(); - return sbb; + return sbbBuilder.end(); } private static class ThreadLocalObjects { public final PoseStack poseStack = new PoseStack(); public final RandomSource random = RandomSource.createNewThreadLocalInstance(); - public final ShadeSeparatingVertexConsumer shadeSeparatingWrapper = new ShadeSeparatingVertexConsumer(); - public final BufferBuilder shadedBuilder = new BufferBuilder(512); - public final BufferBuilder unshadedBuilder = new BufferBuilder(512); + public final ShadedBlockSbbBuilder sbbBuilder = new ShadedBlockSbbBuilder(); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java deleted file mode 100644 index bcdfc481e3..0000000000 --- a/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.simibubi.create.foundation.render; - -import com.jozufozu.flywheel.core.layout.BufferLayout; -import com.jozufozu.flywheel.core.layout.CommonItems; - -public class AllInstanceFormats { - - public static final BufferLayout ROTATING = kineticInstance() - .addItems(CommonItems.NORMAL) - .build(); - - public static final BufferLayout BELT = kineticInstance() - .addItems(CommonItems.QUATERNION, CommonItems.UV, CommonItems.VEC4, - CommonItems.NORMALIZED_BYTE) - .build(); - - public static final BufferLayout ACTOR = BufferLayout.builder() - .addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.FLOAT, - CommonItems.NORMAL, CommonItems.QUATERNION, CommonItems.NORMAL, - CommonItems.FLOAT) - .build(); - - public static final BufferLayout FLAP = BufferLayout.builder() - .addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.VEC3, CommonItems.VEC3, - CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT) - .build(); - - private static BufferLayout.Builder kineticInstance() { - return BufferLayout.builder() - .addItems(CommonItems.LIGHT, CommonItems.RGBA) - .addItems(CommonItems.VEC3, CommonItems.FLOAT, CommonItems.FLOAT); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java new file mode 100644 index 0000000000..7d1b430bb0 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java @@ -0,0 +1,191 @@ +package com.simibubi.create.foundation.render; + +import static com.simibubi.create.Create.asResource; + +import org.lwjgl.system.MemoryUtil; + +import com.simibubi.create.content.contraptions.actors.ActorInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.content.kinetics.belt.BeltInstance; +import com.simibubi.create.content.logistics.flwdata.FlapInstance; +import com.simibubi.create.content.processing.burner.ScrollInstance; + +import dev.engine_room.flywheel.api.instance.InstanceType; +import dev.engine_room.flywheel.api.layout.FloatRepr; +import dev.engine_room.flywheel.api.layout.IntegerRepr; +import dev.engine_room.flywheel.api.layout.LayoutBuilder; +import dev.engine_room.flywheel.lib.instance.SimpleInstanceType; +import dev.engine_room.flywheel.lib.util.ExtraMemoryOps; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public class AllInstanceTypes { + public static final InstanceType ROTATING = SimpleInstanceType.builder(RotatingInstance::new) + .cullShader(asResource("instance/cull/rotating.glsl")) + .vertexShader(asResource("instance/rotating.vert")) + .layout(LayoutBuilder.create() + .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) + .vector("light", IntegerRepr.SHORT, 2) + .vector("overlay", IntegerRepr.SHORT, 2) + .vector("pos", FloatRepr.FLOAT, 3) + .scalar("speed", FloatRepr.FLOAT) + .scalar("offset", FloatRepr.FLOAT) + .vector("axis", FloatRepr.NORMALIZED_BYTE, 3) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutByte(ptr, instance.red); + MemoryUtil.memPutByte(ptr + 1, instance.green); + MemoryUtil.memPutByte(ptr + 2, instance.blue); + MemoryUtil.memPutByte(ptr + 3, instance.alpha); + ExtraMemoryOps.put2x16(ptr + 4, instance.light); + ExtraMemoryOps.put2x16(ptr + 8, instance.overlay); + MemoryUtil.memPutFloat(ptr + 12, instance.x); + MemoryUtil.memPutFloat(ptr + 16, instance.y); + MemoryUtil.memPutFloat(ptr + 20, instance.z); + MemoryUtil.memPutFloat(ptr + 24, instance.rotationalSpeed); + MemoryUtil.memPutFloat(ptr + 28, instance.rotationOffset); + MemoryUtil.memPutByte(ptr + 32, instance.rotationAxisX); + MemoryUtil.memPutByte(ptr + 33, instance.rotationAxisY); + MemoryUtil.memPutByte(ptr + 34, instance.rotationAxisZ); + }) + .register(); + + public static final InstanceType BELT = SimpleInstanceType.builder(BeltInstance::new) + .cullShader(asResource("instance/cull/belt.glsl")) + .vertexShader(asResource("instance/belt.vert")) + .layout(LayoutBuilder.create() + .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) + .vector("light", IntegerRepr.SHORT, 2) + .vector("overlay", IntegerRepr.SHORT, 2) + .vector("pos", FloatRepr.FLOAT, 3) + .scalar("speed", FloatRepr.FLOAT) + .scalar("offset", FloatRepr.FLOAT) + .vector("rotation", FloatRepr.FLOAT, 4) + .vector("sourceTexture", FloatRepr.FLOAT, 2) + .vector("scrollTexture", FloatRepr.FLOAT, 4) + .scalar("scrollMult", FloatRepr.FLOAT) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutByte(ptr, instance.red); + MemoryUtil.memPutByte(ptr + 1, instance.green); + MemoryUtil.memPutByte(ptr + 2, instance.blue); + MemoryUtil.memPutByte(ptr + 3, instance.alpha); + ExtraMemoryOps.put2x16(ptr + 4, instance.light); + ExtraMemoryOps.put2x16(ptr + 8, instance.overlay); + MemoryUtil.memPutFloat(ptr + 12, instance.x); + MemoryUtil.memPutFloat(ptr + 16, instance.y); + MemoryUtil.memPutFloat(ptr + 20, instance.z); + MemoryUtil.memPutFloat(ptr + 24, instance.rotationalSpeed); + MemoryUtil.memPutFloat(ptr + 28, instance.rotationOffset); + ExtraMemoryOps.putQuaternionf(ptr + 32, instance.rotation); + MemoryUtil.memPutFloat(ptr + 48, instance.sourceU); + MemoryUtil.memPutFloat(ptr + 52, instance.sourceV); + MemoryUtil.memPutFloat(ptr + 56, instance.minU); + MemoryUtil.memPutFloat(ptr + 60, instance.minV); + MemoryUtil.memPutFloat(ptr + 64, instance.maxU); + MemoryUtil.memPutFloat(ptr + 68, instance.maxV); + MemoryUtil.memPutFloat(ptr + 72, instance.scrollMult); + }) + .register(); + + // TODO: use this for belts too + public static final InstanceType SCROLLING = SimpleInstanceType.builder(ScrollInstance::new) + .cullShader(asResource("instance/cull/scrolling.glsl")) + .vertexShader(asResource("instance/scrolling.vert")) + .layout(LayoutBuilder.create() + .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) + .vector("light", IntegerRepr.SHORT, 2) + .vector("overlay", IntegerRepr.SHORT, 2) + .vector("pos", FloatRepr.FLOAT, 3) + .vector("rotation", FloatRepr.FLOAT, 4) + .vector("speed", FloatRepr.FLOAT, 2) + .vector("diff", FloatRepr.FLOAT, 2) + .vector("scale", FloatRepr.FLOAT, 2) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutByte(ptr, instance.red); + MemoryUtil.memPutByte(ptr + 1, instance.green); + MemoryUtil.memPutByte(ptr + 2, instance.blue); + MemoryUtil.memPutByte(ptr + 3, instance.alpha); + ExtraMemoryOps.put2x16(ptr + 4, instance.light); + ExtraMemoryOps.put2x16(ptr + 8, instance.overlay); + MemoryUtil.memPutFloat(ptr + 12, instance.x); + MemoryUtil.memPutFloat(ptr + 16, instance.y); + MemoryUtil.memPutFloat(ptr + 20, instance.z); + ExtraMemoryOps.putQuaternionf(ptr + 24, instance.rotation); + MemoryUtil.memPutFloat(ptr + 40, instance.speedU); + MemoryUtil.memPutFloat(ptr + 44, instance.speedV); + MemoryUtil.memPutFloat(ptr + 48, instance.diffU); + MemoryUtil.memPutFloat(ptr + 52, instance.diffV); + MemoryUtil.memPutFloat(ptr + 56, instance.scaleU); + MemoryUtil.memPutFloat(ptr + 60, instance.scaleV); + }) + .register(); + + public static final InstanceType ACTOR = SimpleInstanceType.builder(ActorInstance::new) + .cullShader(asResource("instance/cull/actor.glsl")) + .vertexShader(asResource("instance/actor.vert")) + .layout(LayoutBuilder.create() + .vector("pos", FloatRepr.FLOAT, 3) + .vector("light", IntegerRepr.SHORT, 2) + .scalar("offset", FloatRepr.FLOAT) + .vector("axis", FloatRepr.NORMALIZED_BYTE, 3) + .vector("rotation", FloatRepr.FLOAT, 4) + .vector("rotationCenter", FloatRepr.NORMALIZED_BYTE, 3) + .scalar("speed", FloatRepr.FLOAT) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutFloat(ptr, instance.x); + MemoryUtil.memPutFloat(ptr + 4, instance.y); + MemoryUtil.memPutFloat(ptr + 8, instance.z); + MemoryUtil.memPutShort(ptr + 12, instance.blockLight); + MemoryUtil.memPutShort(ptr + 14, instance.skyLight); + MemoryUtil.memPutFloat(ptr + 16, instance.rotationOffset); + MemoryUtil.memPutByte(ptr + 20, instance.rotationAxisX); + MemoryUtil.memPutByte(ptr + 21, instance.rotationAxisY); + MemoryUtil.memPutByte(ptr + 22, instance.rotationAxisZ); + ExtraMemoryOps.putQuaternionf(ptr + 24, instance.rotation); + MemoryUtil.memPutByte(ptr + 40, instance.rotationCenterX); + MemoryUtil.memPutByte(ptr + 41, instance.rotationCenterY); + MemoryUtil.memPutByte(ptr + 42, instance.rotationCenterZ); + MemoryUtil.memPutFloat(ptr + 44, instance.speed); + }) + .register(); + + // TODO: remove + public static final InstanceType FLAP = SimpleInstanceType.builder(FlapInstance::new) + .cullShader(asResource("instance/cull/flap.glsl")) + .vertexShader(asResource("instance/flap.vert")) + .layout(LayoutBuilder.create() + .vector("instancePos", FloatRepr.FLOAT, 3) + .vector("light", IntegerRepr.SHORT, 2) + .vector("segmentOffset", FloatRepr.FLOAT, 3) + .vector("pivot", FloatRepr.FLOAT, 3) + .scalar("horizontalAngle", FloatRepr.FLOAT) + .scalar("intensity", FloatRepr.FLOAT) + .scalar("flapScale", FloatRepr.FLOAT) + .scalar("flapness", FloatRepr.FLOAT) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutFloat(ptr, instance.x); + MemoryUtil.memPutFloat(ptr + 4, instance.y); + MemoryUtil.memPutFloat(ptr + 8, instance.z); + ExtraMemoryOps.put2x16(ptr + 12, instance.packedLight); + MemoryUtil.memPutFloat(ptr + 16, instance.segmentOffsetX); + MemoryUtil.memPutFloat(ptr + 20, instance.segmentOffsetY); + MemoryUtil.memPutFloat(ptr + 24, instance.segmentOffsetZ); + MemoryUtil.memPutFloat(ptr + 28, instance.pivotX); + MemoryUtil.memPutFloat(ptr + 32, instance.pivotY); + MemoryUtil.memPutFloat(ptr + 36, instance.pivotZ); + MemoryUtil.memPutFloat(ptr + 40, instance.horizontalAngle); + MemoryUtil.memPutFloat(ptr + 44, instance.intensity); + MemoryUtil.memPutFloat(ptr + 48, instance.flapScale); + MemoryUtil.memPutFloat(ptr + 52, instance.flapness); + }) + .register(); + + public static void init() { + // noop + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java deleted file mode 100644 index 706d1284ae..0000000000 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.simibubi.create.foundation.render; - -import com.jozufozu.flywheel.api.struct.StructType; -import com.simibubi.create.Create; -import com.simibubi.create.content.contraptions.actors.flwdata.ActorData; -import com.simibubi.create.content.contraptions.actors.flwdata.ActorType; -import com.simibubi.create.content.kinetics.base.flwdata.BeltData; -import com.simibubi.create.content.kinetics.base.flwdata.BeltType; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingData; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingType; -import com.simibubi.create.content.logistics.flwdata.FlapData; -import com.simibubi.create.content.logistics.flwdata.FlapType; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -@OnlyIn(Dist.CLIENT) -public class AllMaterialSpecs { - - public static final StructType ROTATING = new RotatingType(); - public static final StructType BELTS = new BeltType(); - public static final StructType ACTORS = new ActorType(); - public static final StructType FLAPS = new FlapType(); - - public static class Locations { - public static final ResourceLocation ROTATING = Create.asResource("rotating"); - public static final ResourceLocation BELTS = Create.asResource("belts"); - public static final ResourceLocation ACTORS = Create.asResource("actors"); - public static final ResourceLocation FLAPS = Create.asResource("flaps"); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java deleted file mode 100644 index ccf81b94f5..0000000000 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.simibubi.create.foundation.render; - -import static com.simibubi.create.Create.asResource; - -import net.minecraft.resources.ResourceLocation; - -public class AllProgramSpecs { - - public static final ResourceLocation ROTATING = asResource("rotating"); - public static final ResourceLocation BELT = asResource("belt"); - public static final ResourceLocation FLAPS = asResource("flap"); - public static final ResourceLocation ACTOR = asResource("contraption_actor"); - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java deleted file mode 100644 index de4cb67bcc..0000000000 --- a/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.simibubi.create.foundation.render; - -import com.jozufozu.flywheel.core.model.ModelUtil; -import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferedData; -import com.mojang.blaze3d.vertex.PoseStack; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.world.level.block.state.BlockState; - -public class BakedModelRenderHelper { - - public static SuperByteBuffer standardBlockRender(BlockState renderedState) { - BlockRenderDispatcher dispatcher = Minecraft.getInstance() - .getBlockRenderer(); - return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState); - } - - public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState) { - return standardModelRender(model, referenceState, new PoseStack()); - } - - public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) { - ShadeSeparatedBufferedData data = ModelUtil.getBufferedData(model, referenceState, ms); - SuperByteBuffer sbb = new SuperByteBuffer(data); - data.release(); - return sbb; - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/BlockEntityRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/BlockEntityRenderHelper.java index 5185e7db11..43fd54a935 100644 --- a/src/main/java/com/simibubi/create/foundation/render/BlockEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/BlockEntityRenderHelper.java @@ -7,17 +7,16 @@ import javax.annotation.Nullable; import org.joml.Matrix4f; import org.joml.Vector4f; -import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; -import com.jozufozu.flywheel.config.BackendType; -import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.RegisteredObjects; +import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld; import com.simibubi.create.infrastructure.config.AllConfigs; +import dev.engine_room.flywheel.api.visualization.VisualizationManager; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; @@ -51,7 +50,7 @@ public class BlockEntityRenderHelper { Iterator iterator = customRenderBEs.iterator(); while (iterator.hasNext()) { BlockEntity blockEntity = iterator.next(); - if (Backend.getBackendType() == BackendType.INSTANCING && Backend.isFlywheelWorld(renderWorld) && InstancedRenderRegistry.shouldSkipRender(blockEntity)) + if (VisualizationManager.supportsVisualization(world) && VisualizationHelper.skipVanillaRender(blockEntity)) continue; BlockEntityRenderer renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(blockEntity); @@ -62,7 +61,7 @@ public class BlockEntityRenderHelper { BlockPos pos = blockEntity.getBlockPos(); ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(pos); try { diff --git a/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java b/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java index 791bf137eb..528dc7f91b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java +++ b/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java @@ -6,13 +6,13 @@ import java.util.function.Supplier; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.render.SuperByteBufferCache.Compartment; import com.simibubi.create.foundation.utility.AngleHelper; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.BlockState; @@ -27,18 +27,18 @@ public class CachedBufferer { } public static SuperByteBuffer block(Compartment compartment, BlockState toRender) { - return CreateClient.BUFFER_CACHE.get(compartment, toRender, () -> BakedModelRenderHelper.standardBlockRender(toRender)); + return CreateClient.BUFFER_CACHE.get(compartment, toRender, () -> VirtualRenderHelper.bufferBlock(toRender)); } public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState) { return CreateClient.BUFFER_CACHE.get(PARTIAL, partial, - () -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState)); + () -> VirtualRenderHelper.bufferModel(partial.get(), referenceState)); } public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState, Supplier modelTransform) { return CreateClient.BUFFER_CACHE.get(PARTIAL, partial, - () -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get())); + () -> VirtualRenderHelper.bufferModel(partial.get(), referenceState, modelTransform.get())); } public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState) { @@ -59,17 +59,17 @@ public class CachedBufferer { public static SuperByteBuffer partialDirectional(PartialModel partial, BlockState referenceState, Direction dir, Supplier modelTransform) { return CreateClient.BUFFER_CACHE.get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial), - () -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get())); + () -> VirtualRenderHelper.bufferModel(partial.get(), referenceState, modelTransform.get())); } public static Supplier rotateToFace(Direction facing) { return () -> { PoseStack stack = new PoseStack(); - TransformStack.cast(stack) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing)) - .unCentre(); + TransformStack.of(stack) + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing)) + .rotateXDegrees(AngleHelper.verticalAngle(facing)) + .uncenter(); return stack; }; } @@ -77,11 +77,11 @@ public class CachedBufferer { public static Supplier rotateToFaceVertical(Direction facing) { return () -> { PoseStack stack = new PoseStack(); - TransformStack.cast(stack) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing) + 90) - .unCentre(); + TransformStack.of(stack) + .center() + .rotateYDegrees(AngleHelper.horizontalAngle(facing)) + .rotateXDegrees(AngleHelper.verticalAngle(facing) + 90) + .uncenter(); return stack; }; } diff --git a/src/main/java/com/simibubi/create/foundation/render/ConditionalInstance.java b/src/main/java/com/simibubi/create/foundation/render/ConditionalInstance.java new file mode 100644 index 0000000000..c8c44b4c11 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/ConditionalInstance.java @@ -0,0 +1,68 @@ +package com.simibubi.create.foundation.render; + +import java.util.Optional; +import java.util.function.Consumer; + +import javax.annotation.Nullable; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.lib.instance.AbstractInstance; + +public class ConditionalInstance { + + final Instancer model; + ICondition condition; + + Consumer setupFunc; + + @Nullable + private D instance; + + public ConditionalInstance(Instancer model) { + this.model = model; + this.condition = () -> true; + } + + public ConditionalInstance withSetupFunc(Consumer setupFunc) { + this.setupFunc = setupFunc; + return this; + } + + public ConditionalInstance withCondition(ICondition condition) { + this.condition = condition; + return this; + } + + public ConditionalInstance update() { + boolean shouldShow = condition.shouldShow(); + if (shouldShow && instance == null) { + instance = model.createInstance(); + if (setupFunc != null) setupFunc.accept(instance); + } else if (!shouldShow && instance != null) { + instance.delete(); + instance = null; + } + + return this; + } + + public Optional get() { + return Optional.ofNullable(instance); + } + + public void delete() { + if (instance != null) instance.delete(); + } + + public void forEach(Consumer consumer) { + if (instance != null) { + consumer.accept(instance); + } + } + + @FunctionalInterface + public interface ICondition { + boolean shouldShow(); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java b/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java deleted file mode 100644 index bb651c8433..0000000000 --- a/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.simibubi.create.foundation.render; - -import com.jozufozu.flywheel.core.GameStateRegistry; -import com.jozufozu.flywheel.core.Templates; -import com.jozufozu.flywheel.core.compile.ProgramCompiler; -import com.jozufozu.flywheel.core.source.FileResolution; -import com.jozufozu.flywheel.core.source.Resolver; -import com.jozufozu.flywheel.event.GatherContextEvent; -import com.jozufozu.flywheel.util.ResourceUtil; -import com.simibubi.create.Create; -import com.simibubi.create.content.contraptions.render.ContraptionProgram; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -@OnlyIn(Dist.CLIENT) -public class CreateContexts { - private static final ResourceLocation CONTRAPTION = Create.asResource("context/contraption"); - - public static ProgramCompiler CWORLD; - public static ProgramCompiler STRUCTURE; - - public static void flwInit(GatherContextEvent event) { - GameStateRegistry.register(RainbowDebugStateProvider.INSTANCE); - FileResolution header = Resolver.INSTANCE.get(ResourceUtil.subPath(CONTRAPTION, ".glsl")); - - CWORLD = ProgramCompiler.create(Templates.INSTANCING, ContraptionProgram::new, header); - STRUCTURE = ProgramCompiler.create(Templates.ONE_SHOT, ContraptionProgram::new, header); - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/ForcedDiffuseState.java b/src/main/java/com/simibubi/create/foundation/render/ForcedDiffuseState.java deleted file mode 100644 index 5dd88fecdb..0000000000 --- a/src/main/java/com/simibubi/create/foundation/render/ForcedDiffuseState.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.simibubi.create.foundation.render; - -import javax.annotation.Nullable; - -import com.jozufozu.flywheel.util.DiffuseLightCalculator; - -import it.unimi.dsi.fastutil.objects.ObjectArrayList; - -public final class ForcedDiffuseState { - private static final ThreadLocal> FORCED_DIFFUSE = ThreadLocal.withInitial(ObjectArrayList::new); - - private ForcedDiffuseState() { - } - - public static void pushCalculator(DiffuseLightCalculator calculator) { - FORCED_DIFFUSE.get().push(calculator); - } - - public static void popCalculator() { - FORCED_DIFFUSE.get().pop(); - } - - @Nullable - public static DiffuseLightCalculator getForcedCalculator() { - ObjectArrayList stack = FORCED_DIFFUSE.get(); - if (stack.isEmpty()) { - return null; - } - return stack.top(); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/GroupInstance.java b/src/main/java/com/simibubi/create/foundation/render/GroupInstance.java new file mode 100644 index 0000000000..00255bd772 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/GroupInstance.java @@ -0,0 +1,84 @@ +package com.simibubi.create.foundation.render; + +import java.util.AbstractCollection; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import dev.engine_room.flywheel.api.instance.Instancer; +import dev.engine_room.flywheel.lib.instance.AbstractInstance; + +public class GroupInstance extends AbstractCollection { + + final Instancer model; + final List backing; + + public GroupInstance(Instancer model) { + this.model = model; + + this.backing = new ArrayList<>(); + } + + public GroupInstance(Instancer model, int size) { + this.model = model; + + this.backing = new ArrayList<>(size); + + for (int i = 0; i < size; i++) { + addInstance(); + } + } + + /** + * @param count + * @return True if the number of elements changed. + */ + public boolean resize(int count) { + int size = size(); + if (count == size) return false; + + if (count <= 0) { + clear(); + return size > 0; + } + + if (count > size) { + for (int i = size; i < count; i++) { + addInstance(); + } + } else { + List unnecessary = backing.subList(count, size); + unnecessary.forEach(AbstractInstance::delete); + unnecessary.clear(); + } + + return true; + } + + public D addInstance() { + D instance = model.createInstance(); + backing.add(instance); + + return instance; + } + + public D get(int index) { + return backing.get(index); + } + + @Override + public Iterator iterator() { + return backing.iterator(); + } + + @Override + public int size() { + return backing.size(); + } + + @Override + public void clear() { + backing.forEach(AbstractInstance::delete); + backing.clear(); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/MutableTemplateMesh.java b/src/main/java/com/simibubi/create/foundation/render/MutableTemplateMesh.java new file mode 100644 index 0000000000..4e13377b6d --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/MutableTemplateMesh.java @@ -0,0 +1,55 @@ +package com.simibubi.create.foundation.render; + +public class MutableTemplateMesh extends TemplateMesh { + public MutableTemplateMesh(int[] data) { + super(data); + } + + public MutableTemplateMesh(int vertexCount) { + super(vertexCount); + } + + public void copyFrom(int index, TemplateMesh template) { + System.arraycopy(template.data, 0, data, index * INT_STRIDE, template.data.length); + } + + public void x(int index, float x) { + data[index * INT_STRIDE + X_OFFSET] = Float.floatToRawIntBits(x); + } + + public void y(int index, float y) { + data[index * INT_STRIDE + Y_OFFSET] = Float.floatToRawIntBits(y); + } + + public void z(int index, float z) { + data[index * INT_STRIDE + Z_OFFSET] = Float.floatToRawIntBits(z); + } + + public void color(int index, int color) { + data[index * INT_STRIDE + COLOR_OFFSET] = color; + } + + public void u(int index, float u) { + data[index * INT_STRIDE + U_OFFSET] = Float.floatToRawIntBits(u); + } + + public void v(int index, float v) { + data[index * INT_STRIDE + V_OFFSET] = Float.floatToRawIntBits(v); + } + + public void overlay(int index, int overlay) { + data[index * INT_STRIDE + OVERLAY_OFFSET] = overlay; + } + + public void light(int index, int light) { + data[index * INT_STRIDE + LIGHT_OFFSET] = light; + } + + public void normal(int index, int normal) { + data[index * INT_STRIDE + NORMAL_OFFSET] = normal; + } + + public TemplateMesh toImmutable() { + return new TemplateMesh(data); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/RainbowDebugStateProvider.java b/src/main/java/com/simibubi/create/foundation/render/RainbowDebugStateProvider.java deleted file mode 100644 index 6212602258..0000000000 --- a/src/main/java/com/simibubi/create/foundation/render/RainbowDebugStateProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.simibubi.create.foundation.render; - -import javax.annotation.Nonnull; - -import com.jozufozu.flywheel.core.shader.GameStateProvider; -import com.jozufozu.flywheel.core.shader.ShaderConstants; -import com.simibubi.create.content.kinetics.KineticDebugger; - -public enum RainbowDebugStateProvider implements GameStateProvider { - INSTANCE; - - @Override - public boolean isTrue() { - return KineticDebugger.isActive(); - } - - @Override - public void alterConstants(@Nonnull ShaderConstants constants) { - constants.define("DEBUG_RAINBOW"); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java b/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java index 5a18d8298a..d0acb2cc3f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java +++ b/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java @@ -1,43 +1,104 @@ package com.simibubi.create.foundation.render; import java.io.IOException; +import java.util.function.BiFunction; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexFormat; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.Create; +import net.minecraft.Util; import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ResourceProvider; -import net.minecraft.world.inventory.InventoryMenu; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RegisterShadersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -// TODO 1.17: use custom shaders instead of vanilla ones public class RenderTypes extends RenderStateShard { - public static final RenderStateShard.ShaderStateShard GLOWING_SHADER = new RenderStateShard.ShaderStateShard(() -> Shaders.glowingShader); + private static final RenderType ENTITY_SOLID_BLOCK_MIPPED = RenderType.create(createLayerName("entity_solid_block_mipped"), + DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, + RenderType.CompositeState.builder() + .setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER) + .setTextureState(BLOCK_SHEET_MIPPED) + .setTransparencyState(NO_TRANSPARENCY) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + + private static final RenderType ENTITY_CUTOUT_BLOCK_MIPPED = RenderType.create(createLayerName("entity_cutout_block_mipped"), + DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, + RenderType.CompositeState.builder() + .setShaderState(RENDERTYPE_ENTITY_CUTOUT_SHADER) + .setTextureState(BLOCK_SHEET_MIPPED) + .setTransparencyState(NO_TRANSPARENCY) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + + private static final RenderType ENTITY_TRANSLUCENT_BLOCK_MIPPED = RenderType.create(createLayerName("entity_translucent_block_mipped"), + DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, + RenderType.CompositeState.builder() + .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER) + .setTextureState(BLOCK_SHEET_MIPPED) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + + private static final RenderType ADDITIVE = RenderType.create(createLayerName("additive"), DefaultVertexFormat.BLOCK, + VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder() + .setShaderState(RENDERTYPE_SOLID_SHADER) + .setTextureState(BLOCK_SHEET) + .setTransparencyState(ADDITIVE_TRANSPARENCY) + .setCullState(NO_CULL) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + + private static final RenderType FLUID = RenderType.create(createLayerName("fluid"), + DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, true, RenderType.CompositeState.builder() + .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER) + .setTextureState(BLOCK_SHEET_MIPPED) + .setCullState(NO_CULL) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + + private static final RenderType ITEM_GLOWING_SOLID = RenderType.create(createLayerName("item_glowing_solid"), + DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, RenderType.CompositeState.builder() + .setShaderState(GLOWING_SHADER) + .setTextureState(BLOCK_SHEET) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + + private static final RenderType ITEM_GLOWING_TRANSLUCENT = RenderType.create(createLayerName("item_glowing_translucent"), + DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder() + .setShaderState(GLOWING_SHADER) + .setTextureState(BLOCK_SHEET) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + private static final RenderType OUTLINE_SOLID = RenderType.create(createLayerName("outline_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, false, RenderType.CompositeState.builder() .setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER) .setTextureState(new RenderStateShard.TextureStateShard(AllSpecialTextures.BLANK.getLocation(), false, false)) - .setCullState(CULL) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(false)); - public static RenderType getOutlineSolid() { - return OUTLINE_SOLID; - } - - public static RenderType getOutlineTranslucent(ResourceLocation texture, boolean cull) { + private static final BiFunction OUTLINE_TRANSLUCENT = Util.memoize((texture, cull) -> { return RenderType.create(createLayerName("outline_translucent" + (cull ? "_cull" : "")), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, true, RenderType.CompositeState.builder() .setShaderState(cull ? RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER : RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) @@ -48,96 +109,44 @@ public class RenderTypes extends RenderStateShard { .setOverlayState(OVERLAY) .setWriteMaskState(COLOR_WRITE) .createCompositeState(false)); + }); + + public static RenderType entitySolidBlockMipped() { + return ENTITY_SOLID_BLOCK_MIPPED; } - public static RenderType getGlowingSolid(ResourceLocation texture) { - return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, - true, false, RenderType.CompositeState.builder() - .setShaderState(GLOWING_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(texture, false, false)) - .setCullState(CULL) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); + public static RenderType entityCutoutBlockMipped() { + return ENTITY_CUTOUT_BLOCK_MIPPED; } - private static final RenderType GLOWING_SOLID_DEFAULT = getGlowingSolid(InventoryMenu.BLOCK_ATLAS); - - public static RenderType getGlowingSolid() { - return GLOWING_SOLID_DEFAULT; + public static RenderType entityTranslucentBlockMipped() { + return ENTITY_TRANSLUCENT_BLOCK_MIPPED; } - public static RenderType getGlowingTranslucent(ResourceLocation texture) { - return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, - 256, true, true, RenderType.CompositeState.builder() - .setShaderState(GLOWING_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(texture, false, false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - } - - private static final RenderType ADDITIVE = RenderType.create(createLayerName("additive"), DefaultVertexFormat.BLOCK, - VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_SOLID_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(InventoryMenu.BLOCK_ATLAS, false, false)) - .setTransparencyState(ADDITIVE_TRANSPARENCY) - .setCullState(NO_CULL) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - - public static RenderType getAdditive() { + public static RenderType additive() { return ADDITIVE; } - private static final RenderType GLOWING_TRANSLUCENT_DEFAULT = getGlowingTranslucent(InventoryMenu.BLOCK_ATLAS); - - public static RenderType getGlowingTranslucent() { - return GLOWING_TRANSLUCENT_DEFAULT; - } - - private static final RenderType ITEM_PARTIAL_SOLID = - RenderType.create(createLayerName("item_partial_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, - false, RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER) - .setTextureState(BLOCK_SHEET) - .setCullState(CULL) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - - public static RenderType getItemPartialSolid() { - return ITEM_PARTIAL_SOLID; - } - - private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.create(createLayerName("item_partial_translucent"), - DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER) - .setTextureState(BLOCK_SHEET) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - - public static RenderType getItemPartialTranslucent() { - return ITEM_PARTIAL_TRANSLUCENT; - } - - private static final RenderType FLUID = RenderType.create(createLayerName("fluid"), - DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, true, RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER) - .setTextureState(BLOCK_SHEET_MIPPED) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true)); - - public static RenderType getFluid() { + public static RenderType fluid() { return FLUID; } + public static RenderType itemGlowingSolid() { + return ITEM_GLOWING_SOLID; + } + + public static RenderType itemGlowingTranslucent() { + return ITEM_GLOWING_TRANSLUCENT; + } + + public static RenderType outlineSolid() { + return OUTLINE_SOLID; + } + + public static RenderType outlineTranslucent(ResourceLocation texture, boolean cull) { + return OUTLINE_TRANSLUCENT.apply(texture, cull); + } + private static String createLayerName(String name) { return Create.ID + ":" + name; } @@ -157,5 +166,4 @@ public class RenderTypes extends RenderStateShard { event.registerShader(new ShaderInstance(resourceProvider, Create.asResource("glowing_shader"), DefaultVertexFormat.NEW_ENTITY), shader -> glowingShader = shader); } } - } diff --git a/src/main/java/com/simibubi/create/foundation/render/SelectInstance.java b/src/main/java/com/simibubi/create/foundation/render/SelectInstance.java new file mode 100644 index 0000000000..f638146d8e --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/SelectInstance.java @@ -0,0 +1,69 @@ +package com.simibubi.create.foundation.render; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Consumer; + +import javax.annotation.Nullable; + +import dev.engine_room.flywheel.api.instance.Instance; +import dev.engine_room.flywheel.api.instance.Instancer; + +public class SelectInstance { + + final List> models; + + ModelSelector selector; + + private int last = -1; + @Nullable + private D current; + + public SelectInstance(ModelSelector selector) { + this.models = new ArrayList<>(); + this.selector = selector; + } + + public SelectInstance addModel(Instancer model) { + models.add(model); + return this; + } + + public SelectInstance update() { + int i = selector.modelIndexToShow(); + + if (i < 0 || i >= models.size()) { + if (current != null) { + current.handle().setDeleted(); + current = null; + } + } else if (i != last) { + if (current != null) current.handle().setDeleted(); + + current = models.get(i) + .createInstance(); + } + + last = i; + return this; + } + + public Optional get() { + return Optional.ofNullable(current); + } + + public void delete() { + if (current != null) current.handle().setDeleted(); + } + + public void forEach(Consumer consumer) { + if (current != null) { + consumer.accept(current); + } + } + + public interface ModelSelector { + int modelIndexToShow(); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/ShadedBlockSbbBuilder.java b/src/main/java/com/simibubi/create/foundation/render/ShadedBlockSbbBuilder.java new file mode 100644 index 0000000000..aa212b4196 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/ShadedBlockSbbBuilder.java @@ -0,0 +1,126 @@ +package com.simibubi.create.foundation.render; + +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.VertexFormat; +import com.simibubi.create.foundation.mixin.accessor.BufferBuilderAccessor; + +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.client.renderer.block.model.BakedQuad; + +public class ShadedBlockSbbBuilder implements VertexConsumer { + protected final BufferBuilder bufferBuilder; + protected final IntList shadeSwapVertices = new IntArrayList(); + protected boolean currentShade; + + public ShadedBlockSbbBuilder(BufferBuilder bufferBuilder) { + this.bufferBuilder = bufferBuilder; + } + + public ShadedBlockSbbBuilder() { + this(new BufferBuilder(512)); + } + + public void begin() { + bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); + shadeSwapVertices.clear(); + currentShade = true; + } + + public SuperByteBuffer end() { + RenderedBuffer data = bufferBuilder.end(); + int vertexCount = data.drawState().vertexCount(); + MutableTemplateMesh mutableMesh = new MutableTemplateMesh(vertexCount); + VirtualRenderHelper.transferBlockVertexData(data.vertexBuffer(), data.drawState().format().getVertexSize(), 0, mutableMesh, 0, vertexCount); + return new SuperByteBuffer(mutableMesh.toImmutable(), shadeSwapVertices.toIntArray()); + } + + public BufferBuilder unwrap(boolean shade) { + prepareForGeometry(shade); + return bufferBuilder; + } + + private void prepareForGeometry(boolean shade) { + if (shade != currentShade) { + shadeSwapVertices.add(((BufferBuilderAccessor) bufferBuilder).create$getVertices()); + currentShade = shade; + } + } + + private void prepareForGeometry(BakedQuad quad) { + prepareForGeometry(quad.isShade()); + } + + @Override + public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, int light, int overlay) { + prepareForGeometry(quad); + bufferBuilder.putBulkData(pose, quad, red, green, blue, light, overlay); + } + + @Override + public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, float alpha, int light, int overlay, boolean readExistingColor) { + prepareForGeometry(quad); + bufferBuilder.putBulkData(pose, quad, red, green, blue, alpha, light, overlay, readExistingColor); + } + + @Override + public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float[] brightnesses, float red, float green, float blue, int[] lights, int overlay, boolean readExistingColor) { + prepareForGeometry(quad); + bufferBuilder.putBulkData(pose, quad, brightnesses, red, green, blue, lights, overlay, readExistingColor); + } + + @Override + public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float[] brightnesses, float red, float green, float blue, float alpha, int[] lights, int overlay, boolean readExistingColor) { + prepareForGeometry(quad); + bufferBuilder.putBulkData(pose, quad, brightnesses, red, green, blue, alpha, lights, overlay, readExistingColor); + } + + @Override + public VertexConsumer vertex(double x, double y, double z) { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public VertexConsumer color(int red, int green, int blue, int alpha) { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public VertexConsumer uv(float u, float v) { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public VertexConsumer overlayCoords(int u, int v) { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public VertexConsumer uv2(int u, int v) { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public VertexConsumer normal(float x, float y, float z) { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public void endVertex() { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public void defaultColor(int red, int green, int blue, int alpha) { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } + + @Override + public void unsetDefaultColor() { + throw new UnsupportedOperationException("ShadedBlockSbbBuilder only supports putBulkData!"); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/StitchedSprite.java b/src/main/java/com/simibubi/create/foundation/render/StitchedSprite.java new file mode 100644 index 0000000000..9f7ff99b8e --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/StitchedSprite.java @@ -0,0 +1,57 @@ +package com.simibubi.create.foundation.render; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraftforge.client.event.TextureStitchEvent; + +public class StitchedSprite { + private static final Map> ALL = new HashMap<>(); + + protected final ResourceLocation atlasLocation; + protected final ResourceLocation location; + protected TextureAtlasSprite sprite; + + public StitchedSprite(ResourceLocation atlas, ResourceLocation location) { + atlasLocation = atlas; + this.location = location; + ALL.computeIfAbsent(atlasLocation, $ -> new ArrayList<>()).add(this); + } + + public StitchedSprite(ResourceLocation location) { + this(InventoryMenu.BLOCK_ATLAS, location); + } + + public static void onTextureStitchPost(TextureStitchEvent.Post event) { + TextureAtlas atlas = event.getAtlas(); + ResourceLocation atlasLocation = atlas.location(); + List sprites = ALL.get(atlasLocation); + if (sprites != null) { + for (StitchedSprite sprite : sprites) { + sprite.loadSprite(atlas); + } + } + } + + protected void loadSprite(TextureAtlas atlas) { + sprite = atlas.getSprite(location); + } + + public ResourceLocation getAtlasLocation() { + return atlasLocation; + } + + public ResourceLocation getLocation() { + return location; + } + + public TextureAtlasSprite get() { + return sprite; + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index c79189aa1a..1f77d787c3 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -1,220 +1,186 @@ package com.simibubi.create.foundation.render; - -import java.nio.ByteBuffer; -import java.util.function.IntPredicate; - +import org.jetbrains.annotations.Nullable; import org.joml.Matrix3f; +import org.joml.Matrix3fc; import org.joml.Matrix4f; -import org.joml.Quaternionf; +import org.joml.Matrix4fc; +import org.joml.Quaternionfc; import org.joml.Vector3f; +import org.joml.Vector3fc; import org.joml.Vector4f; -import com.jozufozu.flywheel.api.vertex.ShadedVertexList; -import com.jozufozu.flywheel.api.vertex.VertexList; -import com.jozufozu.flywheel.backend.ShadersModHandler; -import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferedData; -import com.jozufozu.flywheel.core.vertex.BlockVertexList; -import com.jozufozu.flywheel.util.DiffuseLightCalculator; -import com.jozufozu.flywheel.util.transform.TStack; -import com.jozufozu.flywheel.util.transform.Transform; -import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; +import com.simibubi.create.foundation.mixin.accessor.RenderSystemAccessor; import com.simibubi.create.foundation.utility.Color; +import dev.engine_room.flywheel.lib.transform.TransformStack; +import dev.engine_room.flywheel.lib.util.ShadersModHandler; import it.unimi.dsi.fastutil.longs.Long2IntMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.util.Mth; -import net.minecraft.world.level.Level; +import net.minecraft.world.level.BlockAndTintGetter; -public class SuperByteBuffer implements Transform, TStack { +public class SuperByteBuffer implements TransformStack { + private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap(); - private final VertexList template; - private final IntPredicate shadedPredicate; + private final TemplateMesh template; + private final int[] shadeSwapVertices; - // Vertex Position + // Vertex Position and Normals private final PoseStack transforms = new PoseStack(); // Vertex Coloring - private boolean shouldColor; - private int r, g, b, a; - private boolean disableDiffuseMult; - private DiffuseLightCalculator diffuseCalculator; + private float r, g, b, a; + private boolean disableDiffuse; // Vertex Texture Coords + @Nullable private SpriteShiftFunc spriteShiftFunc; - // Vertex Overlay Color - private boolean hasOverlay; - private int overlay = OverlayTexture.NO_OVERLAY; + // Vertex Overlay + private boolean hasCustomOverlay; + private int overlay; - // Vertex Lighting - private boolean useWorldLight; - private Matrix4f lightTransform; + // Vertex Light private boolean hasCustomLight; - private int packedLightCoords; - private boolean hybridLight; + private int packedLight; + private boolean useLevelLight; + @Nullable + private BlockAndTintGetter levelWithLight; + @Nullable + private Matrix4f lightTransform; - // Vertex Normals - private boolean fullNormalTransform; + // Reused objects + private final Matrix4f modelMat = new Matrix4f(); + private final Matrix3f normalMat = new Matrix3f(); + private final Vector4f pos = new Vector4f(); + private final Vector3f normal = new Vector3f(); + private final Vector3f lightDir0 = new Vector3f(); + private final Vector3f lightDir1 = new Vector3f(); + private final ShiftOutput shiftOutput = new ShiftOutput(); + private final Vector4f lightPos = new Vector4f(); - // Temporary - private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap(); - - public SuperByteBuffer(ByteBuffer vertexBuffer, BufferBuilder.DrawState drawState, int unshadedStartVertex) { - int vertexCount = drawState.vertexCount(); - int stride = drawState.format().getVertexSize(); - - ShadedVertexList template = new BlockVertexList.Shaded(vertexBuffer, vertexCount, stride, unshadedStartVertex); - shadedPredicate = template::isShaded; + public SuperByteBuffer(TemplateMesh template, int[] shadeSwapVertices) { this.template = template; - - transforms.pushPose(); + this.shadeSwapVertices = shadeSwapVertices; + reset(); } - public SuperByteBuffer(ShadeSeparatedBufferedData data) { - this(data.vertexBuffer(), data.drawState(), data.unshadedStartVertex()); - } - - public SuperByteBuffer(ByteBuffer vertexBuffer, BufferBuilder.DrawState drawState) { - int vertexCount = drawState.vertexCount(); - int stride = drawState.format().getVertexSize(); - - template = new BlockVertexList(vertexBuffer, vertexCount, stride); - shadedPredicate = index -> true; - - transforms.pushPose(); + public SuperByteBuffer(TemplateMesh template) { + this(template, new int[0]); } public void renderInto(PoseStack input, VertexConsumer builder) { - if (isEmpty()) + if (isEmpty()) { return; + } - Matrix4f modelMat = new Matrix4f(input.last() + if (useLevelLight) { + WORLD_LIGHT_CACHE.clear(); + } + + Matrix4f modelMat = this.modelMat.set(input.last() .pose()); Matrix4f localTransforms = transforms.last() .pose(); modelMat.mul(localTransforms); - Matrix3f normalMat; - if (fullNormalTransform) { - normalMat = new Matrix3f(input.last() - .normal()); - Matrix3f localNormalTransforms = transforms.last() - .normal(); - normalMat.mul(localNormalTransforms); - } else { - normalMat = new Matrix3f(transforms.last() - .normal()); - } + Matrix3f normalMat = this.normalMat.set(input.last() + .normal()); + Matrix3f localNormalTransforms = transforms.last() + .normal(); + normalMat.mul(localNormalTransforms); - if (useWorldLight) { - WORLD_LIGHT_CACHE.clear(); - } + Vector4f pos = this.pos; + Vector3f normal = this.normal; + ShiftOutput shiftOutput = this.shiftOutput; + Vector3f lightDir0 = this.lightDir0; + Vector3f lightDir1 = this.lightDir1; + Vector4f lightPos = this.lightPos; - final Vector4f pos = new Vector4f(); - final Vector3f normal = new Vector3f(); - final Vector4f lightPos = new Vector4f(); - - DiffuseLightCalculator diffuseCalculator = ForcedDiffuseState.getForcedCalculator(); - final boolean disableDiffuseMult = - this.disableDiffuseMult || (ShadersModHandler.isShaderPackInUse() && diffuseCalculator == null); - if (diffuseCalculator == null) { - diffuseCalculator = this.diffuseCalculator; - if (diffuseCalculator == null) { - diffuseCalculator = DiffuseLightCalculator.forCurrentLevel(); + boolean applyDiffuse = !disableDiffuse && !ShadersModHandler.isShaderPackInUse(); + boolean shaded = true; + int shadeSwapIndex = 0; + int nextShadeSwapVertex = shadeSwapIndex < shadeSwapVertices.length ? shadeSwapVertices[shadeSwapIndex] : -1; + float unshadedDiffuse = 1; + if (applyDiffuse) { + lightDir0.set(RenderSystemAccessor.create$getShaderLightDirections()[0]).normalize(); + lightDir1.set(RenderSystemAccessor.create$getShaderLightDirections()[1]).normalize(); + if (shadeSwapVertices.length > 0) { + normal.set(0, 1, 0); + normal.mul(normalMat); + unshadedDiffuse = calculateDiffuse(normal, lightDir0, lightDir1); } } - final int vertexCount = template.getVertexCount(); + int vertexCount = template.vertexCount(); for (int i = 0; i < vertexCount; i++) { - float x = template.getX(i); - float y = template.getY(i); - float z = template.getZ(i); + if (i == nextShadeSwapVertex) { + shaded = !shaded; + shadeSwapIndex++; + nextShadeSwapVertex = shadeSwapIndex < shadeSwapVertices.length ? shadeSwapVertices[shadeSwapIndex] : -1; + } - pos.set(x, y, z, 1F); + float x = template.x(i); + float y = template.y(i); + float z = template.z(i); + pos.set(x, y, z, 1.0f); pos.mul(modelMat); - builder.vertex(pos.x(), pos.y(), pos.z()); - - float normalX = template.getNX(i); - float normalY = template.getNY(i); - float normalZ = template.getNZ(i); + int packedNormal = template.normal(i); + float normalX = ((byte) (packedNormal & 0xFF)) / 127.0f; + float normalY = ((byte) ((packedNormal >>> 8) & 0xFF)) / 127.0f; + float normalZ = ((byte) ((packedNormal >>> 16) & 0xFF)) / 127.0f; normal.set(normalX, normalY, normalZ); normal.mul(normalMat); - float nx = normal.x(); - float ny = normal.y(); - float nz = normal.z(); - byte r, g, b, a; - if (shouldColor) { - r = (byte) this.r; - g = (byte) this.g; - b = (byte) this.b; - a = (byte) this.a; - } else { - r = template.getR(i); - g = template.getG(i); - b = template.getB(i); - a = template.getA(i); - } - if (disableDiffuseMult) { - builder.color(r, g, b, a); - } else { - float instanceDiffuse = diffuseCalculator.getDiffuse(nx, ny, nz, shadedPredicate.test(i)); - int colorR = transformColor(r, instanceDiffuse); - int colorG = transformColor(g, instanceDiffuse); - int colorB = transformColor(b, instanceDiffuse); - builder.color(colorR, colorG, colorB, a); + int color = template.color(i); + float r = (color & 0xFF) / 255.0f * this.r; + float g = ((color >>> 8) & 0xFF) / 255.0f * this.g; + float b = ((color >>> 16) & 0xFF) / 255.0f * this.b; + float a = ((color >>> 24) & 0xFF) / 255.0f * this.a; + if (applyDiffuse) { + float diffuse = shaded ? calculateDiffuse(normal, lightDir0, lightDir1) : unshadedDiffuse; + r *= diffuse; + g *= diffuse; + b *= diffuse; } - float u = template.getU(i); - float v = template.getV(i); + float u = template.u(i); + float v = template.v(i); if (spriteShiftFunc != null) { - spriteShiftFunc.shift(builder, u, v); + spriteShiftFunc.shift(u, v, shiftOutput); + u = shiftOutput.u; + v = shiftOutput.v; + } + + int overlay; + if (hasCustomOverlay) { + overlay = this.overlay; } else { - builder.uv(u, v); + overlay = template.overlay(i); } - if (hasOverlay) { - builder.overlayCoords(overlay); + int light = template.light(i); + if (hasCustomLight) { + light = maxLight(light, packedLight); } - - int light; - if (useWorldLight) { + if (useLevelLight) { lightPos.set(((x - .5f) * 15 / 16f) + .5f, (y - .5f) * 15 / 16f + .5f, (z - .5f) * 15 / 16f + .5f, 1f); lightPos.mul(localTransforms); if (lightTransform != null) { lightPos.mul(lightTransform); } - - light = getLight(Minecraft.getInstance().level, lightPos); - if (hasCustomLight) { - light = maxLight(light, packedLightCoords); - } - } else if (hasCustomLight) { - light = packedLightCoords; - } else { - light = template.getLight(i); + light = maxLight(light, getLight(levelWithLight, lightPos)); } - if (hybridLight) { - builder.uv2(maxLight(light, template.getLight(i))); - } else { - builder.uv2(light); - } - - builder.normal(nx, ny, nz); - - builder.endVertex(); + builder.vertex(pos.x(), pos.y(), pos.z(), r, g, b, a, u, v, overlay, light, normal.x(), normal.y(), normal.z()); } reset(); @@ -225,22 +191,19 @@ public class SuperByteBuffer implements Transform, TStack, TStack, TStack, TStack> 16) & 0xFF); - g = ((color >> 8) & 0xFF); - b = (color & 0xFF); - a = 255; + color((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, 255); return this; } @@ -348,34 +285,24 @@ public class SuperByteBuffer implements Transform, TStack { - builder.uv(entry.getTargetU(u), entry.getTargetV(v)); + spriteShiftFunc = (u, v, output) -> { + output.accept(entry.getTargetU(u), entry.getTargetV(v)); }; return this; } public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollV) { - return this.shiftUVScrolling(entry, 0, scrollV); + return shiftUVScrolling(entry, 0, scrollV); } public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollU, float scrollV) { - this.spriteShiftFunc = (builder, u, v) -> { + spriteShiftFunc = (u, v, output) -> { float targetU = u - entry.getOriginal() .getU0() + entry.getTarget() .getU0() @@ -384,90 +311,47 @@ public class SuperByteBuffer implements Transform, TStack { + spriteShiftFunc = (u, v, output) -> { float targetU = entry.getTarget() .getU((SpriteShiftEntry.getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16); float targetV = entry.getTarget() .getV((SpriteShiftEntry.getUnInterpolatedV(entry.getOriginal(), v) / sheetSize) + vTarget * 16); - builder.uv(targetU, targetV); + output.accept(targetU, targetV); }; return this; } - public SuperByteBuffer overlay() { - hasOverlay = true; - return this; - } - public SuperByteBuffer overlay(int overlay) { - hasOverlay = true; + hasCustomOverlay = true; this.overlay = overlay; return this; } - public SuperByteBuffer light() { - useWorldLight = true; + public SuperByteBuffer light(int packedLight) { + hasCustomLight = true; + this.packedLight = packedLight; return this; } - public SuperByteBuffer light(Matrix4f lightTransform) { - useWorldLight = true; + public SuperByteBuffer useLevelLight(BlockAndTintGetter level) { + useLevelLight = true; + levelWithLight = level; + return this; + } + + public SuperByteBuffer useLevelLight(BlockAndTintGetter level, Matrix4f lightTransform) { + useLevelLight = true; + levelWithLight = level; this.lightTransform = lightTransform; return this; } - public SuperByteBuffer light(int packedLightCoords) { - hasCustomLight = true; - this.packedLightCoords = packedLightCoords; - return this; - } - - public SuperByteBuffer light(Matrix4f lightTransform, int packedLightCoords) { - light(lightTransform); - light(packedLightCoords); - return this; - } - - /** - * Uses max light from calculated light (world light or custom light) and vertex - * light for the final light value. Ineffective if any other light method was - * not called. - */ - public SuperByteBuffer hybridLight() { - hybridLight = true; - return this; - } - - /** - * Transforms normals not only by the local matrix stack, but also by the passed - * matrix stack. - */ - public SuperByteBuffer fullNormalTransform() { - fullNormalTransform = true; - return this; - } - - public SuperByteBuffer forEntityRender() { - disableDiffuse(); - overlay(); - fullNormalTransform(); - return this; - } - - public static int transformColor(byte component, float scale) { - return Mth.clamp((int) (Byte.toUnsignedInt(component) * scale), 0, 255); - } - - public static int transformColor(int component, float scale) { - return Mth.clamp((int) (component * scale), 0, 255); - } - public static int maxLight(int packedLight1, int packedLight2) { int blockLight1 = LightTexture.block(packedLight1); int skyLight1 = LightTexture.sky(packedLight1); @@ -476,19 +360,35 @@ public class SuperByteBuffer implements Transform, TStack LevelRenderer.getLightColor(world, pos)); } @FunctionalInterface public interface SpriteShiftFunc { - void shift(VertexConsumer builder, float u, float v); + void shift(float u, float v, Output output); + + interface Output { + void accept(float u, float v); + } } - @FunctionalInterface - public interface VertexLighter { - int getPackedLight(float x, float y, float z); - } + private class ShiftOutput implements SpriteShiftFunc.Output { + public float u; + public float v; + @Override + public void accept(float u, float v) { + this.u = u; + this.v = v; + } + }; } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java index c66b7b5e5c..f11ea9b945 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java @@ -15,14 +15,12 @@ public class SuperByteBufferCache { public synchronized void registerCompartment(Compartment compartment) { caches.put(compartment, CacheBuilder.newBuilder() - .removalListener(n -> n.getValue().delete()) .build()); } public synchronized void registerCompartment(Compartment compartment, long ticksUntilExpired) { caches.put(compartment, CacheBuilder.newBuilder() .expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS) - .removalListener(n -> n.getValue().delete()) .build()); } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java index 57716c3824..0933e1c4eb 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java @@ -79,10 +79,12 @@ public class SuperRenderTypeBuffer implements MultiBufferSource { put(map, RenderType.entityGlint()); put(map, RenderType.entityGlintDirect()); put(map, RenderType.waterMask()); - put(map, RenderTypes.getOutlineSolid()); ModelBakery.DESTROY_TYPES.forEach((p_173062_) -> { put(map, p_173062_); }); + + // extras + put(map, RenderTypes.outlineSolid()); }); private final MultiBufferSource.BufferSource bufferSource = MultiBufferSource.immediateWithBuffers(fixedBuffers, new BufferBuilder(256)); diff --git a/src/main/java/com/simibubi/create/foundation/render/TemplateMesh.java b/src/main/java/com/simibubi/create/foundation/render/TemplateMesh.java new file mode 100644 index 0000000000..190682a449 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/TemplateMesh.java @@ -0,0 +1,78 @@ +package com.simibubi.create.foundation.render; + +public class TemplateMesh { + public static final int INT_STRIDE = 9; + public static final int BYTE_STRIDE = INT_STRIDE * Integer.BYTES; + + public static final int X_OFFSET = 0; + public static final int Y_OFFSET = 1; + public static final int Z_OFFSET = 2; + public static final int COLOR_OFFSET = 3; + public static final int U_OFFSET = 4; + public static final int V_OFFSET = 5; + public static final int OVERLAY_OFFSET = 6; + public static final int LIGHT_OFFSET = 7; + public static final int NORMAL_OFFSET = 8; + + protected final int[] data; + protected final int vertexCount; + + public TemplateMesh(int[] data) { + if (data.length % INT_STRIDE != 0) { + throw new IllegalArgumentException("Received invalid vertex data"); + } + + this.data = data; + vertexCount = data.length / INT_STRIDE; + } + + public TemplateMesh(int vertexCount) { + data = new int[vertexCount * INT_STRIDE]; + this.vertexCount = vertexCount; + } + + public float x(int index) { + return Float.intBitsToFloat(data[index * INT_STRIDE + X_OFFSET]); + } + + public float y(int index) { + return Float.intBitsToFloat(data[index * INT_STRIDE + Y_OFFSET]); + } + + public float z(int index) { + return Float.intBitsToFloat(data[index * INT_STRIDE + Z_OFFSET]); + } + + // 0xAABBGGRR + public int color(int index) { + return data[index * INT_STRIDE + COLOR_OFFSET]; + } + + public float u(int index) { + return Float.intBitsToFloat(data[index * INT_STRIDE + U_OFFSET]); + } + + public float v(int index) { + return Float.intBitsToFloat(data[index * INT_STRIDE + V_OFFSET]); + } + + public int overlay(int index) { + return data[index * INT_STRIDE + OVERLAY_OFFSET]; + } + + public int light(int index) { + return data[index * INT_STRIDE + LIGHT_OFFSET]; + } + + public int normal(int index) { + return data[index * INT_STRIDE + NORMAL_OFFSET]; + } + + public int vertexCount() { + return vertexCount; + } + + public boolean isEmpty() { + return vertexCount == 0; + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/VirtualRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/VirtualRenderHelper.java new file mode 100644 index 0000000000..7099e537da --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/VirtualRenderHelper.java @@ -0,0 +1,92 @@ +package com.simibubi.create.foundation.render; + +import java.nio.ByteBuffer; + +import org.jetbrains.annotations.Nullable; + +import com.mojang.blaze3d.vertex.PoseStack; + +import dev.engine_room.flywheel.api.model.Model; +import dev.engine_room.flywheel.lib.model.ModelCache; +import dev.engine_room.flywheel.lib.model.ModelUtil; +import dev.engine_room.flywheel.lib.model.baked.ForgeBakedModelBuilder; +import dev.engine_room.flywheel.lib.model.baked.VirtualEmptyBlockGetter; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.block.ModelBlockRenderer; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.model.data.ModelData; +import net.minecraftforge.client.model.data.ModelProperty; + +public class VirtualRenderHelper { + public static final ModelProperty VIRTUAL_PROPERTY = new ModelProperty<>(); + public static final ModelData VIRTUAL_DATA = ModelData.builder().with(VIRTUAL_PROPERTY, true).build(); + + private static final ModelCache VIRTUAL_BLOCKS = new ModelCache<>(state -> new ForgeBakedModelBuilder(ModelUtil.VANILLA_RENDERER.getBlockModel(state)).modelData(VIRTUAL_DATA).build()); + private static final ThreadLocal THREAD_LOCAL_OBJECTS = ThreadLocal.withInitial(ThreadLocalObjects::new); + + public static boolean isVirtual(ModelData data) { + return data.has(VirtualRenderHelper.VIRTUAL_PROPERTY) && data.get(VirtualRenderHelper.VIRTUAL_PROPERTY); + } + + /** + * A copy of {@link dev.engine_room.flywheel.lib.model.Models#block(BlockState)}, but with virtual model data passed in. + * @param state The block state to get the model for. + * @return The model for the given block state. + */ + public static Model blockModel(BlockState state) { + return VIRTUAL_BLOCKS.get(state); + } + + public static SuperByteBuffer bufferBlock(BlockState state) { + return bufferModel(ModelUtil.VANILLA_RENDERER.getBlockModel(state), state); + } + + public static SuperByteBuffer bufferModel(BakedModel model, BlockState state) { + return bufferModel(model, state, null); + } + + public static SuperByteBuffer bufferModel(BakedModel model, BlockState state, @Nullable PoseStack poseStack) { + BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER; + ModelBlockRenderer renderer = dispatcher.getModelRenderer(); + ThreadLocalObjects objects = THREAD_LOCAL_OBJECTS.get(); + + if (poseStack == null) { + poseStack = objects.identityPoseStack; + } + RandomSource random = objects.random; + + ShadedBlockSbbBuilder sbbBuilder = objects.sbbBuilder; + sbbBuilder.begin(); + + ModelData modelData = model.getModelData(VirtualEmptyBlockGetter.FULL_DARK, BlockPos.ZERO, state, VIRTUAL_DATA); + poseStack.pushPose(); + renderer.tesselateBlock(VirtualEmptyBlockGetter.FULL_DARK, model, state, BlockPos.ZERO, poseStack, sbbBuilder, false, random, 42L, OverlayTexture.NO_OVERLAY, modelData, null); + poseStack.popPose(); + + return sbbBuilder.end(); + } + + public static void transferBlockVertexData(ByteBuffer vertexBuffer, int stride, int srcIndex, MutableTemplateMesh mutableMesh, int dstIndex, int vertexCount) { + for (int i = 0; i < vertexCount; i++) { + mutableMesh.x(dstIndex + i, vertexBuffer.getFloat(srcIndex + i * stride)); + mutableMesh.y(dstIndex + i, vertexBuffer.getFloat(srcIndex + i * stride + 4)); + mutableMesh.z(dstIndex + i, vertexBuffer.getFloat(srcIndex + i * stride + 8)); + mutableMesh.color(dstIndex + i, vertexBuffer.getInt(srcIndex + i * stride + 12)); + mutableMesh.u(dstIndex + i, vertexBuffer.getFloat(srcIndex + i * stride + 16)); + mutableMesh.v(dstIndex + i, vertexBuffer.getFloat(srcIndex + i * stride + 20)); + mutableMesh.overlay(dstIndex + i, OverlayTexture.NO_OVERLAY); + mutableMesh.light(dstIndex + i, vertexBuffer.getInt(srcIndex + i * stride + 24)); + mutableMesh.normal(dstIndex + i, vertexBuffer.getInt(srcIndex + i * stride + 28)); + } + } + + private static class ThreadLocalObjects { + public final PoseStack identityPoseStack = new PoseStack(); + public final RandomSource random = RandomSource.createNewThreadLocalInstance(); + public final ShadedBlockSbbBuilder sbbBuilder = new ShadedBlockSbbBuilder(); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java index b946df03a9..097bef997e 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java @@ -4,11 +4,11 @@ import java.util.List; import javax.annotation.Nullable; -import com.jozufozu.flywheel.core.model.ModelUtil; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.foundation.placement.PlacementHelpers; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LevelRenderer; @@ -60,10 +60,10 @@ public abstract class GhostBlockRenderer { ms.pushPose(); ms.translate(pos.getX() - camera.x, pos.getY() - camera.y, pos.getZ() - camera.z); - for (RenderType layer : model.getRenderTypes(state, RandomSource.create(42L), ModelUtil.VIRTUAL_DATA)) { + for (RenderType layer : model.getRenderTypes(state, RandomSource.create(42L), VirtualRenderHelper.VIRTUAL_DATA)) { VertexConsumer vb = buffer.getEarlyBuffer(layer); renderer.renderModel(ms.last(), vb, state, model, 1f, 1f, 1f, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, - ModelUtil.VIRTUAL_DATA, layer); + VirtualRenderHelper.VIRTUAL_DATA, layer); } ms.popPose(); @@ -95,7 +95,7 @@ public abstract class GhostBlockRenderer { renderModel(ms.last(), vb, state, model, 1f, 1f, 1f, alpha, LevelRenderer.getLightColor(mc.level, pos), OverlayTexture.NO_OVERLAY, - ModelUtil.VIRTUAL_DATA, layer); + VirtualRenderHelper.VIRTUAL_DATA, layer); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java index fb39c0792e..d392d51475 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java @@ -6,7 +6,6 @@ import javax.annotation.Nullable; import org.joml.Matrix3f; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllSpecialTextures; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.Direction; @@ -47,9 +47,10 @@ public abstract class Outline { .length(); float vAngle = AngleHelper.deg(Mth.atan2(hDistance, diff.y)) - 90; ms.pushPose(); - TransformStack.cast(ms) + TransformStack.of(ms) .translate(start) - .rotateY(hAngle).rotateX(vAngle); + .rotateYDegrees(hAngle) + .rotateXDegrees(vAngle); renderAACuboidLine(ms, buffer, Vec3.ZERO, new Vec3(0, 0, diff.length())); ms.popPose(); } @@ -59,7 +60,7 @@ public abstract class Outline { if (lineWidth == 0) return; - VertexConsumer builder = buffer.getBuffer(RenderTypes.getOutlineSolid()); + VertexConsumer builder = buffer.getBuffer(RenderTypes.outlineSolid()); Vec3 diff = end.subtract(start); if (diff.x + diff.y + diff.z < 0) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedBlockAndTintGetter.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedBlockAndTintGetter.java new file mode 100644 index 0000000000..27e3a8370a --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedBlockAndTintGetter.java @@ -0,0 +1,58 @@ +package com.simibubi.create.foundation.utility.worldWrappers; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.ColorResolver; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.FluidState; + +public class WrappedBlockAndTintGetter implements BlockAndTintGetter { + protected final BlockAndTintGetter wrapped; + + public WrappedBlockAndTintGetter(BlockAndTintGetter wrapped) { + this.wrapped = wrapped; + } + + @Override + public BlockEntity getBlockEntity(BlockPos pos) { + return wrapped.getBlockEntity(pos); + } + + @Override + public BlockState getBlockState(BlockPos pos) { + return wrapped.getBlockState(pos); + } + + @Override + public FluidState getFluidState(BlockPos pos) { + return wrapped.getFluidState(pos); + } + + @Override + public int getHeight() { + return wrapped.getHeight(); + } + + @Override + public int getMinBuildHeight() { + return wrapped.getMinBuildHeight(); + } + + @Override + public float getShade(Direction pDirection, boolean pShade) { + return wrapped.getShade(pDirection, pShade); + } + + @Override + public LevelLightEngine getLightEngine() { + return wrapped.getLightEngine(); + } + + @Override + public int getBlockTint(BlockPos pBlockPos, ColorResolver pColorResolver) { + return wrapped.getBlockTint(pBlockPos, pColorResolver); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunk.java b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunk.java new file mode 100644 index 0000000000..0dbee6357c --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunk.java @@ -0,0 +1,239 @@ +package com.simibubi.create.foundation.virtualWorld; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.BiPredicate; + +import javax.annotation.Nullable; + +import it.unimi.dsi.fastutil.longs.LongSet; +import it.unimi.dsi.fastutil.longs.LongSets; +import it.unimi.dsi.fastutil.shorts.ShortList; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.UpgradeData; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.StructureStart; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.ticks.BlackholeTickAccess; +import net.minecraft.world.ticks.TickContainerAccess; + +public class VirtualChunk extends ChunkAccess { + public final VirtualRenderWorld world; + + private final VirtualChunkSection[] sections; + + private boolean needsLight; + + public VirtualChunk(VirtualRenderWorld world, int x, int z) { + super(new ChunkPos(x, z), UpgradeData.EMPTY, world, world.registryAccess() + .registryOrThrow(Registries.BIOME), 0L, null, null); + + this.world = world; + + int sectionCount = world.getSectionsCount(); + this.sections = new VirtualChunkSection[sectionCount]; + + for (int i = 0; i < sectionCount; i++) { + sections[i] = new VirtualChunkSection(this, i << 4); + } + + this.needsLight = true; + +// Mods.STARLIGHT.executeIfInstalled(() -> () -> { +// ((ExtendedChunk) this).setBlockNibbles(StarLightEngine.getFilledEmptyLight(this)); +// ((ExtendedChunk) this).setSkyNibbles(StarLightEngine.getFilledEmptyLight(this)); +// }); + } + + @Override + @Nullable + public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving) { + return null; + } + + @Override + public void setBlockEntity(BlockEntity blockEntity) { + } + + @Override + public void addEntity(Entity entity) { + } + + @Override + public Set getBlockEntitiesPos() { + return Collections.emptySet(); + } + + @Override + public LevelChunkSection[] getSections() { + return sections; + } + + @Override + public Collection> getHeightmaps() { + return Collections.emptySet(); + } + + @Override + public void setHeightmap(Heightmap.Types type, long[] data) { + } + + @Override + public Heightmap getOrCreateHeightmapUnprimed(Heightmap.Types type) { + return null; + } + + @Override + public int getHeight(Heightmap.Types type, int x, int z) { + return 0; + } + + @Override + @Nullable + public StructureStart getStartForStructure(Structure structure) { + return null; + } + + @Override + public void setStartForStructure(Structure structure, StructureStart structureStart) { + } + + @Override + public Map getAllStarts() { + return Collections.emptyMap(); + } + + @Override + public void setAllStarts(Map structureStarts) { + } + + @Override + public LongSet getReferencesForStructure(Structure pStructure) { + return LongSets.emptySet(); + } + + @Override + public void addReferenceForStructure(Structure structure, long reference) { + } + + @Override + public Map getAllReferences() { + return Collections.emptyMap(); + } + + @Override + public void setAllReferences(Map structureReferencesMap) { + } + + @Override + public void setUnsaved(boolean unsaved) { + } + + @Override + public boolean isUnsaved() { + return false; + } + + @Override + public ChunkStatus getStatus() { + return ChunkStatus.LIGHT; + } + + @Override + public void removeBlockEntity(BlockPos pos) { + } + + @Override + public ShortList[] getPostProcessing() { + return new ShortList[0]; + } + + @Override + @Nullable + public CompoundTag getBlockEntityNbt(BlockPos pos) { + return null; + } + + @Override + @Nullable + public CompoundTag getBlockEntityNbtForSaving(BlockPos pos) { + return null; + } + + @Override + public void findBlocks(BiPredicate predicate, BiConsumer consumer) { + world.blockStates.forEach((pos, state) -> { + if (SectionPos.blockToSectionCoord(pos.getX()) == chunkPos.x && SectionPos.blockToSectionCoord(pos.getZ()) == chunkPos.z) { + if (predicate.test(state, pos)) { + consumer.accept(pos, state); + } + } + }); + } + + @Override + public TickContainerAccess getBlockTicks() { + return BlackholeTickAccess.emptyContainer(); + } + + @Override + public TickContainerAccess getFluidTicks() { + return BlackholeTickAccess.emptyContainer(); + } + + @Override + public TicksToSave getTicksForSerialization() { + throw new UnsupportedOperationException(); + } + + @Override + public long getInhabitedTime() { + return 0; + } + + @Override + public void setInhabitedTime(long amount) { + } + + @Override + public boolean isLightCorrect() { + return needsLight; + } + + @Override + public void setLightCorrect(boolean lightCorrect) { + this.needsLight = lightCorrect; + } + + @Override + @Nullable + public BlockEntity getBlockEntity(BlockPos pos) { + return world.getBlockEntity(pos); + } + + @Override + public BlockState getBlockState(BlockPos pos) { + return world.getBlockState(pos); + } + + @Override + public FluidState getFluidState(BlockPos pos) { + return world.getFluidState(pos); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunkSection.java b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunkSection.java new file mode 100644 index 0000000000..f47c31a776 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunkSection.java @@ -0,0 +1,42 @@ +package com.simibubi.create.foundation.virtualWorld; + +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.material.FluidState; + +public class VirtualChunkSection extends LevelChunkSection { + public final VirtualChunk owner; + + public final int xStart; + public final int yStart; + public final int zStart; + + public VirtualChunkSection(VirtualChunk owner, int yBase) { + super(owner.world.registryAccess() + .registryOrThrow(Registries.BIOME)); + this.owner = owner; + this.xStart = owner.getPos() + .getMinBlockX(); + this.yStart = yBase; + this.zStart = owner.getPos() + .getMinBlockZ(); + } + + @Override + public BlockState getBlockState(int x, int y, int z) { + // ChunkSection#getBlockState expects local chunk coordinates, so we add to get + // back into world coords. + return owner.world.getBlockState(x + xStart, y + yStart, z + zStart); + } + + @Override + public FluidState getFluidState(int x, int y, int z) { + return getBlockState(x, y, z).getFluidState(); + } + + @Override + public BlockState setBlockState(int x, int y, int z, BlockState state, boolean useLocks) { + throw new UnsupportedOperationException("Chunk sections cannot be mutated in a fake world."); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunkSource.java b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunkSource.java new file mode 100644 index 0000000000..bcd9b35748 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualChunkSource.java @@ -0,0 +1,65 @@ +package com.simibubi.create.foundation.virtualWorld; + +import java.util.function.BooleanSupplier; + +import org.jetbrains.annotations.Nullable; + +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkSource; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.lighting.LevelLightEngine; + +public class VirtualChunkSource extends ChunkSource { + private final VirtualRenderWorld world; + private final Long2ObjectMap chunks = new Long2ObjectOpenHashMap<>(); + + public VirtualChunkSource(VirtualRenderWorld world) { + this.world = world; + } + + @Override + public Level getLevel() { + return world; + } + + public ChunkAccess getChunk(int x, int z) { + long pos = ChunkPos.asLong(x, z); + return chunks.computeIfAbsent(pos, $ -> new VirtualChunk(world, x, z)); + } + + @Override + @Nullable + public LevelChunk getChunk(int x, int z, boolean load) { + return null; + } + + @Override + @Nullable + public ChunkAccess getChunk(int x, int z, ChunkStatus status, boolean load) { + return getChunk(x, z); + } + + @Override + public void tick(BooleanSupplier hasTimeLeft, boolean tickChunks) { + } + + @Override + public String gatherStats() { + return "VirtualChunkSource"; + } + + @Override + public int getLoadedChunksCount() { + return 0; + } + + @Override + public LevelLightEngine getLightEngine() { + return world.getLightEngine(); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualLevelEntityGetter.java b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualLevelEntityGetter.java new file mode 100644 index 0000000000..7656ecdd8a --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualLevelEntityGetter.java @@ -0,0 +1,40 @@ +package com.simibubi.create.foundation.virtualWorld; + +import java.util.Collections; +import java.util.UUID; +import java.util.function.Consumer; + +import net.minecraft.util.AbortableIterationConsumer; +import net.minecraft.world.level.entity.EntityAccess; +import net.minecraft.world.level.entity.EntityTypeTest; +import net.minecraft.world.level.entity.LevelEntityGetter; +import net.minecraft.world.phys.AABB; + +public class VirtualLevelEntityGetter implements LevelEntityGetter { + @Override + public T get(int id) { + return null; + } + + @Override + public T get(UUID uuid) { + return null; + } + + @Override + public Iterable getAll() { + return Collections.emptyList(); + } + + @Override + public void get(EntityTypeTest test, AbortableIterationConsumer consumer) { + } + + @Override + public void get(AABB boundingBox, Consumer consumer) { + } + + @Override + public void get(EntityTypeTest test, AABB bounds, AbortableIterationConsumer consumer) { + } +} diff --git a/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualRenderWorld.java b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualRenderWorld.java new file mode 100644 index 0000000000..2eddcd9d7d --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/virtualWorld/VirtualRenderWorld.java @@ -0,0 +1,459 @@ +package com.simibubi.create.foundation.virtualWorld; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Nullable; + +import dev.engine_room.flywheel.api.visualization.VisualizationLevel; +import it.unimi.dsi.fastutil.objects.Object2ShortMap; +import it.unimi.dsi.fastutil.objects.Object2ShortOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Holder; +import net.minecraft.core.SectionPos; +import net.minecraft.core.Vec3i; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.flag.FeatureFlagSet; +import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.BiomeManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkSource; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.entity.LevelEntityGetter; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.level.gameevent.GameEvent.Context; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.saveddata.maps.MapItemSavedData; +import net.minecraft.world.level.storage.WritableLevelData; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.scores.Scoreboard; +import net.minecraft.world.ticks.LevelTickAccess; + +public class VirtualRenderWorld extends Level implements VisualizationLevel { + protected final Level level; + protected final int minBuildHeight; + protected final int height; + protected final Vec3i biomeOffset; + + protected final VirtualChunkSource chunkSource; + protected final LevelLightEngine lightEngine; + + protected final Map blockStates = new HashMap<>(); + protected final Map blockEntities = new HashMap<>(); + protected final Object2ShortMap nonEmptyBlockCounts = new Object2ShortOpenHashMap<>(); + + protected final LevelEntityGetter entityGetter = new VirtualLevelEntityGetter<>(); + + protected final BlockPos.MutableBlockPos scratchPos = new BlockPos.MutableBlockPos(); + + public VirtualRenderWorld(Level level) { + this(level, Vec3i.ZERO); + } + + public VirtualRenderWorld(Level level, Vec3i biomeOffset) { + this(level, level.getMinBuildHeight(), level.getHeight(), biomeOffset); + } + + public VirtualRenderWorld(Level level, int minBuildHeight, int height, Vec3i biomeOffset) { + super((WritableLevelData) level.getLevelData(), level.dimension(), level.registryAccess(), level.dimensionTypeRegistration(), level.getProfilerSupplier(), + true, false, 0, 0); + this.level = level; + this.minBuildHeight = nextMultipleOf16(minBuildHeight); + this.height = nextMultipleOf16(height); + this.biomeOffset = biomeOffset; + + this.chunkSource = new VirtualChunkSource(this); + this.lightEngine = new LevelLightEngine(chunkSource, true, false); + } + + /** + * We need to ensure that height and minBuildHeight are multiples of 16. + * Adapted from: https://math.stackexchange.com/questions/291468 + */ + public static int nextMultipleOf16(int a) { + if (a < 0) { + return -(((Math.abs(a) - 1) | 15) + 1); + } else { + return ((a - 1) | 15) + 1; + } + } + + public void clear() { + blockStates.clear(); + blockEntities.clear(); + + nonEmptyBlockCounts.forEach((sectionPos, nonEmptyBlockCount) -> { + if (nonEmptyBlockCount > 0) { + lightEngine.updateSectionStatus(sectionPos, true); + } + }); + + nonEmptyBlockCounts.clear(); + + runLightEngine(); + } + + public void setBlockEntities(Collection blockEntities) { + this.blockEntities.clear(); + blockEntities.forEach(this::setBlockEntity); + } + + /** + * Run this after you're done using setBlock(). + */ + public void runLightEngine() { + Set chunkPosSet = new ObjectOpenHashSet<>(); + nonEmptyBlockCounts.object2ShortEntrySet().forEach(entry -> { + if (entry.getShortValue() > 0) { + chunkPosSet.add(entry.getKey().chunk()); + } + }); + for (ChunkPos chunkPos : chunkPosSet) { + lightEngine.propagateLightSources(chunkPos); + } + + lightEngine.runLightUpdates(); + } + + // MEANINGFUL OVERRIDES + + @Override + public LevelChunk getChunk(int x, int z) { + throw new UnsupportedOperationException(); + } + + public ChunkAccess actuallyGetChunk(int x, int z) { + return getChunk(x, z, ChunkStatus.FULL); + } + + @Override + public ChunkAccess getChunk(BlockPos pos) { + return actuallyGetChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); + } + + @Override + public boolean setBlock(BlockPos pos, BlockState newState, int flags, int recursionLeft) { + if (isOutsideBuildHeight(pos)) { + return false; + } + + pos = pos.immutable(); + + BlockState oldState = getBlockState(pos); + if (oldState == newState) { + return false; + } + + blockStates.put(pos, newState); + + SectionPos sectionPos = SectionPos.of(pos); + short nonEmptyBlockCount = nonEmptyBlockCounts.getShort(sectionPos); + boolean prevEmpty = nonEmptyBlockCount == 0; + if (!oldState.isAir()) { + --nonEmptyBlockCount; + } + if (!newState.isAir()) { + ++nonEmptyBlockCount; + } + nonEmptyBlockCounts.put(sectionPos, nonEmptyBlockCount); + boolean nowEmpty = nonEmptyBlockCount == 0; + + if (prevEmpty != nowEmpty) { + lightEngine.updateSectionStatus(sectionPos, nowEmpty); + } + + lightEngine.checkBlock(pos); + + return true; + } + + @Override + public LevelLightEngine getLightEngine() { + return lightEngine; + } + + @Override + public BlockState getBlockState(BlockPos pos) { + if (isOutsideBuildHeight(pos)) { + return Blocks.VOID_AIR.defaultBlockState(); + } + BlockState state = blockStates.get(pos); + if (state != null) { + return state; + } + return Blocks.AIR.defaultBlockState(); + } + + public BlockState getBlockState(int x, int y, int z) { + return getBlockState(scratchPos.set(x, y, z)); + } + + @Override + public FluidState getFluidState(BlockPos pos) { + if (isOutsideBuildHeight(pos)) { + return Fluids.EMPTY.defaultFluidState(); + } + return getBlockState(pos).getFluidState(); + } + + @Override + @Nullable + public BlockEntity getBlockEntity(BlockPos pos) { + if (!isOutsideBuildHeight(pos)) { + return blockEntities.get(pos); + } + return null; + } + + @Override + public void setBlockEntity(BlockEntity blockEntity) { + BlockPos pos = blockEntity.getBlockPos(); + if (!isOutsideBuildHeight(pos)) { + blockEntities.put(pos, blockEntity); + } + } + + @Override + public void removeBlockEntity(BlockPos pos) { + if (!isOutsideBuildHeight(pos)) { + blockEntities.remove(pos); + } + } + + @Override + protected LevelEntityGetter getEntities() { + return entityGetter; + } + + @Override + public ChunkSource getChunkSource() { + return chunkSource; + } + + @Override + public int getMinBuildHeight() { + return minBuildHeight; + } + + @Override + public int getHeight() { + return height; + } + + // BIOME OFFSET + + @Override + public Holder getBiome(BlockPos pos) { + return super.getBiome(pos.offset(biomeOffset)); + } + + @Override + public Holder getNoiseBiome(int x, int y, int z) { + // Control flow should never reach this method, + // so we add biomeOffset in case some other mod calls this directly. + return level.getNoiseBiome(x + biomeOffset.getX(), y + biomeOffset.getY(), z + biomeOffset.getZ()); + } + + @Override + public Holder getUncachedNoiseBiome(int x, int y, int z) { + // Control flow should never reach this method, + // so we add biomeOffset in case some other mod calls this directly. + return level.getUncachedNoiseBiome(x + biomeOffset.getX(), y + biomeOffset.getY(), z + biomeOffset.getZ()); + } + + // RENDERING CONSTANTS + + @Override + public int getMaxLocalRawBrightness(BlockPos pos) { + return 15; + } + + @Override + public float getShade(Direction direction, boolean shade) { + return 1f; + } + + // THIN WRAPPERS + + @Override + public Scoreboard getScoreboard() { + return level.getScoreboard(); + } + + @Override + public RecipeManager getRecipeManager() { + return level.getRecipeManager(); + } + + @Override + public BiomeManager getBiomeManager() { + return level.getBiomeManager(); + } + + @Override + public LevelTickAccess getBlockTicks() { + return level.getBlockTicks(); + } + + @Override + public LevelTickAccess getFluidTicks() { + return level.getFluidTicks(); + } + + @Override + public FeatureFlagSet enabledFeatures() { + return level.enabledFeatures(); + } + + // ADDITIONAL OVERRRIDES + + @Override + public void updateNeighbourForOutputSignal(BlockPos pos, Block block) { + } + + @Override + public boolean isLoaded(BlockPos pos) { + return true; + } + + @Override + public boolean isAreaLoaded(BlockPos center, int range) { + return true; + } + + // UNIMPORTANT IMPLEMENTATIONS + + @Override + public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) { + } + + @Override + public void playSeededSound(Player player, double x, double y, double z, Holder soundEvent, + SoundSource soundSource, float volume, float pitch, long seed) { + } + + @Override + public void playSeededSound(Player player, Entity entity, Holder soundEvent, SoundSource soundSource, + float volume, float pitch, long seed) { + } + + @Override + public String gatherChunkSourceStats() { + return ""; + } + + @Override + @Nullable + public Entity getEntity(int id) { + return null; + } + + @Override + @Nullable + public MapItemSavedData getMapData(String mapName) { + return null; + } + + @Override + public void setMapData(String mapId, MapItemSavedData data) { + } + + @Override + public int getFreeMapId() { + return 0; + } + + @Override + public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) { + } + + @Override + public void levelEvent(@Nullable Player player, int type, BlockPos pos, int data) { + } + + @Override + public void gameEvent(GameEvent event, Vec3 position, Context context) { + } + + @Override + public List players() { + return Collections.emptyList(); + } + + // Override Starlight's ExtendedWorld interface methods: + + public LevelChunk getChunkAtImmediately(final int chunkX, final int chunkZ) { + return chunkSource.getChunk(chunkX, chunkZ, false); + } + + public ChunkAccess getAnyChunkImmediately(final int chunkX, final int chunkZ) { + return chunkSource.getChunk(chunkX, chunkZ); + } + + // Intentionally copied from LevelHeightAccessor. Lithium overrides these methods so we need to, too. + + @Override + public int getMaxBuildHeight() { + return this.getMinBuildHeight() + this.getHeight(); + } + + @Override + public int getSectionsCount() { + return this.getMaxSection() - this.getMinSection(); + } + + @Override + public int getMinSection() { + return SectionPos.blockToSectionCoord(this.getMinBuildHeight()); + } + + @Override + public int getMaxSection() { + return SectionPos.blockToSectionCoord(this.getMaxBuildHeight() - 1) + 1; + } + + @Override + public boolean isOutsideBuildHeight(BlockPos pos) { + return this.isOutsideBuildHeight(pos.getY()); + } + + @Override + public boolean isOutsideBuildHeight(int y) { + return y < this.getMinBuildHeight() || y >= this.getMaxBuildHeight(); + } + + @Override + public int getSectionIndex(int y) { + return this.getSectionIndexFromSectionY(SectionPos.blockToSectionCoord(y)); + } + + @Override + public int getSectionIndexFromSectionY(int sectionY) { + return sectionY - this.getMinSection(); + } + + @Override + public int getSectionYFromSectionIndex(int sectionIndex) { + return sectionIndex + this.getMinSection(); + } +} diff --git a/src/main/java/com/simibubi/create/infrastructure/debugInfo/DebugInformation.java b/src/main/java/com/simibubi/create/infrastructure/debugInfo/DebugInformation.java index cd76ea32e7..72117d3a22 100644 --- a/src/main/java/com/simibubi/create/infrastructure/debugInfo/DebugInformation.java +++ b/src/main/java/com/simibubi/create/infrastructure/debugInfo/DebugInformation.java @@ -9,8 +9,6 @@ import java.util.stream.Stream; import javax.annotation.Nullable; import com.google.common.collect.ImmutableMap; -import com.jozufozu.flywheel.Flywheel; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.platform.GlUtil; import com.simibubi.create.Create; import com.simibubi.create.foundation.mixin.accessor.SystemReportAccessor; @@ -18,6 +16,9 @@ import com.simibubi.create.infrastructure.debugInfo.element.DebugInfoSection; import com.simibubi.create.infrastructure.debugInfo.element.InfoElement; import com.simibubi.create.infrastructure.debugInfo.element.InfoEntry; +import dev.engine_room.flywheel.api.Flywheel; +import dev.engine_room.flywheel.api.backend.Backend; +import dev.engine_room.flywheel.api.backend.BackendManager; import net.minecraft.SharedConstants; import net.minecraft.SystemReport; import net.minecraft.Util; @@ -74,8 +75,13 @@ public class DebugInformation { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { DebugInfoSection.builder("Graphics") - .put("Flywheel Version", Flywheel.getVersion().toString()) - .put("Flywheel Backend", () -> Backend.getBackendType().toString()) + .put("Flywheel Version", ModList.get() + .getModContainerById(Flywheel.ID) + .map(c -> c.getModInfo() + .getVersion() + .toString()) + .orElse("None")) + .put("Flywheel Backend", () -> Backend.REGISTRY.getIdOrThrow(BackendManager.currentBackend()).toString()) .put("OpenGL Renderer", GlUtil::getRenderer) .put("OpenGL Version", GlUtil::getOpenGLVersion) .put("Graphics Mode", () -> Minecraft.getInstance().options.graphicsMode().get().getKey()) diff --git a/src/main/java/com/simibubi/create/infrastructure/gui/CreateMainMenuScreen.java b/src/main/java/com/simibubi/create/infrastructure/gui/CreateMainMenuScreen.java index f478ad85d5..298241d042 100644 --- a/src/main/java/com/simibubi/create/infrastructure/gui/CreateMainMenuScreen.java +++ b/src/main/java/com/simibubi/create/infrastructure/gui/CreateMainMenuScreen.java @@ -1,6 +1,5 @@ package com.simibubi.create.infrastructure.gui; -import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; @@ -20,6 +19,7 @@ import com.simibubi.create.foundation.utility.Components; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; +import dev.engine_room.flywheel.lib.transform.TransformStack; import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.gui.GuiGraphics; @@ -93,14 +93,14 @@ public class CreateMainMenuScreen extends AbstractSimiScreen { RenderSystem.enableDepthTest(); PoseStack ms = graphics.pose(); - + for (int side : Iterate.positiveAndNegative) { ms.pushPose(); ms.translate(width / 2, 60, 200); ms.scale(24 * side, 24 * side, 32); ms.translate(-1.75 * ((alpha * alpha) / 2f + .5f), .25f, 0); - TransformStack.cast(ms) - .rotateX(45); + TransformStack.of(ms) + .rotateXDegrees(45); GuiGameElement.of(AllBlocks.LARGE_COGWHEEL.getDefaultState()) .rotateBlock(0, Util.getMillis() / 32f * side, 0) .render(graphics); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index f445004f8b..b2b5841cfb 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -33,6 +33,6 @@ Technology that empowers the player.''' [[dependencies.create]] modId="flywheel" mandatory=true - versionRange="[0.6.11,0.6.12)" + versionRange="[1.0.0-alpha,2.0)" ordering="AFTER" side="CLIENT" diff --git a/src/main/resources/assets/create/flywheel/instance/actor.vert b/src/main/resources/assets/create/flywheel/instance/actor.vert new file mode 100644 index 0000000000..5a84191125 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/actor.vert @@ -0,0 +1,13 @@ +#include "flywheel:util/matrix.glsl" +#include "flywheel:util/quaternion.glsl" + +void flw_instanceVertex(in FlwInstance instance) { + float degrees = instance.offset + flw_renderSeconds * instance.speed; + + vec4 kineticRot = quaternionDegrees(instance.axis, degrees); + vec3 rotated = rotateByQuaternion(flw_vertexPos.xyz - instance.rotationCenter, kineticRot) + instance.rotationCenter; + + flw_vertexPos.xyz = rotateByQuaternion(rotated - .5, instance.rotation) + instance.pos + .5; + flw_vertexNormal = rotateByQuaternion(rotateByQuaternion(flw_vertexNormal, kineticRot), instance.rotation); + flw_vertexLight = vec2(instance.light) / 256.; +} diff --git a/src/main/resources/assets/create/flywheel/instance/belt.vert b/src/main/resources/assets/create/flywheel/instance/belt.vert new file mode 100644 index 0000000000..91180c79d5 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/belt.vert @@ -0,0 +1,19 @@ +#include "flywheel:util/quaternion.glsl" +#include "flywheel:util/matrix.glsl" + +void flw_instanceVertex(in FlwInstance instance) { + flw_vertexPos = vec4(rotateByQuaternion(flw_vertexPos.xyz - .5, instance.rotation) + instance.pos + .5, 1.); + + flw_vertexNormal = rotateByQuaternion(flw_vertexNormal, instance.rotation); + + float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y; + float scroll = fract(instance.speed * flw_renderTicks / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult; + + flw_vertexTexCoord = flw_vertexTexCoord - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll); + flw_vertexLight = vec2(instance.light) / 256.; + flw_vertexOverlay = instance.overlay; + + #if defined(DEBUG_RAINBOW) + flw_vertexColor = instance.color; + #endif +} diff --git a/src/main/resources/assets/create/flywheel/instance/cull/actor.glsl b/src/main/resources/assets/create/flywheel/instance/cull/actor.glsl new file mode 100644 index 0000000000..6a0b1d8579 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/cull/actor.glsl @@ -0,0 +1,8 @@ +void flw_transformBoundingSphere(in FlwInstance instance, inout vec3 center, inout float radius) { + // The instance will spin about the rotation center, so we need to expand the radius to account for that + float extraForKinetic = length(center - instance.rotationCenter); + float extraForModel = length(center - 0.5); + + radius += extraForKinetic + extraForModel; + center += instance.pos; +} diff --git a/src/main/resources/assets/create/flywheel/instance/cull/belt.glsl b/src/main/resources/assets/create/flywheel/instance/cull/belt.glsl new file mode 100644 index 0000000000..f16aeef0f9 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/cull/belt.glsl @@ -0,0 +1,4 @@ +void flw_transformBoundingSphere(in FlwInstance instance, inout vec3 center, inout float radius) { + radius += length(center - 0.5); + center += instance.pos; +} diff --git a/src/main/resources/assets/create/flywheel/instance/cull/flap.glsl b/src/main/resources/assets/create/flywheel/instance/cull/flap.glsl new file mode 100644 index 0000000000..1a4fed42bf --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/cull/flap.glsl @@ -0,0 +1,27 @@ +#define PI 3.1415926538 + +#include "flywheel:util/quaternion.glsl" + +float getFlapAngle(float flapness, float intensity, float scale) { + float absFlap = abs(flapness); + + float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale; + + float halfAngle = angle * 0.5; + + float which = step(0., flapness); // 0 if negative, 1 if positive + float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply + + return degrees; +} + +void flw_transformBoundingSphere(in FlwInstance flap, inout vec3 center, inout float radius) { + // FIXME: this is incorrect, but it compiles + float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale); + + vec4 orientation = quaternion(vec3(0., 1., 0.), -flap.horizontalAngle); + vec4 flapRotation = quaternion(vec3(1., 0., 0.), flapAngle); + + vec3 rotated = rotateByQuaternion(center - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset; + center = rotateByQuaternion(rotated - .5, orientation) + flap.instancePos + .5; +} diff --git a/src/main/resources/assets/create/flywheel/instance/cull/rotating.glsl b/src/main/resources/assets/create/flywheel/instance/cull/rotating.glsl new file mode 100644 index 0000000000..da6118e155 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/cull/rotating.glsl @@ -0,0 +1,5 @@ +void flw_transformBoundingSphere(in FlwInstance instance, inout vec3 center, inout float radius) { + // The instance will spin about (0.5, 0.5, 0.5), so we need to expand the radius to account for that + radius += length(center - 0.5); + center += instance.pos; +} diff --git a/src/main/resources/assets/create/flywheel/instance/cull/scrolling.glsl b/src/main/resources/assets/create/flywheel/instance/cull/scrolling.glsl new file mode 100644 index 0000000000..f16aeef0f9 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/cull/scrolling.glsl @@ -0,0 +1,4 @@ +void flw_transformBoundingSphere(in FlwInstance instance, inout vec3 center, inout float radius) { + radius += length(center - 0.5); + center += instance.pos; +} diff --git a/src/main/resources/assets/create/flywheel/instance/flap.vert b/src/main/resources/assets/create/flywheel/instance/flap.vert new file mode 100644 index 0000000000..bc655cd448 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/flap.vert @@ -0,0 +1,29 @@ +#define PI 3.1415926538 + +#include "flywheel:util/quaternion.glsl" + +float getFlapAngle(float flapness, float intensity, float scale) { + float absFlap = abs(flapness); + + float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale; + + float halfAngle = angle * 0.5; + + float which = step(0., flapness); // 0 if negative, 1 if positive + float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply + + return degrees; +} + +void flw_instanceVertex(in FlwInstance flap) { + float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale); + + vec4 orientation = quaternionDegrees(vec3(0., 1., 0.), -flap.horizontalAngle); + vec4 flapRotation = quaternionDegrees(vec3(1., 0., 0.), flapAngle); + + vec3 rotated = rotateByQuaternion(flw_vertexPos.xyz - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset; + + flw_vertexPos.xyz = rotateByQuaternion(rotated - .5, orientation) + flap.instancePos + .5; + flw_vertexNormal = rotateByQuaternion(rotateByQuaternion(flw_vertexNormal, flapRotation), orientation); + flw_vertexLight = vec2(flap.light) / 256.; +} diff --git a/src/main/resources/assets/create/flywheel/instance/rotating.vert b/src/main/resources/assets/create/flywheel/instance/rotating.vert new file mode 100644 index 0000000000..9f5e7d23e2 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/rotating.vert @@ -0,0 +1,23 @@ +#include "flywheel:util/matrix.glsl" + +const float uTime = 0.; + +mat3 kineticRotation(float offset, float speed, vec3 axis) { + float degrees = offset + flw_renderTicks * speed * 3./10.; + return rotationDegrees(axis, degrees); +} + +void flw_instanceVertex(in FlwInstance instance) { + mat3 spin = kineticRotation(instance.offset, instance.speed, instance.axis); + + vec3 worldPos = spin * (flw_vertexPos.xyz - .5); + flw_vertexPos.xyz = worldPos.xyz + instance.pos + .5; + + flw_vertexNormal = spin * flw_vertexNormal; + flw_vertexLight = vec2(instance.light) / 256.; + flw_vertexOverlay = instance.overlay; + + #if defined(DEBUG_RAINBOW) + flw_vertexColor = instance.color; + #endif +} diff --git a/src/main/resources/assets/create/flywheel/instance/scrolling.vert b/src/main/resources/assets/create/flywheel/instance/scrolling.vert new file mode 100644 index 0000000000..73a97f002e --- /dev/null +++ b/src/main/resources/assets/create/flywheel/instance/scrolling.vert @@ -0,0 +1,14 @@ +#include "flywheel:util/quaternion.glsl" +#include "flywheel:util/matrix.glsl" + +void flw_instanceVertex(in FlwInstance instance) { + flw_vertexPos = vec4(rotateByQuaternion(flw_vertexPos.xyz - .5, instance.rotation) + instance.pos + .5, 1.); + + flw_vertexNormal = rotateByQuaternion(flw_vertexNormal, instance.rotation); + + vec2 scroll = fract(instance.speed * flw_renderTicks) * instance.scale; + + flw_vertexTexCoord = flw_vertexTexCoord + instance.diff + scroll; + flw_vertexLight = vec2(instance.light) / 256.; + flw_vertexOverlay = instance.overlay; +} diff --git a/src/main/resources/assets/create/flywheel/programs/belt.json b/src/main/resources/assets/create/flywheel/programs/belt.json deleted file mode 100644 index b94f52d086..0000000000 --- a/src/main/resources/assets/create/flywheel/programs/belt.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:belt.vert", - "fragment": "flywheel:block.frag" -} diff --git a/src/main/resources/assets/create/flywheel/programs/contraption_actor.json b/src/main/resources/assets/create/flywheel/programs/contraption_actor.json deleted file mode 100644 index 117122132f..0000000000 --- a/src/main/resources/assets/create/flywheel/programs/contraption_actor.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:contraption_actor.vert", - "fragment": "flywheel:block.frag" -} diff --git a/src/main/resources/assets/create/flywheel/programs/flap.json b/src/main/resources/assets/create/flywheel/programs/flap.json deleted file mode 100644 index e1beb3d15b..0000000000 --- a/src/main/resources/assets/create/flywheel/programs/flap.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:flap.vert", - "fragment": "flywheel:block.frag" -} diff --git a/src/main/resources/assets/create/flywheel/programs/rotating.json b/src/main/resources/assets/create/flywheel/programs/rotating.json deleted file mode 100644 index 5010535ec0..0000000000 --- a/src/main/resources/assets/create/flywheel/programs/rotating.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:rotating.vert", - "fragment": "flywheel:block.frag" -} diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert deleted file mode 100644 index 215958ef65..0000000000 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ /dev/null @@ -1,33 +0,0 @@ -#define PI 3.1415926538 - -#use "flywheel:core/quaternion.glsl" -#use "flywheel:core/matutils.glsl" - -struct Belt { - vec2 light; - vec4 color; - vec3 pos; - float speed; - float offset; - vec4 rotation; - vec2 sourceTexture; - vec4 scrollTexture; - float scrollMult; -}; - - -void vertex(inout Vertex v, Belt instance) { - v.pos = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5; - - v.normal = rotateVertexByQuat(v.normal, instance.rotation); - - float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y; - float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult; - - v.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll); - v.light = instance.light; - - #if defined(DEBUG_RAINBOW) - v.color = instance.color; - #endif -} diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption.glsl b/src/main/resources/assets/create/flywheel/shaders/context/contraption.glsl deleted file mode 100644 index 1d36a39baa..0000000000 --- a/src/main/resources/assets/create/flywheel/shaders/context/contraption.glsl +++ /dev/null @@ -1,77 +0,0 @@ -#use "flywheel:context/fog.glsl" - -uniform sampler3D uLightVolume; - -uniform sampler2D uBlockAtlas; -uniform sampler2D uLightMap; - -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; - -uniform float uTime; -uniform mat4 uViewProjection; -uniform vec3 uCameraPos; - -#if defined(VERTEX_SHADER) - -out vec3 BoxCoord; - -vec4 FLWVertex(inout Vertex v) { - vec4 worldPos = uModel * vec4(v.pos, 1.); - - BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; - - FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog - - mat3 m; - m[0] = uModel[0].xyz; - m[1] = uModel[1].xyz; - m[2] = uModel[2].xyz; - v.normal = m * v.normal; - - v.pos = worldPos.xyz; - return uViewProjection * worldPos; -} - -#elif defined(FRAGMENT_SHADER) -#use "flywheel:core/lightutil.glsl" - -// optimize discard usage -#if defined(ALPHA_DISCARD) -#if defined(GL_ARB_conservative_depth) -layout (depth_greater) out float gl_FragDepth; -#endif -#endif - -in vec3 BoxCoord; - -out vec4 FragColor; - -vec4 FLWBlockTexture(vec2 texCoords) { - return texture(uBlockAtlas, texCoords); -} - -void FLWFinalizeColor(vec4 color) { - float a = color.a; - float fog = clamp(FLWFogFactor(), 0., 1.); - - color = mix(uFogColor, color, fog); - color.a = a; - - #if defined(ALPHA_DISCARD) - if (color.a < ALPHA_DISCARD) { - discard; - } - #endif - - FragColor = color; -} - -vec4 FLWLight(vec2 lightCoords) { - lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg); - - return texture(uLightMap, shiftLight(lightCoords)); -} - -#endif diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert deleted file mode 100644 index 1cb8335dea..0000000000 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert +++ /dev/null @@ -1,26 +0,0 @@ -#define PI 3.1415926538 - -#use "flywheel:core/matutils.glsl" -#use "flywheel:core/quaternion.glsl" - -struct Actor { - vec3 pos; - vec2 light; - float offset; - vec3 axis; - vec4 rotation; - vec3 rotationCenter; - float speed; -}; - -void vertex(inout Vertex v, Actor instance) { - float degrees = instance.offset + uTime * instance.speed / 20.; - //float angle = fract(degrees / 360.) * PI * 2.; - - vec4 kineticRot = quat(instance.axis, degrees); - vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter; - - v.pos = rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5; - v.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation); - v.light = instance.light; -} diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert deleted file mode 100644 index 3966724362..0000000000 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ /dev/null @@ -1,46 +0,0 @@ -#define PI 3.1415926538 - -#use "flywheel:core/matutils.glsl" -#use "flywheel:core/quaternion.glsl" - -struct Flap { - vec3 instancePos; - vec2 light; - vec3 segmentOffset; - vec3 pivot; - float horizontalAngle; - float intensity; - float flapScale; - float flapness; -}; - -float toRad(float degrees) { - return fract(degrees / 360.) * PI * 2.; -} - -float getFlapAngle(float flapness, float intensity, float scale) { - float absFlap = abs(flapness); - - float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale; - - float halfAngle = angle * 0.5; - - float which = step(0., flapness); // 0 if negative, 1 if positive - float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply - - return degrees; -} - -void vertex(inout Vertex v, Flap flap) { - float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale); - - vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle); - vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle); - - vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset; - rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5; - - v.pos = rotated; - v.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation); - v.light = flap.light; -} diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert deleted file mode 100644 index 08a0e331c6..0000000000 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ /dev/null @@ -1,33 +0,0 @@ -#define PI 3.1415926538 - -#use "flywheel:core/matutils.glsl" - -struct Rotating { - vec2 light; - vec4 color; - vec3 pos; - float speed; - float offset; - vec3 axis; -}; - -mat4 kineticRotation(float offset, float speed, vec3 axis) { - float degrees = offset + uTime * speed * 3./10.; - float angle = fract(degrees / 360.) * PI * 2.; - - return rotate(axis, angle); -} - -void vertex(inout Vertex v, Rotating instance) { - mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis); - - vec4 worldPos = spin * vec4(v.pos - .5, 1.); - v.pos = worldPos.xyz + instance.pos + .5; - - v.normal = modelToNormal(spin) * v.normal; - v.light = instance.light; - - #if defined(DEBUG_RAINBOW) - v.color = instance.color; - #endif -} diff --git a/src/main/resources/assets/create/models/block/analog_lever/handle.json b/src/main/resources/assets/create/models/block/analog_lever/handle.json index 10b6a24b34..52052fb2e3 100644 --- a/src/main/resources/assets/create/models/block/analog_lever/handle.json +++ b/src/main/resources/assets/create/models/block/analog_lever/handle.json @@ -10,6 +10,7 @@ { "from": [7, 0, -2], "to": [9, 2, 8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 1, 8]}, "faces": { "north": {"uv": [7, 6, 9, 8], "rotation": 180, "texture": "#1"}, @@ -28,4 +29,4 @@ "children": [0] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/analog_lever/item.json b/src/main/resources/assets/create/models/block/analog_lever/item.json index 855add131f..59351d67dd 100644 --- a/src/main/resources/assets/create/models/block/analog_lever/item.json +++ b/src/main/resources/assets/create/models/block/analog_lever/item.json @@ -23,6 +23,7 @@ { "from": [7, 0, -2], "to": [9, 2, 8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 1, 8]}, "faces": { "north": {"uv": [7, 6, 9, 8], "rotation": 180, "texture": "#1"}, @@ -78,4 +79,4 @@ "children": [0, 1] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/basin/block_directional.json b/src/main/resources/assets/create/models/block/basin/block_directional.json index 8a17e04c8a..daeb7494ac 100644 --- a/src/main/resources/assets/create/models/block/basin/block_directional.json +++ b/src/main/resources/assets/create/models/block/basin/block_directional.json @@ -58,6 +58,7 @@ { "from": [4, 1, 13], "to": [12, 9, 22], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [1, 9, 17]}, "faces": { "north": {"uv": [1, 1, 9, 9], "texture": "#2"}, @@ -71,6 +72,7 @@ { "from": [5, 2, 22], "to": [11, 8, 21], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [1, 9, 17]}, "faces": { "east": {"uv": [15, 1, 16, 9], "texture": "#2"}, @@ -83,6 +85,7 @@ { "from": [5, 3.64387, 12.73569], "to": [11, 9.64387, 11.73569], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 6.64387, 12.23569]}, "faces": { "north": {"uv": [10, 10, 16, 16], "rotation": 180, "texture": "#2"}, @@ -107,4 +110,4 @@ "children": [3, 4, 5, 6] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt/diagonal_end.json b/src/main/resources/assets/create/models/block/belt/diagonal_end.json index 94513f0f5a..389a26d16e 100644 --- a/src/main/resources/assets/create/models/block/belt/diagonal_end.json +++ b/src/main/resources/assets/create/models/block/belt/diagonal_end.json @@ -77,9 +77,10 @@ "name": "Bottom Diagonal", "from": [1, 3, 9.25], "to": [15, 5, 19.328], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { - "east": {"uv": [14, 5, 16, 15], "rotation": 270, "texture": "#0"}, + "east": {"uv": [14, 4, 16, 14], "rotation": 270, "texture": "#0"}, "west": {"uv": [0, 4, 2, 14], "rotation": 90, "texture": "#0"}, "up": {"uv": [1, 4, 15, 14], "rotation": 180, "texture": "#0"}, "down": {"uv": [1, 4, 15, 14], "texture": "#0"} @@ -89,6 +90,7 @@ "name": "Bottom Diagonal", "from": [3, 5, 9.25], "to": [13, 6, 19.328], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [3, 4, 4, 14], "rotation": 270, "texture": "#0"}, @@ -100,6 +102,7 @@ "name": "Top Diagonal", "from": [1, 11, 5.9], "to": [15, 13, 19.328], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [14, 3, 16, 16], "rotation": 90, "texture": "#0"}, @@ -112,12 +115,13 @@ "name": "Top Diagonal", "from": [3, 10, 6.9], "to": [13, 11, 19.328], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { - "east": {"uv": [3, 4, 4, 16], "rotation": 90, "texture": "#0"}, - "west": {"uv": [12, 4, 13, 16], "rotation": 270, "texture": "#0"}, - "down": {"uv": [3, 4, 13, 16], "rotation": 180, "texture": "#0"} + "east": {"uv": [3, 3, 4, 16], "rotation": 90, "texture": "#0"}, + "west": {"uv": [12, 3, 13, 16], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 3, 13, 16], "rotation": 180, "texture": "#0"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt/diagonal_middle.json b/src/main/resources/assets/create/models/block/belt/diagonal_middle.json index 2855a73c13..448538cb51 100644 --- a/src/main/resources/assets/create/models/block/belt/diagonal_middle.json +++ b/src/main/resources/assets/create/models/block/belt/diagonal_middle.json @@ -10,6 +10,7 @@ "name": "Top Diagonal First", "from": [3, 10, -3.305], "to": [13, 11, 8.02], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [3, 4, 4, 16], "rotation": 90, "texture": "#0"}, @@ -22,6 +23,7 @@ "name": "Top Diagonal First", "from": [1, 11, -3.3], "to": [15, 13, 8.02], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [14, 4, 16, 16], "rotation": 90, "texture": "#0"}, @@ -34,6 +36,7 @@ "name": "Top Diagonal", "from": [3, 10, 8], "to": [13, 11, 19.325], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [3, 4, 4, 16], "rotation": 90, "texture": "#0"}, @@ -46,6 +49,7 @@ "name": "Top Diagonal", "from": [1, 11, 8], "to": [15, 13, 19.325], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [14, 4, 16, 16], "rotation": 90, "texture": "#0"}, @@ -58,6 +62,7 @@ "name": "Bottom Diagonal First", "from": [3, -3.305, 5], "to": [13, 8.02, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 0, 15, 10], "rotation": 180, "texture": "#0"}, @@ -70,6 +75,7 @@ "name": "Bottom Diagonal First", "from": [1, -3.3, 3], "to": [15, 8.02, 5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 4, 15, 16], "rotation": 180, "texture": "#0"}, @@ -82,6 +88,7 @@ "name": "Bottom Diagonal", "from": [3, 8, 5], "to": [13, 19.325, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 3, 15, 16], "rotation": 180, "texture": "#0"}, @@ -94,6 +101,7 @@ "name": "Bottom Diagonal", "from": [1, 8, 3], "to": [15, 19.325, 5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 4, 15, 16], "rotation": 180, "texture": "#0"}, @@ -115,4 +123,4 @@ "children": [4, 5, 6, 7] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt/diagonal_start.json b/src/main/resources/assets/create/models/block/belt/diagonal_start.json index b9da310660..3d6303f884 100644 --- a/src/main/resources/assets/create/models/block/belt/diagonal_start.json +++ b/src/main/resources/assets/create/models/block/belt/diagonal_start.json @@ -77,6 +77,7 @@ "name": "Top Diagonal", "from": [1, 11, -3.325], "to": [15, 13, 6.8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [14, 4, 16, 14], "rotation": 90, "texture": "#0"}, @@ -89,6 +90,7 @@ "name": "Top Diagonal", "from": [3, 10, -3.325], "to": [13, 11, 6.8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [3, 4, 4, 14], "rotation": 90, "texture": "#0"}, @@ -100,6 +102,7 @@ "name": "Bottom Diagonal", "from": [1, 3, -3.325], "to": [15, 5, 10.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [14, 3, 16, 16], "rotation": 270, "texture": "#0"}, @@ -112,12 +115,13 @@ "name": "Bottom Diagonal", "from": [3, 5, -3.325], "to": [13, 6, 10.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { - "east": {"uv": [2, 3, 3, 16], "rotation": 270, "texture": "#0"}, - "west": {"uv": [13, 3, 14, 16], "rotation": 90, "texture": "#0"}, + "east": {"uv": [3, 3, 4, 16], "rotation": 270, "texture": "#0"}, + "west": {"uv": [12, 3, 13, 16], "rotation": 90, "texture": "#0"}, "up": {"uv": [3, 3, 13, 16], "rotation": 180, "texture": "#0"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt_casing/diagonal_end.json b/src/main/resources/assets/create/models/block/belt_casing/diagonal_end.json index af619ff1b6..5731bfae7c 100644 --- a/src/main/resources/assets/create/models/block/belt_casing/diagonal_end.json +++ b/src/main/resources/assets/create/models/block/belt_casing/diagonal_end.json @@ -44,6 +44,7 @@ "name": "4", "from": [-0.1, 2, 11.303], "to": [16.1, 11, 19.328], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [39, 8, 8]}, "faces": { "north": {"uv": [12, 2.25, 16, 4.5], "texture": "#7"}, @@ -55,4 +56,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt_casing/diagonal_middle.json b/src/main/resources/assets/create/models/block/belt_casing/diagonal_middle.json index bd8e548a64..2a4acb97f2 100644 --- a/src/main/resources/assets/create/models/block/belt_casing/diagonal_middle.json +++ b/src/main/resources/assets/create/models/block/belt_casing/diagonal_middle.json @@ -10,6 +10,7 @@ "name": "Top Diagonal", "from": [-0.1, 2, -3.325], "to": [16.1, 11, 7.9875], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [8, 2.25, 12, 4.5], "texture": "#4"}, @@ -23,6 +24,7 @@ "name": "Top Diagonal", "from": [-0.1, 7.43588, 10.23912], "to": [16.1, 16.43588, 21.55162], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 13.43588, 2.56412]}, "faces": { "east": {"uv": [11, 5.75, 8.25, 8], "texture": "#4"}, @@ -33,4 +35,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt_casing/diagonal_pulley.json b/src/main/resources/assets/create/models/block/belt_casing/diagonal_pulley.json index 4d11db46a4..bb373137c7 100644 --- a/src/main/resources/assets/create/models/block/belt_casing/diagonal_pulley.json +++ b/src/main/resources/assets/create/models/block/belt_casing/diagonal_pulley.json @@ -11,6 +11,7 @@ "name": "1", "from": [-0.1, 2, -3.325], "to": [16.1, 11, 7.9875], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [8, 2.25, 12, 4.5], "texture": "#10"}, @@ -24,6 +25,7 @@ "name": "2", "from": [-0.1, 7.43588, 10.23912], "to": [16.1, 16.43588, 21.55162], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 13.43588, 2.56412]}, "faces": { "east": {"uv": [9.25, 0, 12, 2.25], "texture": "#10"}, @@ -37,6 +39,7 @@ "name": "3", "from": [-0.1, 11, 3.85], "to": [16.1, 5, 12.15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [4, 3.25, 8, 4.75], "rotation": 180, "texture": "#10"}, @@ -48,6 +51,7 @@ "name": "4", "from": [0.9, 5, 3.85], "to": [15.1, 11, 12.15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [4, 5, 12, 11], "texture": "#8"}, @@ -66,4 +70,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt_casing/diagonal_start.json b/src/main/resources/assets/create/models/block/belt_casing/diagonal_start.json index 3cc34b2347..e0b5c72cdf 100644 --- a/src/main/resources/assets/create/models/block/belt_casing/diagonal_start.json +++ b/src/main/resources/assets/create/models/block/belt_casing/diagonal_start.json @@ -11,6 +11,7 @@ "name": "1", "from": [-0.1, 2, -3.325], "to": [16.1, 11, 4.7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [-22, 8, 8]}, "faces": { "north": {"uv": [8, 2.25, 12, 4.5], "texture": "#7"}, @@ -54,4 +55,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt_funnel/block_pulling.json b/src/main/resources/assets/create/models/block/belt_funnel/block_pulling.json index 722f587ae8..c5a9fb6567 100644 --- a/src/main/resources/assets/create/models/block/belt_funnel/block_pulling.json +++ b/src/main/resources/assets/create/models/block/belt_funnel/block_pulling.json @@ -61,6 +61,7 @@ "name": "External", "from": [-0.05, -3, 13], "to": [16.05, 16, 19], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [0, -3, 13]}, "faces": { "north": {"uv": [0, 0, 8, 9.5], "texture": "#direction"}, @@ -75,6 +76,7 @@ "name": "Internal", "from": [1.9, -3, 19], "to": [14.1, 10.05, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [0, -3, 13]}, "faces": { "east": {"uv": [13, 16, 16, 9.5], "rotation": 180, "texture": "#base"}, @@ -112,4 +114,4 @@ "children": [4, 5] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/belt_funnel/block_pushing.json b/src/main/resources/assets/create/models/block/belt_funnel/block_pushing.json index e641f07443..4d6cf9122c 100644 --- a/src/main/resources/assets/create/models/block/belt_funnel/block_pushing.json +++ b/src/main/resources/assets/create/models/block/belt_funnel/block_pushing.json @@ -61,6 +61,7 @@ "name": "External", "from": [-0.05, -3, 13], "to": [16.05, 16, 19], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [0, -3, 13]}, "faces": { "north": {"uv": [0, 0, 8, 9.5], "texture": "#direction"}, @@ -75,6 +76,7 @@ "name": "Internal", "from": [1.9, -3, 19], "to": [14.1, 10.05, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [0, -3, 13]}, "faces": { "east": {"uv": [13, 6, 16, 12.5], "rotation": 180, "texture": "#base"}, @@ -112,4 +114,4 @@ "children": [4, 5] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/blaze_burner/flame.json b/src/main/resources/assets/create/models/block/blaze_burner/flame.json index c111c8b3a1..209ec4d796 100644 --- a/src/main/resources/assets/create/models/block/blaze_burner/flame.json +++ b/src/main/resources/assets/create/models/block/blaze_burner/flame.json @@ -3,7 +3,8 @@ "loader": "forge:obj", "flip_v": true, "model": "create:models/block/blaze_burner/blaze_flame.obj", - "textures": { + "render_type": "minecraft:cutout", + "textures": { "0": "create:block/blaze_burner_flame" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/chute/block_diagonal.json b/src/main/resources/assets/create/models/block/chute/block_diagonal.json index 09beeb8fdb..a271958d6e 100644 --- a/src/main/resources/assets/create/models/block/chute/block_diagonal.json +++ b/src/main/resources/assets/create/models/block/chute/block_diagonal.json @@ -10,6 +10,7 @@ { "from": [1.1, -12, 2], "to": [14.9, 0, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 0, 16]}, "faces": { "north": {"uv": [8.5, 9.5, 15.5, 15], "texture": "#3"}, @@ -23,6 +24,7 @@ { "from": [4, -16, -1], "to": [12, -5.35, 0], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, -16, 0]}, "faces": { "east": {"uv": [6.5, 9.5, 7, 15], "texture": "#3"}, @@ -33,6 +35,7 @@ { "from": [2.1, -16, -13], "to": [13.9, -5.35, -1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, -16, 0]}, "faces": { "north": {"uv": [9, 1.5, 15, 7], "texture": "#3"}, @@ -42,4 +45,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/chute/block_diagonal_encased.json b/src/main/resources/assets/create/models/block/chute/block_diagonal_encased.json index ce1871c01d..6fa2de9113 100644 --- a/src/main/resources/assets/create/models/block/chute/block_diagonal_encased.json +++ b/src/main/resources/assets/create/models/block/chute/block_diagonal_encased.json @@ -23,6 +23,7 @@ { "from": [4, -16, -1], "to": [12, -5.15, 0], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, -16, 0]}, "faces": { "east": {"uv": [6.5, 9.5, 7, 15], "texture": "#4"}, @@ -33,6 +34,7 @@ { "from": [1.1, -11.8, 2], "to": [14.9, 0, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 0, 16]}, "faces": { "north": {"uv": [8.5, 9.5, 15.5, 15], "texture": "#4"}, @@ -45,6 +47,7 @@ { "from": [2.1, -16, -13], "to": [13.9, -5.15, -1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, -16, 0]}, "faces": { "north": {"uv": [9, 1.5, 15, 7], "texture": "#4"}, @@ -68,4 +71,4 @@ "children": [1, 2, 3] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/chute/block_diagonal_intersection.json b/src/main/resources/assets/create/models/block/chute/block_diagonal_intersection.json index 692ec8f5a1..ee1048b954 100644 --- a/src/main/resources/assets/create/models/block/chute/block_diagonal_intersection.json +++ b/src/main/resources/assets/create/models/block/chute/block_diagonal_intersection.json @@ -34,6 +34,7 @@ { "from": [4, -16, -1], "to": [12, -5.15, 0], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, -16, 0]}, "faces": { "east": {"uv": [6.5, 9.5, 7, 15], "texture": "#4"}, @@ -44,6 +45,7 @@ { "from": [1.1, -11.8, 2], "to": [14.9, 0, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 0, 16]}, "faces": { "north": {"uv": [8.5, 9.5, 15.5, 15], "texture": "#4"}, @@ -56,6 +58,7 @@ { "from": [2.1, -16, -13], "to": [13.9, -5.15, -1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, -16, 0]}, "faces": { "north": {"uv": [9, 1.5, 15, 7], "texture": "#4"}, @@ -79,4 +82,4 @@ "children": [2, 3, 4] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/clipboard/block_empty.json b/src/main/resources/assets/create/models/block/clipboard/block_empty.json index 3047fd8a9c..47e90de574 100644 --- a/src/main/resources/assets/create/models/block/clipboard/block_empty.json +++ b/src/main/resources/assets/create/models/block/clipboard/block_empty.json @@ -23,6 +23,7 @@ { "from": [6, 1, 14.95], "to": [10, 1, 15.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 1, 15]}, "faces": { "up": {"uv": [12, 0, 16, 1], "rotation": 180, "texture": "#0"}, @@ -30,4 +31,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/cogwheel.json b/src/main/resources/assets/create/models/block/cogwheel.json index 7761b23e90..0f2290d5b6 100644 --- a/src/main/resources/assets/create/models/block/cogwheel.json +++ b/src/main/resources/assets/create/models/block/cogwheel.json @@ -39,6 +39,7 @@ "name": "Gear2", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#1_2"}, @@ -53,6 +54,7 @@ "name": "Gear3", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#1_2"}, @@ -103,4 +105,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/cogwheel_shaftless.json b/src/main/resources/assets/create/models/block/cogwheel_shaftless.json index bc2820563d..793cf46d90 100644 --- a/src/main/resources/assets/create/models/block/cogwheel_shaftless.json +++ b/src/main/resources/assets/create/models/block/cogwheel_shaftless.json @@ -24,6 +24,7 @@ "name": "Gear2", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#1_2"}, @@ -38,6 +39,7 @@ "name": "Gear3", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#1_2"}, @@ -88,4 +90,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/block.json b/src/main/resources/assets/create/models/block/contraption_controls/block.json index c5a41c6dcc..527f16430a 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/block.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/block.json @@ -61,6 +61,7 @@ { "from": [2, 9.1, 7], "to": [14, 10.1, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [1, 9.5, 7, 13.5], "rotation": 180, "texture": "#4"} @@ -102,4 +103,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/button.json b/src/main/resources/assets/create/models/block/contraption_controls/button.json index 47a0a32baa..f7ce777445 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/button.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/button.json @@ -8,6 +8,7 @@ { "from": [4.95, 8.5, 7.95], "to": [11.05, 11, 14.05], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10, 7]}, "faces": { "north": {"uv": [5.5, 12.5, 2.5, 13], "rotation": 180, "texture": "#4"}, @@ -53,4 +54,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_0.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_0.json index 0271a29c0f..28730a6fca 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_0.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_0.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [1, 0.5, 7, 3.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_1.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_1.json index 346f112a87..bfe8ccb838 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_1.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_1.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [1, 4.5, 7, 7.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_2.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_2.json index 63abf0138b..84fc65a463 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_2.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_2.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [1, 8.5, 7, 11.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_3.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_3.json index cca5e8b259..7f888aeed3 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_3.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_3.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [1, 12.5, 7, 15.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_4.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_4.json index fbaaf3f6c7..1905a64fc7 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_4.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_4.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [9, 0.5, 15, 3.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_5.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_5.json index 8484489f1c..0efa271d10 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_5.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_5.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [9, 4.5, 15, 7.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_6.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_6.json index 17e456a3c6..ea78f8cf16 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_6.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_6.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [9, 8.5, 15, 11.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/indicator_7.json b/src/main/resources/assets/create/models/block/contraption_controls/indicator_7.json index f0ddc3964f..c0118b1b94 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/indicator_7.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/indicator_7.json @@ -7,10 +7,11 @@ { "from": [2, 9.125, 8], "to": [14, 10.125, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10.1, 7]}, "faces": { "up": {"uv": [9, 12.5, 15, 15.5], "rotation": 180, "texture": "#4"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/contraption_controls/item.json b/src/main/resources/assets/create/models/block/contraption_controls/item.json index aff25c2f0e..fc2bf7a29b 100644 --- a/src/main/resources/assets/create/models/block/contraption_controls/item.json +++ b/src/main/resources/assets/create/models/block/contraption_controls/item.json @@ -60,6 +60,7 @@ { "from": [4.95, 8.5, 7.95], "to": [11.05, 11, 14.05], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10, 7]}, "faces": { "north": {"uv": [5.5, 12.5, 2.5, 13], "rotation": 180, "texture": "#4"}, @@ -72,6 +73,7 @@ { "from": [2, 9, 7], "to": [14, 10, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10, 7]}, "faces": { "up": {"uv": [1, 9.5, 7, 13.5], "rotation": 180, "texture": "#4"} @@ -80,6 +82,7 @@ { "from": [2, 9.05, 8], "to": [14, 10.05, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10, 7]}, "faces": { "up": {"uv": [1, 10, 7, 13], "rotation": 180, "texture": "#4"} @@ -122,4 +125,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/controls/block_virtual.json b/src/main/resources/assets/create/models/block/controls/block_virtual.json index 1977a302f2..373b44c1ba 100644 --- a/src/main/resources/assets/create/models/block/controls/block_virtual.json +++ b/src/main/resources/assets/create/models/block/controls/block_virtual.json @@ -9,6 +9,7 @@ { "from": [4, 9, -1], "to": [6, 11, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 10, 11]}, "faces": { "north": {"uv": [8, 1.5, 9, 2.5], "rotation": 180, "texture": "#1_7"}, @@ -21,6 +22,7 @@ { "from": [10, 9, -1], "to": [12, 11, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 10, 11]}, "faces": { "north": {"uv": [8, 1.5, 9, 2.5], "rotation": 180, "texture": "#1_7"}, @@ -92,4 +94,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/controls/item.json b/src/main/resources/assets/create/models/block/controls/item.json index 5a772fb077..fd92033ed0 100644 --- a/src/main/resources/assets/create/models/block/controls/item.json +++ b/src/main/resources/assets/create/models/block/controls/item.json @@ -9,6 +9,7 @@ { "from": [4, 9, -1], "to": [6, 11, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [0, 10, 11]}, "faces": { "north": {"uv": [8, 1.5, 9, 2.5], "rotation": 180, "texture": "#1_7"}, @@ -21,6 +22,7 @@ { "from": [10, 9, -1], "to": [12, 11, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 10, 11]}, "faces": { "north": {"uv": [8, 1.5, 9, 2.5], "rotation": 180, "texture": "#1_7"}, @@ -128,4 +130,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/controls/train/lever.json b/src/main/resources/assets/create/models/block/controls/train/lever.json index 49cb62d67d..0f02ef3873 100644 --- a/src/main/resources/assets/create/models/block/controls/train/lever.json +++ b/src/main/resources/assets/create/models/block/controls/train/lever.json @@ -7,6 +7,7 @@ { "from": [4, 9, -1], "to": [6, 11, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [0, 10, 11]}, "faces": { "north": {"uv": [8, 1.5, 9, 2.5], "rotation": 180, "texture": "#5"}, @@ -17,4 +18,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/copper_backtank/block_cogs.json b/src/main/resources/assets/create/models/block/copper_backtank/block_cogs.json index e69634e117..42b4b64058 100644 --- a/src/main/resources/assets/create/models/block/copper_backtank/block_cogs.json +++ b/src/main/resources/assets/create/models/block/copper_backtank/block_cogs.json @@ -21,6 +21,7 @@ { "from": [5, 4, 10.5], "to": [7, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [6.5, 11.5, 5.5, 14], "texture": "#0"}, @@ -47,6 +48,7 @@ { "from": [5, 6, 8.5], "to": [7, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "rotation": 180, "texture": "#0"}, @@ -73,6 +75,7 @@ { "from": [9, 4, 10.5], "to": [11, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11.5, 6.5, 14], "texture": "#0"}, @@ -99,6 +102,7 @@ { "from": [9, 6, 8.5], "to": [11, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "texture": "#0"}, @@ -122,4 +126,4 @@ "children": [] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/copper_backtank/item.json b/src/main/resources/assets/create/models/block/copper_backtank/item.json index ce9a790e2e..8e0be2ab0c 100644 --- a/src/main/resources/assets/create/models/block/copper_backtank/item.json +++ b/src/main/resources/assets/create/models/block/copper_backtank/item.json @@ -22,6 +22,7 @@ { "from": [5, 4, 10.5], "to": [7, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [6.5, 11.5, 5.5, 14], "texture": "#0"}, @@ -48,6 +49,7 @@ { "from": [5, 6, 8.5], "to": [7, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "rotation": 180, "texture": "#0"}, @@ -74,6 +76,7 @@ { "from": [9, 4, 10.5], "to": [11, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11.5, 6.5, 14], "texture": "#0"}, @@ -100,6 +103,7 @@ { "from": [9, 6, 8.5], "to": [11, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "texture": "#0"}, @@ -202,4 +206,4 @@ "origin": [8, 8, 8], "children": [] }, 13, 14] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/creative_motor/item.json b/src/main/resources/assets/create/models/block/creative_motor/item.json index 566063c41a..8307a9f621 100644 --- a/src/main/resources/assets/create/models/block/creative_motor/item.json +++ b/src/main/resources/assets/create/models/block/creative_motor/item.json @@ -14,6 +14,7 @@ "name": "Axis", "from": [6, 6, 6], "to": [10, 10, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [6, 6, 10, 10], "rotation": 180, "texture": "#1_1"}, @@ -215,4 +216,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/cuckoo_clock/block.json b/src/main/resources/assets/create/models/block/cuckoo_clock/block.json index e748a2587a..83508a8d4c 100644 --- a/src/main/resources/assets/create/models/block/cuckoo_clock/block.json +++ b/src/main/resources/assets/create/models/block/cuckoo_clock/block.json @@ -69,6 +69,7 @@ "name": "RoofLeft", "from": [13, 10, 1], "to": [15, 20, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [14, 12, 8]}, "faces": { "north": {"uv": [0, 0, 2, 10], "texture": "#1"}, @@ -83,6 +84,7 @@ "name": "RoofRight", "from": [1, 10, 1], "to": [3, 20, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [2, 12, 8]}, "faces": { "north": {"uv": [0, 0, 2, 10], "texture": "#1"}, @@ -156,4 +158,4 @@ "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/cuckoo_clock/item.json b/src/main/resources/assets/create/models/block/cuckoo_clock/item.json index 9ad34983d7..1bf638e38e 100644 --- a/src/main/resources/assets/create/models/block/cuckoo_clock/item.json +++ b/src/main/resources/assets/create/models/block/cuckoo_clock/item.json @@ -125,6 +125,7 @@ "name": "RoofLeft", "from": [1, 10, 1], "to": [15, 20, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 12, 2]}, "faces": { "north": {"uv": [0, 0, 14, 10], "texture": "#1"}, @@ -139,6 +140,7 @@ "name": "RoofRight", "from": [1, 10, 13], "to": [15, 20, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 12, 14]}, "faces": { "north": {"uv": [0, 0, 14, 10], "texture": "#1"}, @@ -244,4 +246,4 @@ "children": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/diodes/latch_off.json b/src/main/resources/assets/create/models/block/diodes/latch_off.json index 4e8ce60be3..f064a4c329 100644 --- a/src/main/resources/assets/create/models/block/diodes/latch_off.json +++ b/src/main/resources/assets/create/models/block/diodes/latch_off.json @@ -80,6 +80,7 @@ { "from": [11.24264, 4.75736, 7], "to": [13.24264, 14.75736, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 9, 8]}, "faces": { "north": {"uv": [7, 6, 9, 16], "texture": "#lever"}, @@ -102,4 +103,4 @@ "scale":[ 0.5, 0.5, 0.5 ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/diodes/latch_on.json b/src/main/resources/assets/create/models/block/diodes/latch_on.json index 6d4c4797f5..8d0da2de90 100644 --- a/src/main/resources/assets/create/models/block/diodes/latch_on.json +++ b/src/main/resources/assets/create/models/block/diodes/latch_on.json @@ -82,6 +82,7 @@ { "from": [7, 3, 7], "to": [9, 13, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 3, 8]}, "faces": { "north": {"uv": [7, 6, 9, 16], "texture": "#lever"}, @@ -104,4 +105,4 @@ "scale":[ 0.5, 0.5, 0.5 ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/display_board/item.json b/src/main/resources/assets/create/models/block/display_board/item.json index c457a70ae8..064adffacf 100644 --- a/src/main/resources/assets/create/models/block/display_board/item.json +++ b/src/main/resources/assets/create/models/block/display_board/item.json @@ -29,6 +29,7 @@ "name": "Gear2", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 6, 16, 7.5], "rotation": 180, "texture": "#1_2"}, @@ -43,6 +44,7 @@ "name": "Gear3", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 6, 16, 7.5], "rotation": 180, "texture": "#1_2"}, @@ -156,4 +158,4 @@ "children": [6, 7, 8, 9] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/encased_cogwheel/item.json b/src/main/resources/assets/create/models/block/encased_cogwheel/item.json index 300a024051..dd46f9f01a 100644 --- a/src/main/resources/assets/create/models/block/encased_cogwheel/item.json +++ b/src/main/resources/assets/create/models/block/encased_cogwheel/item.json @@ -57,6 +57,7 @@ "name": "Gear", "from": [-1, 6.025, 6.5], "to": [17, 9.975, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 10], "texture": "#1_2"}, @@ -71,6 +72,7 @@ "name": "Gear2", "from": [-1, 6.025, 6.5], "to": [17, 9.975, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 10], "texture": "#1_2"}, @@ -85,6 +87,7 @@ "name": "Gear3", "from": [6.5, 6.025, -1], "to": [9.5, 9.975, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [5, 8, 6.5, 10], "texture": "#1_2"}, @@ -99,6 +102,7 @@ "name": "Gear4", "from": [6.5, 6.025, -1], "to": [9.5, 9.975, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [5, 8, 6.5, 10], "texture": "#1_2"}, @@ -113,6 +117,7 @@ "name": "GearCaseInner", "from": [2, 6.5, 2], "to": [14, 9.5, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 6, 6, 7.5], "texture": "#1_2"}, @@ -127,6 +132,7 @@ "name": "GearCaseOuter", "from": [4, 6, 4], "to": [12, 10, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 4, 4, 6], "texture": "#1_2"}, @@ -150,4 +156,4 @@ "children": [4, 5, 6, 7, 8, 9] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/encased_fan/item.json b/src/main/resources/assets/create/models/block/encased_fan/item.json index fe80c3a0eb..a98368f263 100644 --- a/src/main/resources/assets/create/models/block/encased_fan/item.json +++ b/src/main/resources/assets/create/models/block/encased_fan/item.json @@ -94,6 +94,7 @@ "name": "Fan", "from": [1, 1, 4], "to": [15, 15, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 1, 15, 15], "texture": "#fan_blades"}, @@ -108,4 +109,4 @@ "children": [6, 7] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/encased_fan/propeller.json b/src/main/resources/assets/create/models/block/encased_fan/propeller.json index b50ef7caf4..d7a23a1506 100644 --- a/src/main/resources/assets/create/models/block/encased_fan/propeller.json +++ b/src/main/resources/assets/create/models/block/encased_fan/propeller.json @@ -5,6 +5,7 @@ "fan_blades": "create:block/fan_blades", "axis": "create:block/axis" }, + "render_type": "minecraft:cutout", "elements": [ { "name": "Shaft", @@ -23,10 +24,11 @@ "name": "Fan", "from": [1, 1, 4], "to": [15, 15, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 1, 15, 15], "texture": "#fan_blades"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/encased_large_cogwheel/item.json b/src/main/resources/assets/create/models/block/encased_large_cogwheel/item.json index 21cc17a7e4..0468a25e04 100644 --- a/src/main/resources/assets/create/models/block/encased_large_cogwheel/item.json +++ b/src/main/resources/assets/create/models/block/encased_large_cogwheel/item.json @@ -37,6 +37,7 @@ "name": "GearCaseInnerRotated", "from": [-2, 6.525, -2], "to": [18, 9.475, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 10, 10, 11.5], "texture": "#4"}, @@ -51,6 +52,7 @@ "name": "Gear2", "from": [-7, 6.025, 6.5], "to": [23, 9.975, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 15], "texture": "#4"}, @@ -65,6 +67,7 @@ "name": "Gear3", "from": [-7, 6.025, 6.5], "to": [23, 9.975, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 15], "texture": "#4"}, @@ -79,6 +82,7 @@ "name": "Gear4", "from": [6.5, 6.025, -7], "to": [9.5, 9.975, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9, 11.5, 11], "texture": "#4"}, @@ -171,6 +175,7 @@ "name": "Gear", "from": [6.5, 6.025, -7], "to": [9.5, 9.975, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9, 11.5, 11], "texture": "#4"}, @@ -185,6 +190,7 @@ "name": "Gear5", "from": [-7, 6.025, 6.5], "to": [23, 9.975, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 15], "texture": "#4"}, @@ -199,6 +205,7 @@ "name": "Gear6", "from": [6.5, 6.025, -7], "to": [9.5, 9.975, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9, 11.5, 11], "texture": "#4"}, @@ -246,4 +253,4 @@ "children": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/fluid_valve/item.json b/src/main/resources/assets/create/models/block/fluid_valve/item.json index b09bd0b776..ad326cb73c 100644 --- a/src/main/resources/assets/create/models/block/fluid_valve/item.json +++ b/src/main/resources/assets/create/models/block/fluid_valve/item.json @@ -39,6 +39,7 @@ { "from": [7, 14.1, 5], "to": [9, 15.1, 7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [14, 0, 12, 1], "rotation": 180, "texture": "#4"}, @@ -52,6 +53,7 @@ { "from": [9, 14.1, 5], "to": [11, 15.1, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [16, 0, 14, 1], "texture": "#4"}, @@ -65,6 +67,7 @@ { "from": [5, 14.1, 7], "to": [7, 15.1, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [16, 0, 14, 1], "rotation": 180, "texture": "#4"}, @@ -78,6 +81,7 @@ { "from": [7, 14.1, 9], "to": [9, 15.1, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [14, 2, 12, 3], "rotation": 180, "texture": "#4"}, @@ -92,6 +96,7 @@ "name": "Center", "from": [7, 14, 7], "to": [9, 16, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 15, 8]}, "faces": { "north": {"uv": [12.5, 0, 12, 1], "rotation": 90, "texture": "#2"}, @@ -187,4 +192,4 @@ 7, 8 ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/fluid_valve/pointer.json b/src/main/resources/assets/create/models/block/fluid_valve/pointer.json index 2e9eed35b7..b29464403d 100644 --- a/src/main/resources/assets/create/models/block/fluid_valve/pointer.json +++ b/src/main/resources/assets/create/models/block/fluid_valve/pointer.json @@ -9,6 +9,7 @@ { "from": [7, 14.1, 5], "to": [9, 15.1, 7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [14, 0, 12, 1], "rotation": 180, "texture": "#4"}, @@ -22,6 +23,7 @@ { "from": [9, 14.1, 5], "to": [11, 15.1, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [16, 0, 14, 1], "texture": "#4"}, @@ -34,6 +36,7 @@ { "from": [7, 14.1, 9], "to": [11, 15.1, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [16, 0, 14, 1], "texture": "#4"}, @@ -46,6 +49,7 @@ { "from": [9, 14.1, 7], "to": [11, 15.1, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [12, 0, 13, 2], "rotation": 270, "texture": "#4"}, @@ -59,6 +63,7 @@ { "from": [9, 14.1, 5], "to": [11, 15.1, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [16, 0, 14, 1], "texture": "#4"}, @@ -71,6 +76,7 @@ { "from": [7, 14.1, 5], "to": [9, 15.1, 7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [14, 0, 12, 1], "rotation": 180, "texture": "#4"}, @@ -85,6 +91,7 @@ "name": "Center", "from": [7, 14, 7], "to": [9, 16, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 15, 8]}, "faces": { "north": {"uv": [12.5, 0, 12, 1], "rotation": 90, "texture": "#2"}, @@ -148,4 +155,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/funnel/block_horizontal.json b/src/main/resources/assets/create/models/block/funnel/block_horizontal.json index 42a525dc09..ed1820117a 100644 --- a/src/main/resources/assets/create/models/block/funnel/block_horizontal.json +++ b/src/main/resources/assets/create/models/block/funnel/block_horizontal.json @@ -61,6 +61,7 @@ { "from": [-0.05, 0, 12], "to": [16.05, 16, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 0, 12]}, "faces": { "north": {"uv": [0, 0, 8, 8], "texture": "#direction"}, @@ -74,6 +75,7 @@ { "from": [1.9, 0, 18], "to": [14.1, 10.05, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 0, 12]}, "faces": { "east": {"uv": [13, 6, 16, 11], "rotation": 180, "texture": "#base"}, @@ -112,4 +114,4 @@ 4, 5 ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/funnel/block_vertical.json b/src/main/resources/assets/create/models/block/funnel/block_vertical.json index bee49ffc84..6bdfc25f09 100644 --- a/src/main/resources/assets/create/models/block/funnel/block_vertical.json +++ b/src/main/resources/assets/create/models/block/funnel/block_vertical.json @@ -25,6 +25,7 @@ { "from": [0.95, 5, 2], "to": [1.95, 10, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "z", "origin": [1.95, 10, 8]}, "faces": { "east": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -33,6 +34,7 @@ { "from": [14.05, 5, 2], "to": [15.05, 10, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "z", "origin": [14.05, 10, 8]}, "faces": { "west": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -41,6 +43,7 @@ { "from": [2, 5, 14.05], "to": [14, 10, 15.05], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 10, 14.05]}, "faces": { "north": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -49,6 +52,7 @@ { "from": [2, 5, 0.95], "to": [14, 10, 1.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10, 1.95]}, "faces": { "south": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -146,4 +150,4 @@ "children": [8, 9] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/funnel/block_vertical_filterless.json b/src/main/resources/assets/create/models/block/funnel/block_vertical_filterless.json index 7a75928258..b5b3f728ef 100644 --- a/src/main/resources/assets/create/models/block/funnel/block_vertical_filterless.json +++ b/src/main/resources/assets/create/models/block/funnel/block_vertical_filterless.json @@ -25,6 +25,7 @@ { "from": [0.95, 5, 2], "to": [1.95, 10, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "z", "origin": [1.95, 10, 8]}, "faces": { "east": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -33,6 +34,7 @@ { "from": [14.05, 5, 2], "to": [15.05, 10, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "z", "origin": [14.05, 10, 8]}, "faces": { "west": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -41,6 +43,7 @@ { "from": [2, 5, 14.05], "to": [14, 10, 15.05], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 10, 14.05]}, "faces": { "north": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -49,6 +52,7 @@ { "from": [2, 5, 0.95], "to": [14, 10, 1.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 10, 1.95]}, "faces": { "south": {"uv": [12, 0, 14.5, 6], "rotation": 90, "texture": "#base"} @@ -116,4 +120,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/gantry_carriage/item.json b/src/main/resources/assets/create/models/block/gantry_carriage/item.json index e99bd3f23b..23eebf1b55 100644 --- a/src/main/resources/assets/create/models/block/gantry_carriage/item.json +++ b/src/main/resources/assets/create/models/block/gantry_carriage/item.json @@ -18,6 +18,7 @@ "name": "Gear", "from": [2.5, -10, 6.5], "to": [5.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -32,6 +33,7 @@ "name": "Gear2", "from": [2.5, -10, 6.5], "to": [5.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -46,6 +48,7 @@ "name": "Gear3", "from": [2.5, -2.5, -1], "to": [5.5, 0.5, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [5, 8, 6.5, 9.5], "rotation": 90, "texture": "#3"}, @@ -60,6 +63,7 @@ "name": "Gear4", "from": [2.5, -2.5, -1], "to": [5.5, 0.5, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [5, 8, 6.5, 9.5], "rotation": 90, "texture": "#3"}, @@ -74,6 +78,7 @@ "name": "GearCaseInner", "from": [2.55, -7, 2], "to": [5.45, 5, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [0, 6, 6, 7.5], "rotation": 90, "texture": "#3"}, @@ -88,6 +93,7 @@ "name": "GearCaseOuter", "from": [2, -5, 4], "to": [6, 3, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [0, 4, 4, 6], "rotation": 90, "texture": "#3"}, @@ -102,6 +108,7 @@ "name": "Gear", "from": [10.5, -10, 6.5], "to": [13.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -116,6 +123,7 @@ "name": "Gear3", "from": [10.5, -10, 6.5], "to": [13.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -130,6 +138,7 @@ "name": "Gear4", "from": [10.5, -2.5, -1], "to": [13.5, 0.5, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [5, 8, 6.5, 9.5], "rotation": 90, "texture": "#3"}, @@ -144,6 +153,7 @@ "name": "Gear5", "from": [10.5, -2.5, -1], "to": [13.5, 0.5, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [5, 8, 6.5, 9.5], "rotation": 90, "texture": "#3"}, @@ -158,6 +168,7 @@ "name": "GearCaseInner", "from": [10.55, -7, 2], "to": [13.45, 5, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [0, 6, 6, 7.5], "rotation": 90, "texture": "#3"}, @@ -172,6 +183,7 @@ "name": "GearCaseOuter", "from": [10, -5, 4], "to": [14, 3, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [0, 4, 4, 6], "rotation": 90, "texture": "#3"}, @@ -364,4 +376,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/gantry_carriage/wheels.json b/src/main/resources/assets/create/models/block/gantry_carriage/wheels.json index 957523ec15..c710f2014b 100644 --- a/src/main/resources/assets/create/models/block/gantry_carriage/wheels.json +++ b/src/main/resources/assets/create/models/block/gantry_carriage/wheels.json @@ -25,6 +25,7 @@ "name": "Gear2", "from": [2.5, -10, 6.5], "to": [5.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [4, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -39,6 +40,7 @@ "name": "Gear3", "from": [2.5, -10, 6.5], "to": [5.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [4, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -109,6 +111,7 @@ "name": "Gear3", "from": [10.5, -10, 6.5], "to": [13.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -123,6 +126,7 @@ "name": "Gear4", "from": [10.5, -10, 6.5], "to": [13.5, 8, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [12, -1, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "rotation": 90, "texture": "#3"}, @@ -224,4 +228,4 @@ "children": [6, 7, 8, 9, 10, 11] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/hand_crank/handle.json b/src/main/resources/assets/create/models/block/hand_crank/handle.json index df816830a9..a52ba2ca19 100644 --- a/src/main/resources/assets/create/models/block/hand_crank/handle.json +++ b/src/main/resources/assets/create/models/block/hand_crank/handle.json @@ -52,6 +52,7 @@ "name": "Grip", "from": [-0.5, 6.5, 3], "to": [2.5, 9.5, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [1, 8, 9]}, "faces": { "north": {"uv": [6, 11, 9, 14], "rotation": 90, "texture": "#0"}, @@ -69,4 +70,4 @@ "origin": [8, 8, 8], "children": [0] }, 1, 2, 3] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/hand_crank/item.json b/src/main/resources/assets/create/models/block/hand_crank/item.json index a9ee1da235..513b219dfd 100644 --- a/src/main/resources/assets/create/models/block/hand_crank/item.json +++ b/src/main/resources/assets/create/models/block/hand_crank/item.json @@ -65,6 +65,7 @@ "name": "Grip", "from": [-0.5, 6.5, 3], "to": [2.5, 9.5, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [1, 8, 9]}, "faces": { "north": {"uv": [6, 11, 9, 14], "rotation": 90, "texture": "#0"}, @@ -119,4 +120,4 @@ "origin": [8, 8, 8], "children": [0] }, 1, 2, 3, 4] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/hose_pulley/item.json b/src/main/resources/assets/create/models/block/hose_pulley/item.json index 428de4c1f2..cddc499779 100644 --- a/src/main/resources/assets/create/models/block/hose_pulley/item.json +++ b/src/main/resources/assets/create/models/block/hose_pulley/item.json @@ -193,6 +193,7 @@ "name": "coil", "from": [4, 4, 2], "to": [12, 12, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [2, 1, 14, 9], "rotation": 180, "texture": "#5"}, @@ -205,6 +206,7 @@ "name": "coil", "from": [3.5, 3.5, 9], "to": [12.5, 12.5, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 1, 1], "texture": "#5"}, @@ -219,6 +221,7 @@ "name": "coil", "from": [3.5, 3.5, 3], "to": [12.5, 12.5, 7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 1, 1], "texture": "#5"}, @@ -361,4 +364,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/hose_pulley/rope_coil.json b/src/main/resources/assets/create/models/block/hose_pulley/rope_coil.json index f4d01993a5..c8c41e1263 100644 --- a/src/main/resources/assets/create/models/block/hose_pulley/rope_coil.json +++ b/src/main/resources/assets/create/models/block/hose_pulley/rope_coil.json @@ -9,6 +9,7 @@ "name": "coil", "from": [4, 4, 2], "to": [12, 12, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "east": {"uv": [2, 1, 14, 9], "texture": "#5"}, @@ -21,6 +22,7 @@ "name": "coil", "from": [3.5, 3.5, 3], "to": [12.5, 12.5, 7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "north": {"uv": [0, 0, 1, 1], "texture": "#5"}, @@ -35,6 +37,7 @@ "name": "coil", "from": [3.5, 3.5, 9], "to": [12.5, 12.5, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, -4]}, "faces": { "north": {"uv": [0, 0, 1, 1], "texture": "#5"}, @@ -46,4 +49,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/large_cogwheel.json b/src/main/resources/assets/create/models/block/large_cogwheel.json index 5d6ed2b5bc..5742c517e2 100644 --- a/src/main/resources/assets/create/models/block/large_cogwheel.json +++ b/src/main/resources/assets/create/models/block/large_cogwheel.json @@ -13,6 +13,7 @@ "name": "GearCaseInnerRotated", "from": [-2, 6.625, -2], "to": [18, 9.375, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 10, 10, 11.5], "texture": "#4"}, @@ -40,6 +41,7 @@ "name": "Gear2", "from": [-7, 6.525, 6.5], "to": [23, 9.475, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 14.5], "texture": "#4"}, @@ -54,6 +56,7 @@ "name": "Gear3", "from": [-7, 6.525, 6.5], "to": [23, 9.475, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 14.5], "texture": "#4"}, @@ -68,6 +71,7 @@ "name": "Gear4", "from": [6.5, 6.525, -7], "to": [9.5, 9.475, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9.5, 11.5, 11], "texture": "#4"}, @@ -160,6 +164,7 @@ "name": "Gear", "from": [6.5, 6.525, -7], "to": [9.5, 9.475, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9.5, 11.5, 11], "texture": "#4"}, @@ -174,6 +179,7 @@ "name": "Gear5", "from": [-7, 6.525, 6.5], "to": [23, 9.475, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 14.5], "texture": "#4"}, @@ -188,6 +194,7 @@ "name": "Gear6", "from": [6.5, 6.525, -7], "to": [9.5, 9.475, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9.5, 11.5, 11], "texture": "#4"}, @@ -225,4 +232,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/large_cogwheel_shaftless.json b/src/main/resources/assets/create/models/block/large_cogwheel_shaftless.json index 05b5d70eed..0d3ab77c16 100644 --- a/src/main/resources/assets/create/models/block/large_cogwheel_shaftless.json +++ b/src/main/resources/assets/create/models/block/large_cogwheel_shaftless.json @@ -11,6 +11,7 @@ "name": "GearCaseInnerRotated", "from": [-2, 6.625, -2], "to": [18, 9.375, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 10, 10, 11.5], "texture": "#4"}, @@ -25,6 +26,7 @@ "name": "Gear2", "from": [-7, 6.525, 6.5], "to": [23, 9.475, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 14.5], "texture": "#4"}, @@ -39,6 +41,7 @@ "name": "Gear3", "from": [-7, 6.525, 6.5], "to": [23, 9.475, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 14.5], "texture": "#4"}, @@ -53,6 +56,7 @@ "name": "Gear4", "from": [6.5, 6.525, -7], "to": [9.5, 9.475, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9.5, 11.5, 11], "texture": "#4"}, @@ -145,6 +149,7 @@ "name": "Gear", "from": [6.5, 6.525, -7], "to": [9.5, 9.475, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9.5, 11.5, 11], "texture": "#4"}, @@ -159,6 +164,7 @@ "name": "Gear5", "from": [-7, 6.525, 6.5], "to": [23, 9.475, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 13, 15, 14.5], "texture": "#4"}, @@ -173,6 +179,7 @@ "name": "Gear6", "from": [6.5, 6.525, -7], "to": [9.5, 9.475, 23], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [10, 9.5, 11.5, 11], "texture": "#4"}, @@ -210,4 +217,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_arm/claw_base_goggles.json b/src/main/resources/assets/create/models/block/mechanical_arm/claw_base_goggles.json index 8bd6fd97b8..e610d582ee 100644 --- a/src/main/resources/assets/create/models/block/mechanical_arm/claw_base_goggles.json +++ b/src/main/resources/assets/create/models/block/mechanical_arm/claw_base_goggles.json @@ -50,6 +50,7 @@ { "from": [-4, 0.5, -4.25], "to": [4, 4.5, 3.75], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 3, 1]}, "faces": { "north": {"uv": [8, 2, 16, 6], "texture": "#1"}, @@ -61,6 +62,7 @@ { "from": [-4, 0.5, 3.75], "to": [4, 4.5, -4.25], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 3, 1]}, "faces": { "north": {"uv": [8, 10, 16, 14], "texture": "#1"}, @@ -115,4 +117,4 @@ "children": [3, 4] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_arm/cog.json b/src/main/resources/assets/create/models/block/mechanical_arm/cog.json index d10a6472d2..51a22920e8 100644 --- a/src/main/resources/assets/create/models/block/mechanical_arm/cog.json +++ b/src/main/resources/assets/create/models/block/mechanical_arm/cog.json @@ -24,6 +24,7 @@ "name": "Gear6", "from": [6.5, 6, -1], "to": [9.5, 10, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [13, 5.5, 15, 7], "rotation": 90, "texture": "#5"}, @@ -52,6 +53,7 @@ "name": "Gear8", "from": [-1, 6, 6.5], "to": [17, 10, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [13, 7, 15, 16], "rotation": 90, "texture": "#5"}, @@ -126,4 +128,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_arm/item.json b/src/main/resources/assets/create/models/block/mechanical_arm/item.json index 55ee9f8c36..1c3ee0c7f8 100644 --- a/src/main/resources/assets/create/models/block/mechanical_arm/item.json +++ b/src/main/resources/assets/create/models/block/mechanical_arm/item.json @@ -28,6 +28,7 @@ "name": "Gear6", "from": [6.5, -10, -1], "to": [9.5, -6, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, -8, 8]}, "faces": { "north": {"uv": [13, 5.5, 15, 7], "rotation": 90, "texture": "#4"}, @@ -56,6 +57,7 @@ "name": "Gear8", "from": [-1, -10, 6.5], "to": [17, -6, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, -8, 8]}, "faces": { "north": {"uv": [13, 7, 15, 16], "rotation": 90, "texture": "#4"}, @@ -123,6 +125,7 @@ "name": "Arm 1", "from": [6.5, -3, 5.5], "to": [9.5, 13, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, -2, 8]}, "faces": { "north": {"uv": [0, 0, 1.5, 8], "texture": "#5"}, @@ -310,4 +313,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_crafter/item.json b/src/main/resources/assets/create/models/block/mechanical_crafter/item.json index f99b84d7be..56cd5b0b6c 100644 --- a/src/main/resources/assets/create/models/block/mechanical_crafter/item.json +++ b/src/main/resources/assets/create/models/block/mechanical_crafter/item.json @@ -159,6 +159,7 @@ "name": "Gear2", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#9"}, @@ -173,6 +174,7 @@ "name": "Gear3", "from": [-1, 6.5, 6.5], "to": [17, 9.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#9"}, @@ -248,4 +250,4 @@ "children": [12, 13, 14, 15, 16, 17] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_drill/head.json b/src/main/resources/assets/create/models/block/mechanical_drill/head.json index 23d80c50e4..5bd8b0a03e 100644 --- a/src/main/resources/assets/create/models/block/mechanical_drill/head.json +++ b/src/main/resources/assets/create/models/block/mechanical_drill/head.json @@ -25,6 +25,7 @@ "name": "Core", "from": [5, 5, 9], "to": [11, 11, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [1, 1, 7, 4], "rotation": 270, "texture": "#10"}, @@ -38,6 +39,7 @@ "name": "Bottom", "from": [6, 3, 9], "to": [10, 5, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 4, 2], "texture": "#10"}, @@ -52,6 +54,7 @@ "name": "Bottom", "from": [11, 6, 9], "to": [13, 10, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 4, 2], "rotation": 90, "texture": "#10"}, @@ -66,6 +69,7 @@ "name": "Bottom", "from": [6, 11, 9], "to": [10, 13, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 4, 2], "rotation": 180, "texture": "#10"}, @@ -80,6 +84,7 @@ "name": "Bottom", "from": [3, 6, 9], "to": [5, 10, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 4, 2], "rotation": 270, "texture": "#10"}, @@ -94,6 +99,7 @@ "name": "Bit1", "from": [5.5, 5.5, 12], "to": [10.5, 10.5, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 5, 5], "texture": "#2"}, @@ -108,6 +114,7 @@ "name": "Bit2", "from": [6, 6, 14], "to": [10, 10, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 7]}, "faces": { "north": {"uv": [0, 0, 4, 4], "texture": "#2"}, @@ -122,6 +129,7 @@ "name": "Bit3", "from": [6.5, 6.5, 16], "to": [9.5, 9.5, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 7]}, "faces": { "north": {"uv": [0, 0, 3, 3], "texture": "#2"}, @@ -136,6 +144,7 @@ "name": "Bit4", "from": [7, 7, 18], "to": [9, 9, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 7]}, "faces": { "north": {"uv": [0, 0, 2, 2], "texture": "#2"}, @@ -155,4 +164,4 @@ "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_drill/item.json b/src/main/resources/assets/create/models/block/mechanical_drill/item.json index 156dfc7e5c..628b8f9973 100644 --- a/src/main/resources/assets/create/models/block/mechanical_drill/item.json +++ b/src/main/resources/assets/create/models/block/mechanical_drill/item.json @@ -28,6 +28,7 @@ "name": "Core", "from": [5, 5, 9], "to": [11, 11, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 6, 6], "texture": "#7"}, @@ -42,6 +43,7 @@ "name": "Top", "from": [6, 11, 9], "to": [10, 13, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 4, 2], "texture": "#10"}, @@ -56,6 +58,7 @@ "name": "Bottom", "from": [6, 3, 9], "to": [10, 5, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 4, 2], "texture": "#10"}, @@ -70,6 +73,7 @@ "name": "Left", "from": [3, 6, 9], "to": [5, 10, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 4], "texture": "#10"}, @@ -84,6 +88,7 @@ "name": "Right", "from": [11, 6, 9], "to": [13, 10, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 4], "texture": "#10"}, @@ -98,6 +103,7 @@ "name": "Bit1", "from": [5.5, 5.5, 12], "to": [10.5, 10.5, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 5, 5], "texture": "#2"}, @@ -112,6 +118,7 @@ "name": "Bit2", "from": [6, 6, 14], "to": [10, 10, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 7]}, "faces": { "north": {"uv": [0, 0, 4, 4], "texture": "#2"}, @@ -126,6 +133,7 @@ "name": "Bit3", "from": [6.5, 6.5, 16], "to": [9.5, 9.5, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, 7]}, "faces": { "north": {"uv": [0, 0, 3, 3], "texture": "#2"}, @@ -140,6 +148,7 @@ "name": "Bit4", "from": [7, 7, 18], "to": [9, 9, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 7]}, "faces": { "north": {"uv": [0, 0, 2, 2], "texture": "#2"}, @@ -229,4 +238,4 @@ "children": [10, 11, 12, 13, 14] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_harvester/blade.json b/src/main/resources/assets/create/models/block/mechanical_harvester/blade.json index a15ba52c4e..ab5eb93bea 100644 --- a/src/main/resources/assets/create/models/block/mechanical_harvester/blade.json +++ b/src/main/resources/assets/create/models/block/mechanical_harvester/blade.json @@ -5,11 +5,13 @@ "anvil": "minecraft:block/anvil", "andesite_casing_short": "create:block/andesite_casing_short" }, + "render_type": "minecraft:cutout", "elements": [ { "name": "Wheel", - "from": [ 1, 0, 3 ], - "to": [ 1.0625, 12, 15 ], + "from": [ 1, 0, 3 ], + "to": [ 1.0625, 12, 15 ], + "forge_data": {"calculate_normals": true}, "rotation": { "origin": [ 8, 6, 9 ], "axis": "x", "angle": -22.5 }, "faces": { "east": { "texture": "#harvester", "uv": [ 0, 0, 12, 12 ] }, @@ -18,8 +20,8 @@ }, { "name": "Trim", - "from": [ 0, 0, 11 ], - "to": [ 16, 2, 12 ], + "from": [ 0, 0, 11 ], + "to": [ 16, 2, 12 ], "faces": { "north": { "texture": "#anvil", "uv": [ 0, 0, 16, 2 ] }, "east": { "texture": "#anvil", "uv": [ 0, 0, 1, 2 ] }, @@ -31,8 +33,8 @@ }, { "name": "Trim", - "from": [ 0, 10, 6 ], - "to": [ 16, 12, 7 ], + "from": [ 0, 10, 6 ], + "to": [ 16, 12, 7 ], "faces": { "north": { "texture": "#anvil", "uv": [ 0, 0, 16, 2 ] }, "east": { "texture": "#anvil", "uv": [ 0, 0, 1, 2 ] }, @@ -44,8 +46,8 @@ }, { "name": "Trim", - "from": [ 0, 8, 13 ], - "to": [ 16, 9, 15 ], + "from": [ 0, 8, 13 ], + "to": [ 16, 9, 15 ], "faces": { "north": { "texture": "#anvil", "uv": [ 0, 9, 16, 10 ] }, "east": { "texture": "#anvil", "uv": [ 0, 0, 2, 1 ] }, @@ -57,8 +59,8 @@ }, { "name": "Trim", - "from": [ 0, 3, 3 ], - "to": [ 16, 4, 5 ], + "from": [ 0, 3, 3 ], + "to": [ 16, 4, 5 ], "faces": { "north": { "texture": "#anvil", "uv": [ 0, 0, 16, 1 ] }, "east": { "texture": "#anvil", "uv": [ 0, 0, 2, 1 ] }, @@ -70,8 +72,8 @@ }, { "name": "Blade", - "from": [ 0, 6, 15 ], - "to": [ 16, 8, 15.0625 ], + "from": [ 0, 6, 15 ], + "to": [ 16, 8, 15.0625 ], "faces": { "north": { "texture": "#harvester", "uv": [ 0, 12, 16, 14 ], "rotation": 180 }, "south": { "texture": "#harvester", "uv": [ 16, 12, 0, 14 ], "rotation": 180 } @@ -79,8 +81,9 @@ }, { "name": "Wheel", - "from": [ 15, 0, 3 ], - "to": [ 15.0625, 12, 15 ], + "from": [ 15, 0, 3 ], + "to": [ 15.0625, 12, 15 ], + "forge_data": {"calculate_normals": true}, "rotation": { "origin": [ 8, 6, 9 ], "axis": "x", "angle": -22.5 }, "faces": { "east": { "texture": "#harvester", "uv": [ 0, 0, 12, 12 ] }, @@ -89,8 +92,8 @@ }, { "name": "Blade", - "from": [ 0, 4, 3 ], - "to": [ 16, 6, 3.0625 ], + "from": [ 0, 4, 3 ], + "to": [ 16, 6, 3.0625 ], "faces": { "north": { "texture": "#harvester", "uv": [ 0, 12, 16, 14 ] }, "south": { "texture": "#harvester", "uv": [ 16, 12, 0, 14 ] } @@ -98,8 +101,8 @@ }, { "name": "Blade", - "from": [ 0, 12, 7 ], - "to": [ 16, 12.0625, 9 ], + "from": [ 0, 12, 7 ], + "to": [ 16, 12.0625, 9 ], "faces": { "up": { "texture": "#harvester", "uv": [ 0, 12, 16, 14 ], "rotation": 180 }, "down": { "texture": "#harvester", "uv": [ 16, 12, 0, 14 ] } @@ -107,12 +110,12 @@ }, { "name": "Blade", - "from": [ 0, 0.0625, 9 ], - "to": [ 16, 0.125, 11 ], + "from": [ 0, 0.0625, 9 ], + "to": [ 16, 0.125, 11 ], "faces": { "up": { "texture": "#harvester", "uv": [ 0, 12, 16, 14 ] }, "down": { "texture": "#harvester", "uv": [ 16, 12, 0, 14 ], "rotation": 180 } } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_harvester/block.json b/src/main/resources/assets/create/models/block/mechanical_harvester/block.json index 46c82eece0..c9b0d02f4f 100644 --- a/src/main/resources/assets/create/models/block/mechanical_harvester/block.json +++ b/src/main/resources/assets/create/models/block/mechanical_harvester/block.json @@ -22,6 +22,7 @@ "name": "Attachment", "from": [14, 7, 5], "to": [15.9, 10, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [16, 10, 13]}, "faces": { "north": {"uv": [0.1, 8, 2, 11], "texture": "#andesite_casing_short"}, @@ -36,6 +37,7 @@ "name": "Attachment", "from": [0.1, 7, 5], "to": [2, 10, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [16, 10, 13]}, "faces": { "north": {"uv": [14, 8, 15.9, 11], "texture": "#andesite_casing_short"}, @@ -47,4 +49,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_harvester/item.json b/src/main/resources/assets/create/models/block/mechanical_harvester/item.json index 9bb48da0b2..518cbf8c81 100644 --- a/src/main/resources/assets/create/models/block/mechanical_harvester/item.json +++ b/src/main/resources/assets/create/models/block/mechanical_harvester/item.json @@ -25,6 +25,7 @@ "name": "Wheel", "from": [1, 0, 3], "to": [1, 12, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 6, 9]}, "faces": { "east": {"uv": [0, 0, 12, 12], "texture": "#harvester"}, @@ -96,6 +97,7 @@ "name": "Wheel", "from": [15, 0, 3], "to": [15, 12, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 6, 9]}, "faces": { "east": {"uv": [0, 0, 12, 12], "texture": "#harvester"}, @@ -133,6 +135,7 @@ "name": "Attachment", "from": [0.1, 7, 3], "to": [2, 10, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 10, 3]}, "faces": { "north": {"uv": [0, 0, 1.9, 3], "texture": "#andesite_casing_short"}, @@ -147,6 +150,7 @@ "name": "Attachment", "from": [14, 7, 3], "to": [15.9, 10, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 10, 3]}, "faces": { "north": {"uv": [0, 0, 1.9, 3], "texture": "#andesite_casing_short"}, @@ -165,4 +169,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_mixer/head.json b/src/main/resources/assets/create/models/block/mechanical_mixer/head.json index 2e4744b639..e949ae1ff6 100644 --- a/src/main/resources/assets/create/models/block/mechanical_mixer/head.json +++ b/src/main/resources/assets/create/models/block/mechanical_mixer/head.json @@ -5,7 +5,8 @@ "textures": { "6": "create:block/mixer_head" }, - "elements": [ + "render_type": "minecraft:cutout", + "elements": [ { "name": "MixerCenter", "from": [7, -4, 7], @@ -39,4 +40,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_mixer/item.json b/src/main/resources/assets/create/models/block/mechanical_mixer/item.json index e51e594a9e..b9aebf5dca 100644 --- a/src/main/resources/assets/create/models/block/mechanical_mixer/item.json +++ b/src/main/resources/assets/create/models/block/mechanical_mixer/item.json @@ -38,6 +38,7 @@ "name": "Mixer wire 1", "from": [2.5, -4, 8], "to": [13.5, 6, 8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 1.25, 8]}, "faces": { "north": {"uv": [0, 0, 11, 10], "texture": "#6"}, @@ -48,6 +49,7 @@ "name": "MixerCenter", "from": [7, -4, 7], "to": [9, 8, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 1.25, 8]}, "faces": { "north": {"uv": [12, 0, 14, 12], "texture": "#6"}, @@ -61,6 +63,7 @@ "name": "Mixer wire 2", "from": [8, -4, 2.5], "to": [8, 6, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "y", "origin": [8, 1.25, 8]}, "faces": { "east": {"uv": [0, 0, 11, 10], "texture": "#6"}, @@ -222,6 +225,7 @@ "name": "Gear2", "from": [-1, 13.5, 6.5], "to": [17, 16.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 15, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#1_2"}, @@ -236,6 +240,7 @@ "name": "Gear3", "from": [-1, 13.5, 6.5], "to": [17, 16.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 15, 8]}, "faces": { "north": {"uv": [7, 8, 16, 9.5], "texture": "#1_2"}, @@ -364,4 +369,4 @@ "children": [16, 17, 18, 19, 20, 21] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_plough.json b/src/main/resources/assets/create/models/block/mechanical_plough.json index ad0dd1fb03..9969d33f91 100644 --- a/src/main/resources/assets/create/models/block/mechanical_plough.json +++ b/src/main/resources/assets/create/models/block/mechanical_plough.json @@ -24,6 +24,7 @@ "name": "Attachment", "from": [14, 4, 1], "to": [15.9, 7, 10], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [16, 10, 13]}, "faces": { "north": {"uv": [0.1, 8, 2, 11], "texture": "#andesite_casing_short"}, @@ -38,6 +39,7 @@ "name": "Attachment", "from": [2, 5, -1], "to": [13.9, 6, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [16, 10, 13]}, "faces": { "north": {"uv": [2, 15, 13.9, 16], "texture": "#1"}, @@ -52,6 +54,7 @@ "name": "Attachment", "from": [0.1, 4, 1], "to": [2, 7, 10], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [16, 10, 13]}, "faces": { "north": {"uv": [14, 8, 15.9, 11], "texture": "#andesite_casing_short"}, @@ -83,4 +86,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_pump/block.json b/src/main/resources/assets/create/models/block/mechanical_pump/block.json index 8dd3ab9b70..a38904e464 100644 --- a/src/main/resources/assets/create/models/block/mechanical_pump/block.json +++ b/src/main/resources/assets/create/models/block/mechanical_pump/block.json @@ -52,6 +52,7 @@ { "from": [5.85355, 13.25, 1.75], "to": [9.85355, 15.25, 13.75], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8.35355, 13.25, 7.75]}, "faces": { "north": {"uv": [16, 0, 12, 2], "texture": "#4"}, @@ -65,6 +66,7 @@ { "from": [7.85355, 11.25, 1.75], "to": [9.85355, 13.25, 13.75], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8.35355, 13.25, 7.75]}, "faces": { "north": {"uv": [16, 2, 14, 4], "texture": "#4"}, @@ -77,6 +79,7 @@ { "from": [2.35355, 10.75, 7.75], "to": [14.35355, 12.75, 9.75], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8.35355, 13.25, 7.75]}, "faces": { "north": {"uv": [14, 2, 15, 4], "texture": "#4"}, @@ -89,6 +92,7 @@ { "from": [2.35355, 12.75, 5.75], "to": [14.35355, 14.75, 9.75], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8.35355, 13.25, 7.75]}, "faces": { "north": {"uv": [12, 0, 13, 2], "texture": "#4"}, @@ -143,4 +147,4 @@ 5, 6 ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_pump/cog.json b/src/main/resources/assets/create/models/block/mechanical_pump/cog.json index d9f2d4c46c..53cbe69bd2 100644 --- a/src/main/resources/assets/create/models/block/mechanical_pump/cog.json +++ b/src/main/resources/assets/create/models/block/mechanical_pump/cog.json @@ -25,6 +25,7 @@ "name": "Gear7", "from": [6.5, -1, 5], "to": [9.5, 17, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 6.5]}, "faces": { "north": {"uv": [0, 8.5, 9, 10], "rotation": 90, "texture": "#5"}, @@ -39,6 +40,7 @@ "name": "Gear8", "from": [-1, 6.5, 5], "to": [17, 9.5, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 6.5]}, "faces": { "north": {"uv": [0, 8.5, 9, 10], "texture": "#5"}, @@ -120,4 +122,4 @@ "children": [0, 1, 2, 3, 4] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_pump/item.json b/src/main/resources/assets/create/models/block/mechanical_pump/item.json index 161c4910c9..0e52322468 100644 --- a/src/main/resources/assets/create/models/block/mechanical_pump/item.json +++ b/src/main/resources/assets/create/models/block/mechanical_pump/item.json @@ -26,6 +26,7 @@ "name": "Gear6", "from": [5.5, 7, -1], "to": [11.5, 10, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8.5, 8.5, 8]}, "faces": { "north": {"uv": [9, 10, 10.5, 13], "rotation": 90, "texture": "#5"}, @@ -40,6 +41,7 @@ "name": "Gear7", "from": [5.5, -0.5, 6.5], "to": [11.5, 17.5, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8.5, 8.5, 8]}, "faces": { "north": {"uv": [0, 10, 9, 13], "rotation": 90, "texture": "#5"}, @@ -123,6 +125,7 @@ { "from": [1.70355, 6.15, 2], "to": [3.70355, 10.15, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3.35355, 8.25, 7.75]}, "faces": { "north": {"uv": [16, 0, 12, 2], "rotation": 90, "texture": "#4"}, @@ -136,6 +139,7 @@ { "from": [3.70355, 8.15, 2], "to": [5.70355, 10.15, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3.35355, 8.25, 7.75]}, "faces": { "north": {"uv": [16, 2, 14, 4], "rotation": 90, "texture": "#4"}, @@ -148,6 +152,7 @@ { "from": [3.85355, 2.5, 7.75], "to": [5.85355, 14.5, 9.75], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [3.35355, 8.25, 7.75]}, "faces": { "north": {"uv": [14, 2, 15, 4], "rotation": 90, "texture": "#4"}, @@ -160,6 +165,7 @@ { "from": [1.85355, 2.5, 5.75], "to": [3.85355, 14.5, 9.75], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [3.35355, 8.25, 7.75]}, "faces": { "north": {"uv": [12, 0, 13, 2], "rotation": 90, "texture": "#4"}, @@ -222,4 +228,4 @@ "children": [8, 9, 10, 11] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/mechanical_roller/frame.json b/src/main/resources/assets/create/models/block/mechanical_roller/frame.json index 489a68f423..7c997b5f04 100644 --- a/src/main/resources/assets/create/models/block/mechanical_roller/frame.json +++ b/src/main/resources/assets/create/models/block/mechanical_roller/frame.json @@ -9,6 +9,7 @@ "name": "Axle left", "from": [-2, -8, -5], "to": [2, 0, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [4, -4, -1]}, "faces": { "north": {"uv": [0, 4, 4, 6], "rotation": 90, "texture": "#1"}, @@ -23,6 +24,7 @@ "name": "Axle right", "from": [14, -8, -5], "to": [18, 0, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [4, -4, -1]}, "faces": { "north": {"uv": [0, 4, 4, 6], "rotation": 90, "texture": "#1"}, @@ -37,6 +39,7 @@ "name": "Chute", "from": [1, -4, -8], "to": [15, 12, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [4, -4, -1]}, "faces": { "north": {"uv": [0.5, 8, 7.5, 16], "texture": "#1"}, @@ -50,6 +53,7 @@ "name": "Chute top", "from": [1, 5, -14], "to": [15, 11, -8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [4, -4, -1]}, "faces": { "north": {"uv": [9, 1, 16, 4], "texture": "#1"}, @@ -62,6 +66,7 @@ "name": "Cage", "from": [1, -2, -14], "to": [15, 5, -8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [4, -4, -1]}, "faces": { "north": {"uv": [9, 4, 16, 8], "texture": "#1"}, @@ -70,4 +75,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/millstone/inner.json b/src/main/resources/assets/create/models/block/millstone/inner.json index c68026361c..8c09153fa1 100644 --- a/src/main/resources/assets/create/models/block/millstone/inner.json +++ b/src/main/resources/assets/create/models/block/millstone/inner.json @@ -27,6 +27,7 @@ "name": "Gear6", "from": [6.5, 6, -1], "to": [9.5, 12, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 7.5, 8]}, "faces": { "north": {"uv": [9, 10, 10.5, 13], "texture": "#5"}, @@ -41,6 +42,7 @@ "name": "Gear7", "from": [-1, 6, 6.5], "to": [17, 12, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 7.5, 8]}, "faces": { "north": {"uv": [0, 10, 9, 13], "texture": "#5"}, @@ -141,4 +143,4 @@ "children": [5] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/millstone/item.json b/src/main/resources/assets/create/models/block/millstone/item.json index eff5cf81da..84a61ee0a6 100644 --- a/src/main/resources/assets/create/models/block/millstone/item.json +++ b/src/main/resources/assets/create/models/block/millstone/item.json @@ -26,6 +26,7 @@ "name": "Gear6", "from": [6.5, 6, -1], "to": [9.5, 12, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 7.5, 8]}, "faces": { "north": {"uv": [9, 10, 10.5, 13], "texture": "#5"}, @@ -40,6 +41,7 @@ "name": "Gear7", "from": [-1, 6, 6.5], "to": [17, 12, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 7.5, 8]}, "faces": { "north": {"uv": [0, 10, 9, 13], "texture": "#5"}, @@ -172,4 +174,4 @@ }, 11 ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/netherite_backtank/block_cogs.json b/src/main/resources/assets/create/models/block/netherite_backtank/block_cogs.json index 3db35b065a..3030bad3d1 100644 --- a/src/main/resources/assets/create/models/block/netherite_backtank/block_cogs.json +++ b/src/main/resources/assets/create/models/block/netherite_backtank/block_cogs.json @@ -21,6 +21,7 @@ { "from": [5, 4, 10.5], "to": [7, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [6.5, 11.5, 5.5, 14], "texture": "#0"}, @@ -47,6 +48,7 @@ { "from": [5, 6, 8.5], "to": [7, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "rotation": 180, "texture": "#0"}, @@ -73,6 +75,7 @@ { "from": [9, 4, 10.5], "to": [11, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11.5, 6.5, 14], "texture": "#0"}, @@ -99,6 +102,7 @@ { "from": [9, 6, 8.5], "to": [11, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "texture": "#0"}, @@ -122,4 +126,4 @@ "children": [] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/netherite_backtank/item.json b/src/main/resources/assets/create/models/block/netherite_backtank/item.json index 20607aa1f2..f333c93862 100644 --- a/src/main/resources/assets/create/models/block/netherite_backtank/item.json +++ b/src/main/resources/assets/create/models/block/netherite_backtank/item.json @@ -22,6 +22,7 @@ { "from": [5, 4, 10.5], "to": [7, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [6.5, 11.5, 5.5, 14], "texture": "#0"}, @@ -48,6 +49,7 @@ { "from": [5, 6, 8.5], "to": [7, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "rotation": 180, "texture": "#0"}, @@ -74,6 +76,7 @@ { "from": [9, 4, 10.5], "to": [11, 9, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11.5, 6.5, 14], "texture": "#0"}, @@ -100,6 +103,7 @@ { "from": [9, 6, 8.5], "to": [11, 7, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 6.5, 11]}, "faces": { "north": {"uv": [5.5, 11, 6.5, 11.5], "texture": "#0"}, @@ -202,4 +206,4 @@ "origin": [8, 8, 8], "children": [] }, 13, 14] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/placard.json b/src/main/resources/assets/create/models/block/placard.json index b79599cb27..b48f82909d 100644 --- a/src/main/resources/assets/create/models/block/placard.json +++ b/src/main/resources/assets/create/models/block/placard.json @@ -34,6 +34,7 @@ { "from": [2.5, 1, 2.5], "to": [13.5, 3, 13.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 11, 12, 12], "rotation": 180, "texture": "#0"}, @@ -47,6 +48,7 @@ { "from": [10.7, 2.5, 4.3], "to": [11.7, 3.5, 5.3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [12, 1, 13, 2], "rotation": 180, "texture": "#0"}, @@ -59,6 +61,7 @@ { "from": [4.3, 2.5, 10.7], "to": [5.3, 3.5, 11.7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [12, 1, 13, 2], "rotation": 180, "texture": "#0"}, @@ -108,4 +111,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/portable_fluid_interface/block_top.json b/src/main/resources/assets/create/models/block/portable_fluid_interface/block_top.json index 3815c2846d..7c160d25eb 100644 --- a/src/main/resources/assets/create/models/block/portable_fluid_interface/block_top.json +++ b/src/main/resources/assets/create/models/block/portable_fluid_interface/block_top.json @@ -32,6 +32,7 @@ { "from": [4, 13.1, 13], "to": [6, 15.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 14, 13]}, "faces": { "east": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -42,6 +43,7 @@ { "from": [10, 13.1, 2], "to": [12, 15.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 14, 3]}, "faces": { "north": {"uv": [10, 15, 11, 16], "texture": "#0"}, @@ -52,6 +54,7 @@ { "from": [2, 13.1, 4], "to": [3, 15.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 14, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -62,6 +65,7 @@ { "from": [13, 13.1, 10], "to": [14, 15.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 14, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -72,6 +76,7 @@ { "from": [10, 13.1, 13], "to": [12, 15.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 14, 13]}, "faces": { "east": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -82,6 +87,7 @@ { "from": [4, 13.1, 2], "to": [6, 15.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 14, 3]}, "faces": { "north": {"uv": [13, 15, 14, 16], "texture": "#0"}, @@ -92,6 +98,7 @@ { "from": [2, 13.1, 10], "to": [3, 15.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 14, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -102,6 +109,7 @@ { "from": [13, 13.1, 4], "to": [14, 15.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 14, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -181,4 +189,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/portable_fluid_interface/item.json b/src/main/resources/assets/create/models/block/portable_fluid_interface/item.json index 19312bcc8f..f2aa756a7f 100644 --- a/src/main/resources/assets/create/models/block/portable_fluid_interface/item.json +++ b/src/main/resources/assets/create/models/block/portable_fluid_interface/item.json @@ -92,6 +92,7 @@ { "from": [4, 16.1, 13], "to": [6, 18.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 17, 13]}, "faces": { "east": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -102,6 +103,7 @@ { "from": [10, 16.1, 2], "to": [12, 18.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 17, 3]}, "faces": { "north": {"uv": [10, 15, 11, 16], "texture": "#0"}, @@ -112,6 +114,7 @@ { "from": [2, 16.1, 4], "to": [3, 18.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 17, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -122,6 +125,7 @@ { "from": [13, 16.1, 10], "to": [14, 18.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 17, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -132,6 +136,7 @@ { "from": [10, 16.1, 13], "to": [12, 18.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 17, 13]}, "faces": { "east": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -142,6 +147,7 @@ { "from": [4, 16.1, 2], "to": [6, 18.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 17, 3]}, "faces": { "north": {"uv": [13, 15, 14, 16], "texture": "#0"}, @@ -152,6 +158,7 @@ { "from": [2, 16.1, 10], "to": [3, 18.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 17, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -162,6 +169,7 @@ { "from": [13, 16.1, 4], "to": [14, 18.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 17, 8]}, "faces": { "north": {"uv": [6.5, 7.5, 7, 8], "texture": "#0"}, @@ -241,4 +249,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/portable_storage_interface/block_top.json b/src/main/resources/assets/create/models/block/portable_storage_interface/block_top.json index 88f35fcabe..f09e4f8fca 100644 --- a/src/main/resources/assets/create/models/block/portable_storage_interface/block_top.json +++ b/src/main/resources/assets/create/models/block/portable_storage_interface/block_top.json @@ -32,6 +32,7 @@ { "from": [4, 13.1, 13], "to": [6, 15.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 14, 13]}, "faces": { "east": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -42,6 +43,7 @@ { "from": [10, 13.1, 2], "to": [12, 15.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 14, 3]}, "faces": { "north": {"uv": [10, 15, 11, 16], "texture": "#0"}, @@ -52,6 +54,7 @@ { "from": [2, 13.1, 4], "to": [3, 15.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 14, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -62,6 +65,7 @@ { "from": [13, 13.1, 10], "to": [14, 15.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 14, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -72,6 +76,7 @@ { "from": [10, 13.1, 13], "to": [12, 15.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 14, 13]}, "faces": { "east": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -82,6 +87,7 @@ { "from": [4, 13.1, 2], "to": [6, 15.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 14, 3]}, "faces": { "north": {"uv": [13, 15, 14, 16], "texture": "#0"}, @@ -92,6 +98,7 @@ { "from": [2, 13.1, 10], "to": [3, 15.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 14, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -102,6 +109,7 @@ { "from": [13, 13.1, 4], "to": [14, 15.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 14, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -117,4 +125,4 @@ "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/portable_storage_interface/item.json b/src/main/resources/assets/create/models/block/portable_storage_interface/item.json index 81d7071603..3d5defe3fa 100644 --- a/src/main/resources/assets/create/models/block/portable_storage_interface/item.json +++ b/src/main/resources/assets/create/models/block/portable_storage_interface/item.json @@ -91,6 +91,7 @@ { "from": [4, 16.1, 13], "to": [6, 18.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 17, 13]}, "faces": { "east": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -101,6 +102,7 @@ { "from": [10, 16.1, 2], "to": [12, 18.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 17, 3]}, "faces": { "north": {"uv": [10, 15, 11, 16], "texture": "#0"}, @@ -111,6 +113,7 @@ { "from": [2, 16.1, 4], "to": [3, 18.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 17, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -121,6 +124,7 @@ { "from": [13, 16.1, 10], "to": [14, 18.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 17, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -131,6 +135,7 @@ { "from": [10, 16.1, 13], "to": [12, 18.1, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 17, 13]}, "faces": { "east": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -141,6 +146,7 @@ { "from": [4, 16.1, 2], "to": [6, 18.1, 3], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 17, 3]}, "faces": { "north": {"uv": [13, 15, 14, 16], "texture": "#0"}, @@ -151,6 +157,7 @@ { "from": [2, 16.1, 10], "to": [3, 18.1, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [3, 17, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -161,6 +168,7 @@ { "from": [13, 16.1, 4], "to": [14, 18.1, 6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [13, 17, 8]}, "faces": { "north": {"uv": [7.5, 10, 8, 10.5], "texture": "#0"}, @@ -240,4 +248,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/rope_pulley/item.json b/src/main/resources/assets/create/models/block/rope_pulley/item.json index ed905e4591..fab68e5d39 100644 --- a/src/main/resources/assets/create/models/block/rope_pulley/item.json +++ b/src/main/resources/assets/create/models/block/rope_pulley/item.json @@ -17,6 +17,7 @@ "name": "coil", "from": [4, 4, 2], "to": [12, 12, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "east": {"uv": [0, 0, 12, 8], "texture": "#5"}, @@ -29,6 +30,7 @@ "name": "coil", "from": [3.5, 3.5, 9], "to": [12.5, 12.5, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "north": {"uv": [0, 0, 9, 9], "texture": "#5"}, @@ -43,6 +45,7 @@ "name": "coil", "from": [3.5, 3.5, 3], "to": [12.5, 12.5, 7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "north": {"uv": [0, 0, 9, 9], "texture": "#5"}, @@ -364,4 +367,4 @@ 20, 21 ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/rope_pulley/rope_coil.json b/src/main/resources/assets/create/models/block/rope_pulley/rope_coil.json index f29424c95a..8649b41042 100644 --- a/src/main/resources/assets/create/models/block/rope_pulley/rope_coil.json +++ b/src/main/resources/assets/create/models/block/rope_pulley/rope_coil.json @@ -9,6 +9,7 @@ "name": "coil", "from": [4, 4, 2], "to": [12, 12, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "east": {"uv": [0, 0, 12, 8], "texture": "#5"}, @@ -21,6 +22,7 @@ "name": "coil", "from": [3.5, 3.5, 9], "to": [12.5, 12.5, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "north": {"uv": [0, 0, 9, 9], "texture": "#5"}, @@ -35,6 +37,7 @@ "name": "coil", "from": [3.5, 3.5, 3], "to": [12.5, 12.5, 7], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 8, -10]}, "faces": { "north": {"uv": [0, 0, 9, 9], "texture": "#5"}, @@ -46,4 +49,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/schematicannon/block.json b/src/main/resources/assets/create/models/block/schematicannon/block.json index 3a2bc897a4..0eaef656cd 100644 --- a/src/main/resources/assets/create/models/block/schematicannon/block.json +++ b/src/main/resources/assets/create/models/block/schematicannon/block.json @@ -13,6 +13,7 @@ "name": "Cube", "from": [-2, -0.2, 5], "to": [18, 3, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 16, 3], "texture": "#0"}, @@ -27,6 +28,7 @@ "name": "Cube", "from": [-2, -0.1, 5], "to": [18, 3, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 16, 3], "texture": "#0"}, @@ -58,4 +60,4 @@ "children": [0, 1, 2] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/schematicannon/item.json b/src/main/resources/assets/create/models/block/schematicannon/item.json index 2efe2cb445..6e0697ef60 100644 --- a/src/main/resources/assets/create/models/block/schematicannon/item.json +++ b/src/main/resources/assets/create/models/block/schematicannon/item.json @@ -16,6 +16,7 @@ "name": "Cube", "from": [4, 30, 4], "to": [12, 32, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 15, 0]}, "faces": { "north": {"uv": [6, 0, 14, 2], "texture": "#3"}, @@ -30,6 +31,7 @@ "name": "Cube", "from": [4.5, 20, 4.5], "to": [11.5, 31, 11.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 15, 0]}, "faces": { "north": {"uv": [8, 1, 15, 12], "texture": "#3"}, @@ -44,6 +46,7 @@ "name": "Cube", "from": [6, 13, -1.5], "to": [10, 17, 17.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 15, 0]}, "faces": { "north": {"uv": [10, 8, 14, 12], "texture": "#3"}, @@ -58,6 +61,7 @@ "name": "Cube", "from": [3.5, 10, 3.5], "to": [12.5, 20, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 15, 0]}, "faces": { "north": {"uv": [4, 6, 13, 16], "texture": "#3"}, @@ -109,6 +113,7 @@ "name": "Cube", "from": [-2, -0.2, 5], "to": [18, 3, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 16, 3], "texture": "#0"}, @@ -123,6 +128,7 @@ "name": "Cube", "from": [-2, -0.1, 5], "to": [18, 3, 11], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 16, 3], "texture": "#0"}, @@ -197,4 +203,4 @@ "children": [7, 8, 9] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/smart_fluid_pipe/block.json b/src/main/resources/assets/create/models/block/smart_fluid_pipe/block.json index 1f67458820..613fdf15a4 100644 --- a/src/main/resources/assets/create/models/block/smart_fluid_pipe/block.json +++ b/src/main/resources/assets/create/models/block/smart_fluid_pipe/block.json @@ -44,6 +44,7 @@ { "from": [4.5, 5, 7.15], "to": [11.5, 12, 13.15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 12, 13]}, "faces": { "north": {"uv": [1, 9, 7, 15], "texture": "#3"}, @@ -56,6 +57,7 @@ { "from": [3.9, 4.4, 4.15], "to": [12.1, 12.6, 7.15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 12, 13]}, "faces": { "north": {"uv": [8, 8, 16, 16], "texture": "#3"}, @@ -67,4 +69,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/smart_fluid_pipe/item.json b/src/main/resources/assets/create/models/block/smart_fluid_pipe/item.json index a3df689d89..1f445f3e38 100644 --- a/src/main/resources/assets/create/models/block/smart_fluid_pipe/item.json +++ b/src/main/resources/assets/create/models/block/smart_fluid_pipe/item.json @@ -70,6 +70,7 @@ { "from": [4.5, 5, 7.15], "to": [11.5, 12, 13.15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 12, 13]}, "faces": { "north": {"uv": [1, 9, 7, 15], "texture": "#3"}, @@ -82,6 +83,7 @@ { "from": [3.9, 4.4, 4.15], "to": [12.1, 12.6, 7.15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 12, 13]}, "faces": { "north": {"uv": [8, 8, 16, 16], "texture": "#3"}, @@ -124,4 +126,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/steam_engine/item.json b/src/main/resources/assets/create/models/block/steam_engine/item.json index 3e1797a1a0..b6757a18f3 100644 --- a/src/main/resources/assets/create/models/block/steam_engine/item.json +++ b/src/main/resources/assets/create/models/block/steam_engine/item.json @@ -67,6 +67,7 @@ { "from": [6, 22, 4], "to": [10, 28, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [15, 25, 8]}, "faces": { "north": {"uv": [8.5, 11, 10.5, 14], "rotation": 180, "texture": "#0"}, @@ -80,6 +81,7 @@ { "from": [6, 8, 4], "to": [10, 14, 12], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [15, 25, 8]}, "faces": { "north": {"uv": [8.5, 11, 10.5, 14], "rotation": 180, "texture": "#0"}, @@ -93,6 +95,7 @@ { "from": [6, 14, 6], "to": [10, 22, 10], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [15, 25, 8]}, "faces": { "north": {"uv": [1.5, 1, 3.5, 6], "rotation": 180, "texture": "#0"}, @@ -154,4 +157,4 @@ "children": [5, 6, 7] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/symmetry_effect/crossplane.json b/src/main/resources/assets/create/models/block/symmetry_effect/crossplane.json index 0fdbb96684..b6d97b9eb7 100644 --- a/src/main/resources/assets/create/models/block/symmetry_effect/crossplane.json +++ b/src/main/resources/assets/create/models/block/symmetry_effect/crossplane.json @@ -22,6 +22,7 @@ "name": "rod_left_bottom", "from": [1, 3, 7], "to": [3, 4, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -36,6 +37,7 @@ "name": "rod_left_bottom", "from": [13, 3, 7], "to": [15, 4, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -50,6 +52,7 @@ "name": "rod_left_top", "from": [1, 12, 7], "to": [3, 13, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -64,6 +67,7 @@ "name": "rod_left_top", "from": [13, 12, 7], "to": [15, 13, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -79,6 +83,7 @@ "from": [1, 4, 7.5], "to": [3, 12, 8.5], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [3, 5, 1, 13], "texture": "#2"}, @@ -92,6 +97,7 @@ "from": [13, 4, 7.5], "to": [15, 12, 8.5], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 3, 3, 11], "texture": "#2"}, @@ -140,4 +146,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/symmetry_effect/tripleplane.json b/src/main/resources/assets/create/models/block/symmetry_effect/tripleplane.json index 99450d7cab..ffd609b860 100644 --- a/src/main/resources/assets/create/models/block/symmetry_effect/tripleplane.json +++ b/src/main/resources/assets/create/models/block/symmetry_effect/tripleplane.json @@ -61,6 +61,7 @@ "name": "Cube", "from": [7.5, 6, -0.5], "to": [8.5, 10, 3.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [4, 1, 5, 5], "texture": "#0"}, @@ -75,6 +76,7 @@ "name": "Cube", "from": [7.5, 6, 12.5], "to": [8.5, 10, 16.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [4, 1, 5, 5], "texture": "#0"}, @@ -89,6 +91,7 @@ "name": "rod_left_bottom", "from": [1, 3, 7], "to": [3, 4, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -103,6 +106,7 @@ "name": "rod_left_bottom", "from": [13, 3, 7], "to": [15, 4, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -117,6 +121,7 @@ "name": "rod_left_top", "from": [1, 12, 7], "to": [3, 13, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -131,6 +136,7 @@ "name": "rod_left_top", "from": [13, 12, 7], "to": [15, 13, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [0, 0, 2, 1], "texture": "#2"}, @@ -146,6 +152,7 @@ "from": [1, 4, 7.5], "to": [3, 12, 8.5], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [3, 5, 1, 13], "texture": "#2"}, @@ -159,6 +166,7 @@ "from": [13, 4, 7.5], "to": [15, 12, 8.5], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1, 3, 3, 11], "texture": "#2"}, @@ -175,4 +183,4 @@ "children": [6, 7, 8, 9, 10, 11] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/toolbox/lid/brown.json b/src/main/resources/assets/create/models/block/toolbox/lid/brown.json index f352cd3961..62b9011110 100644 --- a/src/main/resources/assets/create/models/block/toolbox/lid/brown.json +++ b/src/main/resources/assets/create/models/block/toolbox/lid/brown.json @@ -5,7 +5,8 @@ "0": "create:block/toolbox/brown", "particle": "block/dark_oak_planks" }, - "elements": [ + "render_type": "minecraft:cutout", + "elements": [ { "from": [1, 6, 4], "to": [15, 9, 12], @@ -56,4 +57,4 @@ } ], "display": {} -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/ascending_template.json.donotload b/src/main/resources/assets/create/models/block/track/ascending_template.json.donotload index d4f4829352..c8be741953 100644 --- a/src/main/resources/assets/create/models/block/track/ascending_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/ascending_template.json.donotload @@ -11,6 +11,7 @@ "name": "cube1", "from": [16, 10.6, 22.1], "to": [37.95, 14.7, 26.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1_0"}, @@ -22,6 +23,7 @@ "name": "cube2", "from": [16, 10.6, 14.6], "to": [37.95, 14.7, 18.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1_0"}, @@ -33,6 +35,7 @@ "name": "cube3", "from": [-5.95, 10.6, 22.1], "to": [16, 14.7, 26.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1_0"}, @@ -44,6 +47,7 @@ "name": "cube5", "from": [16, 10.6, 29.6], "to": [37.95, 14.7, 33.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1_0"}, @@ -55,6 +59,7 @@ "name": "cube4", "from": [-5.95, 10.6, 29.6], "to": [16, 14.7, 33.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1_0"}, @@ -66,6 +71,7 @@ "name": "cube6", "from": [-5.95, 10.6, 14.6], "to": [16, 14.7, 18.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1_0"}, @@ -77,6 +83,7 @@ "name": "cube7", "from": [-5.95, 10.6, 12.6], "to": [16, 14.7, 20.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -87,6 +94,7 @@ "name": "cube8", "from": [-5.95, 10.6, 20.1], "to": [16, 14.7, 28.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -97,6 +105,7 @@ "name": "cube9", "from": [-5.95, 10.6, 27.6], "to": [16, 14.7, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -107,6 +116,7 @@ "name": "cube10", "from": [16, 10.6, 12.6], "to": [37.95, 14.7, 20.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -117,6 +127,7 @@ "name": "cube11", "from": [16, 10.6, 20.1], "to": [37.95, 14.7, 28.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -127,6 +138,7 @@ "name": "cube12", "from": [16, 10.6, 27.6], "to": [37.95, 14.7, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -137,6 +149,7 @@ "name": "rail1", "from": [29.35, 13.65, 12.6], "to": [33.55, 13.7, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "rotation": 270, "texture": "#1_0"}, @@ -147,6 +160,7 @@ "name": "rail2", "from": [29.45, 18.05, 12.6], "to": [33.45, 18.1, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "rotation": 270, "texture": "#1_0"}, @@ -157,6 +171,7 @@ "name": "rail3", "from": [29.9, 13.7, 12.6], "to": [33, 18.1, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 12.5, 4], "texture": "#1_0"}, @@ -169,6 +184,7 @@ "name": "rail4", "from": [-1.45, 18.05, 12.6], "to": [2.55, 18.1, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "rotation": 270, "texture": "#1_0"}, @@ -179,6 +195,7 @@ "name": "rail5", "from": [-1, 13.7, 12.6], "to": [2.1, 18.1, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [12.5, 2, 11, 4], "texture": "#1_0"}, @@ -191,6 +208,7 @@ "name": "rail6", "from": [-1.55, 13.65, 12.6], "to": [2.65, 13.7, 35.6], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "rotation": 270, "texture": "#1_0"}, @@ -213,4 +231,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/cross_d1_xo_template.json.donotload b/src/main/resources/assets/create/models/block/track/cross_d1_xo_template.json.donotload index 4009870d3a..0881b26c1d 100644 --- a/src/main/resources/assets/create/models/block/track/cross_d1_xo_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/cross_d1_xo_template.json.donotload @@ -11,6 +11,7 @@ "name": "cube1", "from": [16, 5.95, 14], "to": [37.95, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -22,6 +23,7 @@ "name": "cube2", "from": [16, 5.95, 6.5], "to": [37.95, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -33,6 +35,7 @@ "name": "cube3", "from": [-5.95, 5.95, 14], "to": [16, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -44,6 +47,7 @@ "name": "cube5", "from": [16, 5.95, 21.5], "to": [37.95, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -55,6 +59,7 @@ "name": "cube4", "from": [-5.95, 5.95, 21.5], "to": [16, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -66,6 +71,7 @@ "name": "cube6", "from": [-5.95, 5.95, 6.5], "to": [16, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -77,6 +83,7 @@ "name": "cube7", "from": [-5.95, 5.95, 4.5], "to": [16, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -87,6 +94,7 @@ "name": "cube8", "from": [-5.95, 5.95, 12], "to": [16, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -97,6 +105,7 @@ "name": "cube9", "from": [-5.95, 5.95, 19.5], "to": [16, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -107,6 +116,7 @@ "name": "cube10", "from": [16, 5.95, 4.5], "to": [37.95, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -117,6 +127,7 @@ "name": "cube11", "from": [16, 5.95, 12], "to": [37.95, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -127,6 +138,7 @@ "name": "cube12", "from": [16, 5.95, 19.5], "to": [37.95, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -137,6 +149,7 @@ "name": "rail1", "from": [29.35, 9, 4.5], "to": [33.55, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "rotation": 270, "texture": "#1"}, @@ -147,6 +160,7 @@ "name": "rail2", "from": [29.45, 13.4, 4.5], "to": [33.45, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "rotation": 270, "texture": "#1"}, @@ -157,6 +171,7 @@ "name": "rail3", "from": [29.9, 9.05, 4.5], "to": [33, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 12.5, 4], "texture": "#1"}, @@ -169,6 +184,7 @@ "name": "rail4", "from": [-1.45, 13.4, 4.5], "to": [2.55, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "rotation": 270, "texture": "#1"}, @@ -179,6 +195,7 @@ "name": "rail5", "from": [-1, 9.05, 4.5], "to": [2.1, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [12.5, 2, 11, 4], "texture": "#1"}, @@ -191,6 +208,7 @@ "name": "rail6", "from": [-1.55, 9, 4.5], "to": [2.65, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "rotation": 270, "texture": "#1"}, @@ -346,4 +364,4 @@ 28, 29 ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/cross_d1_zo_template.json.donotload b/src/main/resources/assets/create/models/block/track/cross_d1_zo_template.json.donotload index f7bfa144d3..6612ec4f63 100644 --- a/src/main/resources/assets/create/models/block/track/cross_d1_zo_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/cross_d1_zo_template.json.donotload @@ -11,6 +11,7 @@ "name": "cube1", "from": [16, 5.95, 14], "to": [37.95, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -22,6 +23,7 @@ "name": "cube2", "from": [16, 5.95, 6.5], "to": [37.95, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -33,6 +35,7 @@ "name": "cube3", "from": [-5.95, 5.95, 14], "to": [16, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -44,6 +47,7 @@ "name": "cube5", "from": [16, 5.95, 21.5], "to": [37.95, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -55,6 +59,7 @@ "name": "cube4", "from": [-5.95, 5.95, 21.5], "to": [16, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -66,6 +71,7 @@ "name": "cube6", "from": [-5.95, 5.95, 6.5], "to": [16, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -77,6 +83,7 @@ "name": "cube7", "from": [-5.95, 5.95, 4.5], "to": [16, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -87,6 +94,7 @@ "name": "cube8", "from": [-5.95, 5.95, 12], "to": [16, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -97,6 +105,7 @@ "name": "cube9", "from": [-5.95, 5.95, 19.5], "to": [16, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -107,6 +116,7 @@ "name": "cube10", "from": [16, 5.95, 4.5], "to": [37.95, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -117,6 +127,7 @@ "name": "cube11", "from": [16, 5.95, 12], "to": [37.95, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -127,6 +138,7 @@ "name": "cube12", "from": [16, 5.95, 19.5], "to": [37.95, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -137,6 +149,7 @@ "name": "rail1", "from": [29.35, 9, 4.5], "to": [33.55, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "rotation": 270, "texture": "#1"}, @@ -147,6 +160,7 @@ "name": "rail2", "from": [29.45, 13.4, 4.5], "to": [33.45, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "rotation": 270, "texture": "#1"}, @@ -157,6 +171,7 @@ "name": "rail3", "from": [29.9, 9.05, 4.5], "to": [33, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 12.5, 4], "texture": "#1"}, @@ -169,6 +184,7 @@ "name": "rail4", "from": [-1.45, 13.4, 4.5], "to": [2.55, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "rotation": 270, "texture": "#1"}, @@ -179,6 +195,7 @@ "name": "rail5", "from": [-1, 9.05, 4.5], "to": [2.1, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [12.5, 2, 11, 4], "texture": "#1"}, @@ -191,6 +208,7 @@ "name": "rail6", "from": [-1.55, 9, 4.5], "to": [2.65, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "rotation": 270, "texture": "#1"}, @@ -347,4 +365,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/cross_d2_xo_template.json.donotload b/src/main/resources/assets/create/models/block/track/cross_d2_xo_template.json.donotload index c35020b44e..361b750820 100644 --- a/src/main/resources/assets/create/models/block/track/cross_d2_xo_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/cross_d2_xo_template.json.donotload @@ -11,6 +11,7 @@ "name": "cube1", "from": [14, 6.0125, 16], "to": [18, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -22,6 +23,7 @@ "name": "cube2", "from": [21.5, 6.0125, 16], "to": [25.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -33,6 +35,7 @@ "name": "cube3", "from": [14, 6.0125, -5.95], "to": [18, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -44,6 +47,7 @@ "name": "cube5", "from": [6.5, 6.0125, 16], "to": [10.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -55,6 +59,7 @@ "name": "cube4", "from": [6.5, 6.0125, -5.95], "to": [10.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -66,6 +71,7 @@ "name": "cube6", "from": [21.5, 6.0125, -5.95], "to": [25.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -77,6 +83,7 @@ "name": "cube7", "from": [19.5, 6.0125, -5.95], "to": [27.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -87,6 +94,7 @@ "name": "cube8", "from": [12, 6.0125, -5.95], "to": [20, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -97,6 +105,7 @@ "name": "cube9", "from": [4.5, 6.0125, -5.95], "to": [12.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -107,6 +116,7 @@ "name": "cube10", "from": [19.5, 6.0125, 16], "to": [27.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -117,6 +127,7 @@ "name": "cube11", "from": [12, 6.0125, 16], "to": [20, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -127,6 +138,7 @@ "name": "cube12", "from": [4.5, 6.0125, 16], "to": [12.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -137,6 +149,7 @@ "name": "rail1", "from": [4.5, 9.0625, 29.35], "to": [27.5, 9.1125, 33.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "texture": "#1"}, @@ -147,6 +160,7 @@ "name": "rail2", "from": [4.5, 13.4625, 29.45], "to": [27.5, 13.5125, 33.45], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "texture": "#1"}, @@ -157,6 +171,7 @@ "name": "rail3", "from": [4.5, 9.1125, 29.9], "to": [27.5, 13.5125, 33], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 6, 11.5, 8], "texture": "#1"}, @@ -169,6 +184,7 @@ "name": "rail4", "from": [4.5, 13.4625, -1.45], "to": [27.5, 13.5125, 2.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "texture": "#1"}, @@ -179,6 +195,7 @@ "name": "rail5", "from": [4.5, 9.1125, -1], "to": [27.5, 13.5125, 2.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11.5, 6, 0, 8], "texture": "#1"}, @@ -191,6 +208,7 @@ "name": "rail6", "from": [4.5, 9.0625, -1.55], "to": [27.5, 9.1125, 2.65], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "texture": "#1"}, @@ -347,4 +365,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/cross_d2_zo_template.json.donotload b/src/main/resources/assets/create/models/block/track/cross_d2_zo_template.json.donotload index 4f0ceddbee..d90bedf04d 100644 --- a/src/main/resources/assets/create/models/block/track/cross_d2_zo_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/cross_d2_zo_template.json.donotload @@ -11,6 +11,7 @@ "name": "cube1", "from": [14, 6.0125, 16], "to": [18, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -22,6 +23,7 @@ "name": "cube2", "from": [21.5, 6.0125, 16], "to": [25.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -33,6 +35,7 @@ "name": "cube3", "from": [14, 6.0125, -5.95], "to": [18, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -44,6 +47,7 @@ "name": "cube5", "from": [6.5, 6.0125, 16], "to": [10.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -55,6 +59,7 @@ "name": "cube4", "from": [6.5, 6.0125, -5.95], "to": [10.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -66,6 +71,7 @@ "name": "cube6", "from": [21.5, 6.0125, -5.95], "to": [25.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -77,6 +83,7 @@ "name": "cube7", "from": [19.5, 6.0125, -5.95], "to": [27.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -87,6 +94,7 @@ "name": "cube8", "from": [12, 6.0125, -5.95], "to": [20, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -97,6 +105,7 @@ "name": "cube9", "from": [4.5, 6.0125, -5.95], "to": [12.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -107,6 +116,7 @@ "name": "cube10", "from": [19.5, 6.0125, 16], "to": [27.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -117,6 +127,7 @@ "name": "cube11", "from": [12, 6.0125, 16], "to": [20, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -127,6 +138,7 @@ "name": "cube12", "from": [4.5, 6.0125, 16], "to": [12.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -137,6 +149,7 @@ "name": "rail1", "from": [4.5, 9.0625, 29.35], "to": [27.5, 9.1125, 33.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "texture": "#1"}, @@ -147,6 +160,7 @@ "name": "rail2", "from": [4.5, 13.4625, 29.45], "to": [27.5, 13.5125, 33.45], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "texture": "#1"}, @@ -157,6 +171,7 @@ "name": "rail3", "from": [4.5, 9.1125, 29.9], "to": [27.5, 13.5125, 33], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 6, 11.5, 8], "texture": "#1"}, @@ -169,6 +184,7 @@ "name": "rail4", "from": [4.5, 13.4625, -1.45], "to": [27.5, 13.5125, 2.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "texture": "#1"}, @@ -179,6 +195,7 @@ "name": "rail5", "from": [4.5, 9.1125, -1], "to": [27.5, 13.5125, 2.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11.5, 6, 0, 8], "texture": "#1"}, @@ -191,6 +208,7 @@ "name": "rail6", "from": [4.5, 9.0625, -1.55], "to": [27.5, 9.1125, 2.65], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "texture": "#1"}, @@ -347,4 +365,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/cross_diag_template.json.donotload b/src/main/resources/assets/create/models/block/track/cross_diag_template.json.donotload index 4dc753565c..5c0a2ec76c 100644 --- a/src/main/resources/assets/create/models/block/track/cross_diag_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/cross_diag_template.json.donotload @@ -12,6 +12,7 @@ "name": "cube1a", "from": [16, 5.95, 14], "to": [37.95, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -23,6 +24,7 @@ "name": "cube2a", "from": [16, 5.95, 6.5], "to": [37.95, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -34,6 +36,7 @@ "name": "cube3a", "from": [-5.95, 5.95, 14], "to": [16, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -45,6 +48,7 @@ "name": "cube5a", "from": [16, 5.95, 21.5], "to": [37.95, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -56,6 +60,7 @@ "name": "cube4a", "from": [-5.95, 5.95, 21.5], "to": [16, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -67,6 +72,7 @@ "name": "cube6a", "from": [-5.95, 5.95, 6.5], "to": [16, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -78,6 +84,7 @@ "name": "cube7a", "from": [-5.95, 5.95, 4.5], "to": [16, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -88,6 +95,7 @@ "name": "cube8a", "from": [-5.95, 5.95, 12], "to": [16, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -98,6 +106,7 @@ "name": "cube9a", "from": [-5.95, 5.95, 19.5], "to": [16, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -108,6 +117,7 @@ "name": "cube10a", "from": [16, 5.95, 4.5], "to": [37.95, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -118,6 +128,7 @@ "name": "cube11a", "from": [16, 5.95, 12], "to": [37.95, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -128,6 +139,7 @@ "name": "cube12a", "from": [16, 5.95, 19.5], "to": [37.95, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -138,6 +150,7 @@ "name": "rail1a", "from": [29.35, 9, 4.5], "to": [33.55, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "rotation": 270, "texture": "#1"}, @@ -148,6 +161,7 @@ "name": "rail2a", "from": [29.45, 13.4, 4.5], "to": [33.45, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "rotation": 270, "texture": "#1"}, @@ -158,6 +172,7 @@ "name": "rail3a", "from": [29.9, 9.05, 4.5], "to": [33, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 12.5, 4], "texture": "#1"}, @@ -170,6 +185,7 @@ "name": "rail4a", "from": [-1.45, 13.4, 4.5], "to": [2.55, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "rotation": 270, "texture": "#1"}, @@ -180,6 +196,7 @@ "name": "rail5a", "from": [-1, 9.05, 4.5], "to": [2.1, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [12.5, 2, 11, 4], "texture": "#1"}, @@ -192,6 +209,7 @@ "name": "rail6a", "from": [-1.55, 9, 4.5], "to": [2.65, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "rotation": 270, "texture": "#1"}, @@ -202,6 +220,7 @@ "name": "cube1", "from": [14, 6.0125, 16], "to": [18, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -213,6 +232,7 @@ "name": "cube2", "from": [21.5, 6.0125, 16], "to": [25.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -224,6 +244,7 @@ "name": "cube3", "from": [14, 6.0125, -5.95], "to": [18, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -235,6 +256,7 @@ "name": "cube5", "from": [6.5, 6.0125, 16], "to": [10.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -246,6 +268,7 @@ "name": "cube4", "from": [6.5, 6.0125, -5.95], "to": [10.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -257,6 +280,7 @@ "name": "cube6", "from": [21.5, 6.0125, -5.95], "to": [25.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -268,6 +292,7 @@ "name": "middle", "from": [2, 5.9125, 2], "to": [30, 10.1625, 30], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [1, 13, 15, 15], "texture": "#3"}, @@ -282,6 +307,7 @@ "name": "cube7", "from": [19.5, 6.0125, -5.95], "to": [27.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -292,6 +318,7 @@ "name": "cube8", "from": [12, 6.0125, -5.95], "to": [20, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -302,6 +329,7 @@ "name": "cube9", "from": [4.5, 6.0125, -5.95], "to": [12.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -312,6 +340,7 @@ "name": "cube10", "from": [19.5, 6.0125, 16], "to": [27.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -322,6 +351,7 @@ "name": "cube11", "from": [12, 6.0125, 16], "to": [20, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -332,6 +362,7 @@ "name": "cube12", "from": [4.5, 6.0125, 16], "to": [12.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -342,6 +373,7 @@ "name": "rail1", "from": [4.5, 9.0625, 29.35], "to": [27.5, 9.1125, 33.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "texture": "#1"}, @@ -352,6 +384,7 @@ "name": "rail2", "from": [4.5, 13.4625, 29.45], "to": [27.5, 13.5125, 33.45], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "texture": "#1"}, @@ -362,6 +395,7 @@ "name": "rail3", "from": [4.5, 9.1125, 29.9], "to": [27.5, 13.5125, 33], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 6, 11.5, 8], "texture": "#1"}, @@ -374,6 +408,7 @@ "name": "rail4", "from": [4.5, 13.4625, -1.45], "to": [27.5, 13.5125, 2.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "texture": "#1"}, @@ -384,6 +419,7 @@ "name": "rail5", "from": [4.5, 9.1125, -1], "to": [27.5, 13.5125, 2.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11.5, 6, 0, 8], "texture": "#1"}, @@ -396,6 +432,7 @@ "name": "rail6", "from": [4.5, 9.0625, -1.55], "to": [27.5, 9.1125, 2.65], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "texture": "#1"}, @@ -403,4 +440,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/diag_2_template.json.donotload b/src/main/resources/assets/create/models/block/track/diag_2_template.json.donotload index 4ae06b98af..fbee6ee6ef 100644 --- a/src/main/resources/assets/create/models/block/track/diag_2_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/diag_2_template.json.donotload @@ -11,6 +11,7 @@ "name": "cube1", "from": [14, 6.0125, 16], "to": [18, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -22,6 +23,7 @@ "name": "cube2", "from": [21.5, 6.0125, 16], "to": [25.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -33,6 +35,7 @@ "name": "cube3", "from": [14, 6.0125, -5.95], "to": [18, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -44,6 +47,7 @@ "name": "cube5", "from": [6.5, 6.0125, 16], "to": [10.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -55,6 +59,7 @@ "name": "cube4", "from": [6.5, 6.0125, -5.95], "to": [10.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -66,6 +71,7 @@ "name": "cube6", "from": [21.5, 6.0125, -5.95], "to": [25.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -77,6 +83,7 @@ "name": "cube7", "from": [19.5, 6.0125, -5.95], "to": [27.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -87,6 +94,7 @@ "name": "cube8", "from": [12, 6.0125, -5.95], "to": [20, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -97,6 +105,7 @@ "name": "cube9", "from": [4.5, 6.0125, -5.95], "to": [12.5, 10.1125, 16], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -107,6 +116,7 @@ "name": "cube10", "from": [19.5, 6.0125, 16], "to": [27.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -117,6 +127,7 @@ "name": "cube11", "from": [12, 6.0125, 16], "to": [20, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -127,6 +138,7 @@ "name": "cube12", "from": [4.5, 6.0125, 16], "to": [12.5, 10.1125, 37.95], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "south": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -137,6 +149,7 @@ "name": "rail1", "from": [4.5, 9.0625, 29.35], "to": [27.5, 9.1125, 33.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "texture": "#1"}, @@ -147,6 +160,7 @@ "name": "rail2", "from": [4.5, 13.4625, 29.45], "to": [27.5, 13.5125, 33.45], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "texture": "#1"}, @@ -157,6 +171,7 @@ "name": "rail3", "from": [4.5, 9.1125, 29.9], "to": [27.5, 13.5125, 33], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 6, 11.5, 8], "texture": "#1"}, @@ -169,6 +184,7 @@ "name": "rail4", "from": [4.5, 13.4625, -1.45], "to": [27.5, 13.5125, 2.55], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "texture": "#1"}, @@ -179,6 +195,7 @@ "name": "rail5", "from": [4.5, 9.1125, -1], "to": [27.5, 13.5125, 2.1], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11.5, 6, 0, 8], "texture": "#1"}, @@ -191,6 +208,7 @@ "name": "rail6", "from": [4.5, 9.0625, -1.55], "to": [27.5, 9.1125, 2.65], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "texture": "#1"}, @@ -206,4 +224,4 @@ "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/diag_template.json.donotload b/src/main/resources/assets/create/models/block/track/diag_template.json.donotload index fcef2d4fb1..0ef1ca40d5 100644 --- a/src/main/resources/assets/create/models/block/track/diag_template.json.donotload +++ b/src/main/resources/assets/create/models/block/track/diag_template.json.donotload @@ -11,6 +11,7 @@ "name": "cube1", "from": [16, 5.95, 14], "to": [37.95, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -22,6 +23,7 @@ "name": "cube2", "from": [16, 5.95, 6.5], "to": [37.95, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -33,6 +35,7 @@ "name": "cube3", "from": [-5.95, 5.95, 14], "to": [16, 10.05, 18], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -44,6 +47,7 @@ "name": "cube5", "from": [16, 5.95, 21.5], "to": [37.95, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 0, 4], "texture": "#1"}, @@ -55,6 +59,7 @@ "name": "cube4", "from": [-5.95, 5.95, 21.5], "to": [16, 10.05, 25.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -66,6 +71,7 @@ "name": "cube6", "from": [-5.95, 5.95, 6.5], "to": [16, 10.05, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [0, 2, 11, 4], "texture": "#1"}, @@ -77,6 +83,7 @@ "name": "cube7", "from": [-5.95, 5.95, 4.5], "to": [16, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -87,6 +94,7 @@ "name": "cube8", "from": [-5.95, 5.95, 12], "to": [16, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -97,6 +105,7 @@ "name": "cube9", "from": [-5.95, 5.95, 19.5], "to": [16, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "west": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -107,6 +116,7 @@ "name": "cube10", "from": [16, 5.95, 4.5], "to": [37.95, 10.05, 12.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -117,6 +127,7 @@ "name": "cube11", "from": [16, 5.95, 12], "to": [37.95, 10.05, 20], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -127,6 +138,7 @@ "name": "cube12", "from": [16, 5.95, 19.5], "to": [37.95, 10.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "east": {"uv": [11, 4.5, 13, 8.5], "rotation": 90, "texture": "#2"}, @@ -137,6 +149,7 @@ "name": "rail1", "from": [29.35, 9, 4.5], "to": [33.55, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 8.5, 11.5, 10.5], "rotation": 270, "texture": "#1"}, @@ -147,6 +160,7 @@ "name": "rail2", "from": [29.45, 13.4, 4.5], "to": [33.45, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 11.5, 11.5, 13.5], "rotation": 270, "texture": "#1"}, @@ -157,6 +171,7 @@ "name": "rail3", "from": [29.9, 9.05, 4.5], "to": [33, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [11, 2, 12.5, 4], "texture": "#1"}, @@ -169,6 +184,7 @@ "name": "rail4", "from": [-1.45, 13.4, 4.5], "to": [2.55, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 13.5, 11.5, 11.5], "rotation": 270, "texture": "#1"}, @@ -179,6 +195,7 @@ "name": "rail5", "from": [-1, 9.05, 4.5], "to": [2.1, 13.45, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "north": {"uv": [12.5, 2, 11, 4], "texture": "#1"}, @@ -191,6 +208,7 @@ "name": "rail6", "from": [-1.55, 9, 4.5], "to": [2.65, 9.05, 27.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [16, 8, 16]}, "faces": { "up": {"uv": [0, 10.5, 11.5, 8.5], "rotation": 270, "texture": "#1"}, @@ -206,4 +224,4 @@ "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/track/tie.json b/src/main/resources/assets/create/models/block/track/tie.json index 3f199f4797..4278f784e5 100644 --- a/src/main/resources/assets/create/models/block/track/tie.json +++ b/src/main/resources/assets/create/models/block/track/tie.json @@ -2,5 +2,6 @@ "parent": "create:block/track/obj_track", "loader": "forge:obj", "flip_v": true, + "render_type": "minecraft:cutout_mipped", "model": "create:models/block/track/tie.obj" -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/weighted_ejector/item.json b/src/main/resources/assets/create/models/block/weighted_ejector/item.json index 9a64f9ae59..9efcb87d4b 100644 --- a/src/main/resources/assets/create/models/block/weighted_ejector/item.json +++ b/src/main/resources/assets/create/models/block/weighted_ejector/item.json @@ -83,6 +83,7 @@ { "from": [7, 2, 0], "to": [9, 11, 2], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 11, 1]}, "faces": { "north": {"uv": [3, 0, 5, 9], "texture": "#2"}, @@ -96,6 +97,7 @@ { "from": [7, 2, 0], "to": [9, 11, 2], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 11, 1]}, "faces": { "north": {"uv": [3, 0, 5, 9], "texture": "#2"}, @@ -109,6 +111,7 @@ { "from": [7, 10, 1], "to": [9, 12, 10], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 11, 1]}, "faces": { "north": {"uv": [0, 0, 2, 2], "rotation": 180, "texture": "#2"}, @@ -247,4 +250,4 @@ "children": [10, 11, 12, 13, 14, 15, 16, 17] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/block/weighted_ejector/top.json b/src/main/resources/assets/create/models/block/weighted_ejector/top.json index e17f41781f..b5819a6e63 100644 --- a/src/main/resources/assets/create/models/block/weighted_ejector/top.json +++ b/src/main/resources/assets/create/models/block/weighted_ejector/top.json @@ -67,6 +67,7 @@ { "from": [7, 2, 0], "to": [9, 11, 2], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 11, 1]}, "faces": { "north": {"uv": [3, 0, 5, 9], "texture": "#2"}, @@ -80,6 +81,7 @@ { "from": [7, 2, 0], "to": [9, 11, 2], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "x", "origin": [8, 11, 1]}, "faces": { "north": {"uv": [3, 0, 5, 9], "texture": "#2"}, @@ -93,6 +95,7 @@ { "from": [7, 10, 1], "to": [9, 12, 10], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 11, 1]}, "faces": { "north": {"uv": [0, 0, 2, 2], "rotation": 180, "texture": "#2"}, @@ -124,4 +127,4 @@ "children": [0, 1, 2, 3, 4, 5, 6, 7, 8] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/entity/minecart_coupling/attachment.json b/src/main/resources/assets/create/models/entity/minecart_coupling/attachment.json index 29d9735c78..ead8ea3146 100644 --- a/src/main/resources/assets/create/models/entity/minecart_coupling/attachment.json +++ b/src/main/resources/assets/create/models/entity/minecart_coupling/attachment.json @@ -21,6 +21,7 @@ { "from": [-3.5, -2.5, 0.5], "to": [2.5, -1.5, 1.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "z", "origin": [2.5, -2.5, 1.5]}, "faces": { "north": {"uv": [2, 5, 1, 10], "texture": "#0"}, @@ -32,6 +33,7 @@ { "from": [-3.5, -2.5, -1.5], "to": [2.5, -1.5, -0.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "z", "origin": [2.5, -2.5, 1.5]}, "faces": { "north": {"uv": [2, 5, 1, 10], "texture": "#0"}, @@ -53,4 +55,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/entity/train_hat.json b/src/main/resources/assets/create/models/entity/train_hat.json index 28cc936ef0..09fd97ba83 100644 --- a/src/main/resources/assets/create/models/entity/train_hat.json +++ b/src/main/resources/assets/create/models/entity/train_hat.json @@ -42,6 +42,7 @@ { "from": [-4.5, 1.3961, 4.04328], "to": [4.5, 2.3961, 6.04328], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 0, -1.5]}, "faces": { "up": {"uv": [0, 0, 9, 2], "rotation": 180, "texture": "#0"} @@ -50,10 +51,11 @@ { "from": [-4.5, 2.31684, 3.9585], "to": [4.5, 3.31684, 5.9585], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 22.5, "axis": "x", "origin": [0, 0, -1.5]}, "faces": { "down": {"uv": [0, 0, 9, 2], "texture": "#0"} } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/extendo_grip/cog.json b/src/main/resources/assets/create/models/item/extendo_grip/cog.json index 6fad79e2f4..5577039374 100644 --- a/src/main/resources/assets/create/models/item/extendo_grip/cog.json +++ b/src/main/resources/assets/create/models/item/extendo_grip/cog.json @@ -37,6 +37,7 @@ "name": "Cog", "from": [7, 5, 3], "to": [9, 13, 5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 9, 5]}, "faces": { "north": {"uv": [4, 4, 5, 9], "rotation": 180, "texture": "#cog"}, @@ -51,6 +52,7 @@ "name": "Cog", "from": [7, 5, 3], "to": [9, 13, 5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 9, 5]}, "faces": { "north": {"uv": [4, 4, 5, 9], "rotation": 180, "texture": "#cog"}, @@ -62,4 +64,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/extendo_grip/item.json b/src/main/resources/assets/create/models/item/extendo_grip/item.json index 0ac961e182..8df9643728 100644 --- a/src/main/resources/assets/create/models/item/extendo_grip/item.json +++ b/src/main/resources/assets/create/models/item/extendo_grip/item.json @@ -9,6 +9,7 @@ { "from": [7, 3.8, 11.4], "to": [9, 9.8, 14.4], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8.5, 4.5, 14]}, "faces": { "north": {"uv": [4, 6, 6, 12], "texture": "#4"}, @@ -22,6 +23,7 @@ { "from": [7.5, 4.8, 9.4], "to": [8.5, 10.8, 12.4], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 5.5, 12]}, "faces": { "north": {"uv": [14, 6, 15, 12], "texture": "#4"}, @@ -110,4 +112,4 @@ "scale": [0.5, 0.5, 0.5] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/handheld_worldshaper/accelerator.json b/src/main/resources/assets/create/models/item/handheld_worldshaper/accelerator.json index 2cd6b1b9d7..95d8ce7672 100644 --- a/src/main/resources/assets/create/models/item/handheld_worldshaper/accelerator.json +++ b/src/main/resources/assets/create/models/item/handheld_worldshaper/accelerator.json @@ -9,6 +9,7 @@ "name": "Cog", "from": [5.5, 5, 11], "to": [10.5, 6, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 5.5, 13]}, "faces": { "north": {"uv": [6, 15, 11, 16], "texture": "#2"}, @@ -23,6 +24,7 @@ "name": "Cog", "from": [5.5, 5, 11], "to": [10.5, 6, 14], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 5.5, 13]}, "faces": { "north": {"uv": [6, 15, 11, 16], "texture": "#2"}, @@ -61,4 +63,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/handheld_worldshaper/item.json b/src/main/resources/assets/create/models/item/handheld_worldshaper/item.json index 9b4f955702..557adf2f7e 100644 --- a/src/main/resources/assets/create/models/item/handheld_worldshaper/item.json +++ b/src/main/resources/assets/create/models/item/handheld_worldshaper/item.json @@ -11,6 +11,7 @@ "name": "Rod Back Cap", "from": [6.5, 4, 14], "to": [9.5, 7, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 5.5, 8]}, "faces": { "north": {"uv": [0, 0, 3, 3], "texture": "#0"}, @@ -25,6 +26,7 @@ "name": "Rod Back Cap", "from": [7, 4.5, 15], "to": [9, 6.5, 17], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 5.5, 8]}, "faces": { "north": {"uv": [0, 0, 2, 2], "texture": "#0"}, @@ -65,6 +67,7 @@ "name": "Connector", "from": [5.75, 4, 6], "to": [10.25, 8, 8], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 4, 8]}, "faces": { "north": {"uv": [5, 0, 9.5, 4], "texture": "#0"}, @@ -79,6 +82,7 @@ "name": "Connector", "from": [5.75, 4, 8], "to": [10.25, 6, 10], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "x", "origin": [8, 4, 8]}, "faces": { "north": {"uv": [0, 0, 4.5, 2], "texture": "#0"}, @@ -107,6 +111,7 @@ "name": "Grip", "from": [7.1, 1, 12], "to": [8.9, 5, 15], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 2, 14]}, "faces": { "north": {"uv": [5, 7, 6.8, 11], "texture": "#1"}, @@ -121,6 +126,7 @@ "name": "Trigger", "from": [7.4, 3, 11], "to": [8.6, 6, 13], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 2, 14]}, "faces": { "north": {"uv": [6, 4, 7, 7], "texture": "#3_0"}, @@ -135,6 +141,7 @@ "name": "Scope", "from": [7.5, 7.5, 5.5], "to": [8.5, 8.5, 10.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 4]}, "faces": { "north": {"uv": [0, 0, 1, 1], "texture": "#1"}, @@ -238,4 +245,4 @@ "children": [11, 12] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/potato_cannon/cog.json b/src/main/resources/assets/create/models/item/potato_cannon/cog.json index 023fd8b88c..7f2cb673f2 100644 --- a/src/main/resources/assets/create/models/item/potato_cannon/cog.json +++ b/src/main/resources/assets/create/models/item/potato_cannon/cog.json @@ -39,6 +39,7 @@ "name": "Cog", "from": [7.5, 6, 6.5], "to": [8.5, 11, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8.5, 7.5]}, "faces": { "north": {"uv": [6.5, 9.75, 9, 10], "rotation": 90, "texture": "#1"}, @@ -53,6 +54,7 @@ "name": "Cog", "from": [5.5, 8, 6.5], "to": [10.5, 9, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "z", "origin": [8, 8.5, 7.5]}, "faces": { "north": {"uv": [6.5, 9.75, 9, 10], "texture": "#1"}, @@ -114,4 +116,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/potato_cannon/item.json b/src/main/resources/assets/create/models/item/potato_cannon/item.json index a7388ac313..37b7f4cc28 100644 --- a/src/main/resources/assets/create/models/item/potato_cannon/item.json +++ b/src/main/resources/assets/create/models/item/potato_cannon/item.json @@ -70,6 +70,7 @@ { "from": [6.5, 4.5, 8.5], "to": [9.5, 7.5, 14.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "z", "origin": [8, 6, 11.5]}, "faces": { "north": {"uv": [3, 6, 4.5, 7.5], "rotation": 90, "texture": "#1"}, diff --git a/src/main/resources/assets/create/models/item/wand_of_symmetry/bits.json b/src/main/resources/assets/create/models/item/wand_of_symmetry/bits.json index bf6751f712..e8f90ba437 100644 --- a/src/main/resources/assets/create/models/item/wand_of_symmetry/bits.json +++ b/src/main/resources/assets/create/models/item/wand_of_symmetry/bits.json @@ -13,9 +13,10 @@ "elements": [ { "name": "Square North", - "from": [ 7.5, 24.0, 4.0 ], - "to": [ 8.5, 25.0, 5.0 ], + "from": [ 7.5, 24.0, 4.0 ], + "to": [ 8.5, 25.0, 5.0 ], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": { "origin": [ 9.0, 24.0, 5.0 ], "axis": "x", "angle": 45.0 }, "faces": { "north": { "texture": "#3", "uv": [ 2.0, 2.0, 3.0, 3.0 ] }, @@ -28,9 +29,10 @@ }, { "name": "Square South", - "from": [ 7.5, 24.0, 10.0 ], - "to": [ 8.5, 25.0, 11.0 ], + "from": [ 7.5, 24.0, 10.0 ], + "to": [ 8.5, 25.0, 11.0 ], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": { "origin": [ 13.0, 24.0, 11.0 ], "axis": "x", "angle": 45.0 }, "faces": { "north": { "texture": "#3", "uv": [ 2.0, 2.0, 3.0, 3.0 ] }, @@ -43,9 +45,10 @@ }, { "name": "Square West", - "from": [ 11.5, 25.5, 7.5 ], - "to": [ 12.5, 26.5, 8.5 ], + "from": [ 11.5, 25.5, 7.5 ], + "to": [ 12.5, 26.5, 8.5 ], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": { "origin": [ 13.0, 24.0, 11.0 ], "axis": "z", "angle": 45.0 }, "faces": { "north": { "texture": "#3", "uv": [ 2.0, 2.0, 3.0, 3.0 ] }, @@ -58,9 +61,10 @@ }, { "name": "Square East", - "from": [ 7.5, 29.5, 7.5 ], - "to": [ 8.5, 30.5, 8.5 ], + "from": [ 7.5, 29.5, 7.5 ], + "to": [ 8.5, 30.5, 8.5 ], "shade": false, + "forge_data": {"calculate_normals": true}, "rotation": { "origin": [ 13.0, 24.0, 11.0 ], "axis": "z", "angle": 45.0 }, "faces": { "north": { "texture": "#3", "uv": [ 2.0, 2.0, 3.0, 3.0 ] }, @@ -72,4 +76,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/wand_of_symmetry/item.json b/src/main/resources/assets/create/models/item/wand_of_symmetry/item.json index 530067fc52..745d4acc48 100644 --- a/src/main/resources/assets/create/models/item/wand_of_symmetry/item.json +++ b/src/main/resources/assets/create/models/item/wand_of_symmetry/item.json @@ -25,6 +25,7 @@ "name": "Rod Bottom Core", "from": [6.5, 7, 6.5], "to": [9.5, 17, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [5, 6, 8, 16], "texture": "#6"}, @@ -52,6 +53,7 @@ "name": "Rod Top Core", "from": [6.5, 27, 6.5], "to": [9.5, 30, 9.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [8, 1, 11, 4], "texture": "#6"}, @@ -123,4 +125,4 @@ "translation": [0, -5, 0] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/wrench/gear.json b/src/main/resources/assets/create/models/item/wrench/gear.json index 05ffe56655..c442818c51 100644 --- a/src/main/resources/assets/create/models/item/wrench/gear.json +++ b/src/main/resources/assets/create/models/item/wrench/gear.json @@ -24,6 +24,7 @@ "name": "Cog", "from": [8.5, 7, 6], "to": [9.5, 8, 10], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [9, 7, 8]}, "faces": { "north": {"uv": [10, 14, 12, 16], "texture": "#5"}, @@ -52,6 +53,7 @@ "name": "Cog", "from": [7, 7, 7.5], "to": [11, 8, 8.5], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [9, 7, 8]}, "faces": { "north": {"uv": [2, 14, 10, 16], "rotation": 180, "texture": "#5"}, @@ -63,4 +65,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/models/item/wrench/item.json b/src/main/resources/assets/create/models/item/wrench/item.json index 9c89b0ff6e..1507d8f730 100644 --- a/src/main/resources/assets/create/models/item/wrench/item.json +++ b/src/main/resources/assets/create/models/item/wrench/item.json @@ -37,6 +37,7 @@ "name": "axle", "from": [8.35355, 5, 7.14645], "to": [9.35355, 12, 8.14645], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": -45, "axis": "y", "origin": [8.5, 11, 8]}, "faces": { "north": {"uv": [0, 0, 2, 14], "texture": "#5"}, @@ -93,6 +94,7 @@ "name": "gear case", "from": [7.5, 6, 7], "to": [9.5, 7, 9], + "forge_data": {"calculate_normals": true}, "rotation": {"angle": 45, "axis": "y", "origin": [8.5, 11, 8]}, "faces": { "north": {"uv": [12, 12, 16, 14], "texture": "#5"}, @@ -144,4 +146,4 @@ "children": [0, 1, 2, 3, 4, 5, 6] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 61c014448c..30f7228850 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -29,11 +29,13 @@ ], "client": [ "accessor.AgeableListModelAccessor", + "accessor.BufferBuilderAccessor", "accessor.FontAccessor", "accessor.GameRendererAccessor", "accessor.HumanoidArmorLayerAccessor", "accessor.MouseHandlerAccessor", "accessor.ParticleEngineAccessor", + "accessor.RenderSystemAccessor", "client.BlockDestructionProgressMixin", "client.CameraMixin", "client.EntityContraptionInteractionMixin",