Merge remote-tracking branch 'upstream/mc1.18/dev' into mc1.18/dev

# Conflicts:
#	src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java
This commit is contained in:
Aeiou 2021-12-24 21:41:27 -05:00
commit 658f5125e0
100 changed files with 784 additions and 451 deletions

View file

@ -21,7 +21,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
// apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false');
// jozu: I use a gradle workspace with both projects.
@ -39,8 +39,7 @@ 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'))
minecraft {
// mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
mappings channel: 'official', version: "${minecraft_version}"
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {

View file

@ -6,7 +6,7 @@ org.gradle.daemon = false
# mod version info
mod_version = 0.4a
minecraft_version = 1.18.1
forge_version = 39.0.5
forge_version = 39.0.8
# build dependency versions
forgegradle_version = 5.1.+
@ -15,11 +15,11 @@ mixin_version = 0.8.5
librarian_version = 1.+
shadow_version = 7.1.0
cursegradle_version = 1.4.0
parchment_version = 2021.10.31
parchment_version = 2021.12.19
# dependency versions
registrate_version = MC1.18-1.0.21
flywheel_version = 1.18-0.4.2-rc.26
flywheel_version = 1.18-0.5.0.28
jei_minecraft_version = 1.18
jei_version = 9.0.0.40

View file

@ -2125,7 +2125,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear
a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json
b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json
5049f72c327a88f175f6f9425909e098fc711100 assets/create/sounds.json
5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json
0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json
613e64b44bed959da899fdd54c1cacb227fb33f2 data/create/advancements/andesite_alloy.json
81885c6bfb85792c88aaa7c9b70f58832945d31f data/create/advancements/andesite_casing.json
83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json
@ -5210,7 +5210,7 @@ ff1900963bc4cd8ceffa78d58ef1952ceacb2fb7 data/forge/tags/items/storage_blocks/br
9f7a428085b1aac66da32a43e9d51c7efc1f0d81 data/minecraft/tags/blocks/beacon_base_blocks.json
69f596fcb065e26b02ce246760432b5174191b76 data/minecraft/tags/blocks/impermeable.json
59681910c06f8b7385c6641a409d352056235506 data/minecraft/tags/blocks/mineable/axe.json
7d948c24605906ac26e44258f8eac04aa1ddfac4 data/minecraft/tags/blocks/mineable/pickaxe.json
f8c66b3808efb61d2d928748783bb7eb8a1357f9 data/minecraft/tags/blocks/mineable/pickaxe.json
e157c1d3af30e409e34bbefbe15a037e6e1c8daa data/minecraft/tags/blocks/needs_iron_tool.json
a08f67865337f62601c5e333b4011382d10020e4 data/minecraft/tags/blocks/needs_stone_tool.json
6bcabbc1c0479caa80a0ebc676bb34ce0052efb0 data/minecraft/tags/blocks/rails.json

View file

@ -28,8 +28,8 @@
"trigger": "create:bracket_apply",
"conditions": {
"accepted_entries": [
"create:large_cogwheel",
"create:cogwheel"
"create:cogwheel",
"create:large_cogwheel"
]
}
},

View file

@ -189,94 +189,262 @@
"create:waxed_weathered_copper_tile_stairs",
"create:waxed_oxidized_copper_tile_stairs",
"create:cut_granite",
"create:cut_granite_stairs",
"create:cut_granite_slab",
"create:cut_granite_wall",
"create:polished_cut_granite",
"create:polished_cut_granite_stairs",
"create:polished_cut_granite_slab",
"create:polished_cut_granite_wall",
"create:cut_granite_bricks",
"create:cut_granite_brick_stairs",
"create:cut_granite_brick_slab",
"create:cut_granite_brick_wall",
"create:small_granite_bricks",
"create:small_granite_brick_stairs",
"create:small_granite_brick_slab",
"create:small_granite_brick_wall",
"create:layered_granite",
"create:granite_pillar",
"create:cut_diorite",
"create:cut_diorite_stairs",
"create:cut_diorite_slab",
"create:cut_diorite_wall",
"create:polished_cut_diorite",
"create:polished_cut_diorite_stairs",
"create:polished_cut_diorite_slab",
"create:polished_cut_diorite_wall",
"create:cut_diorite_bricks",
"create:cut_diorite_brick_stairs",
"create:cut_diorite_brick_slab",
"create:cut_diorite_brick_wall",
"create:small_diorite_bricks",
"create:small_diorite_brick_stairs",
"create:small_diorite_brick_slab",
"create:small_diorite_brick_wall",
"create:layered_diorite",
"create:diorite_pillar",
"create:cut_andesite",
"create:cut_andesite_stairs",
"create:cut_andesite_slab",
"create:cut_andesite_wall",
"create:polished_cut_andesite",
"create:polished_cut_andesite_stairs",
"create:polished_cut_andesite_slab",
"create:polished_cut_andesite_wall",
"create:cut_andesite_bricks",
"create:cut_andesite_brick_stairs",
"create:cut_andesite_brick_slab",
"create:cut_andesite_brick_wall",
"create:small_andesite_bricks",
"create:small_andesite_brick_stairs",
"create:small_andesite_brick_slab",
"create:small_andesite_brick_wall",
"create:layered_andesite",
"create:andesite_pillar",
"create:cut_calcite",
"create:cut_calcite_stairs",
"create:cut_calcite_slab",
"create:cut_calcite_wall",
"create:polished_cut_calcite",
"create:polished_cut_calcite_stairs",
"create:polished_cut_calcite_slab",
"create:polished_cut_calcite_wall",
"create:cut_calcite_bricks",
"create:cut_calcite_brick_stairs",
"create:cut_calcite_brick_slab",
"create:cut_calcite_brick_wall",
"create:small_calcite_bricks",
"create:small_calcite_brick_stairs",
"create:small_calcite_brick_slab",
"create:small_calcite_brick_wall",
"create:layered_calcite",
"create:calcite_pillar",
"create:cut_dripstone",
"create:cut_dripstone_stairs",
"create:cut_dripstone_slab",
"create:cut_dripstone_wall",
"create:polished_cut_dripstone",
"create:polished_cut_dripstone_stairs",
"create:polished_cut_dripstone_slab",
"create:polished_cut_dripstone_wall",
"create:cut_dripstone_bricks",
"create:cut_dripstone_brick_stairs",
"create:cut_dripstone_brick_slab",
"create:cut_dripstone_brick_wall",
"create:small_dripstone_bricks",
"create:small_dripstone_brick_stairs",
"create:small_dripstone_brick_slab",
"create:small_dripstone_brick_wall",
"create:layered_dripstone",
"create:dripstone_pillar",
"create:cut_deepslate",
"create:cut_deepslate_stairs",
"create:cut_deepslate_slab",
"create:cut_deepslate_wall",
"create:polished_cut_deepslate",
"create:polished_cut_deepslate_stairs",
"create:polished_cut_deepslate_slab",
"create:polished_cut_deepslate_wall",
"create:cut_deepslate_bricks",
"create:cut_deepslate_brick_stairs",
"create:cut_deepslate_brick_slab",
"create:cut_deepslate_brick_wall",
"create:small_deepslate_bricks",
"create:small_deepslate_brick_stairs",
"create:small_deepslate_brick_slab",
"create:small_deepslate_brick_wall",
"create:layered_deepslate",
"create:deepslate_pillar",
"create:cut_tuff",
"create:cut_tuff_stairs",
"create:cut_tuff_slab",
"create:cut_tuff_wall",
"create:polished_cut_tuff",
"create:polished_cut_tuff_stairs",
"create:polished_cut_tuff_slab",
"create:polished_cut_tuff_wall",
"create:cut_tuff_bricks",
"create:cut_tuff_brick_stairs",
"create:cut_tuff_brick_slab",
"create:cut_tuff_brick_wall",
"create:small_tuff_bricks",
"create:small_tuff_brick_stairs",
"create:small_tuff_brick_slab",
"create:small_tuff_brick_wall",
"create:layered_tuff",
"create:tuff_pillar",
"create:asurine",
"create:cut_asurine",
"create:cut_asurine_stairs",
"create:cut_asurine_slab",
"create:cut_asurine_wall",
"create:polished_cut_asurine",
"create:polished_cut_asurine_stairs",
"create:polished_cut_asurine_slab",
"create:polished_cut_asurine_wall",
"create:cut_asurine_bricks",
"create:cut_asurine_brick_stairs",
"create:cut_asurine_brick_slab",
"create:cut_asurine_brick_wall",
"create:small_asurine_bricks",
"create:small_asurine_brick_stairs",
"create:small_asurine_brick_slab",
"create:small_asurine_brick_wall",
"create:layered_asurine",
"create:asurine_pillar",
"create:crimsite",
"create:cut_crimsite",
"create:cut_crimsite_stairs",
"create:cut_crimsite_slab",
"create:cut_crimsite_wall",
"create:polished_cut_crimsite",
"create:polished_cut_crimsite_stairs",
"create:polished_cut_crimsite_slab",
"create:polished_cut_crimsite_wall",
"create:cut_crimsite_bricks",
"create:cut_crimsite_brick_stairs",
"create:cut_crimsite_brick_slab",
"create:cut_crimsite_brick_wall",
"create:small_crimsite_bricks",
"create:small_crimsite_brick_stairs",
"create:small_crimsite_brick_slab",
"create:small_crimsite_brick_wall",
"create:layered_crimsite",
"create:crimsite_pillar",
"create:limestone",
"create:cut_limestone",
"create:cut_limestone_stairs",
"create:cut_limestone_slab",
"create:cut_limestone_wall",
"create:polished_cut_limestone",
"create:polished_cut_limestone_stairs",
"create:polished_cut_limestone_slab",
"create:polished_cut_limestone_wall",
"create:cut_limestone_bricks",
"create:cut_limestone_brick_stairs",
"create:cut_limestone_brick_slab",
"create:cut_limestone_brick_wall",
"create:small_limestone_bricks",
"create:small_limestone_brick_stairs",
"create:small_limestone_brick_slab",
"create:small_limestone_brick_wall",
"create:layered_limestone",
"create:limestone_pillar",
"create:ochrum",
"create:cut_ochrum",
"create:cut_ochrum_stairs",
"create:cut_ochrum_slab",
"create:cut_ochrum_wall",
"create:polished_cut_ochrum",
"create:polished_cut_ochrum_stairs",
"create:polished_cut_ochrum_slab",
"create:polished_cut_ochrum_wall",
"create:cut_ochrum_bricks",
"create:cut_ochrum_brick_stairs",
"create:cut_ochrum_brick_slab",
"create:cut_ochrum_brick_wall",
"create:small_ochrum_bricks",
"create:small_ochrum_brick_stairs",
"create:small_ochrum_brick_slab",
"create:small_ochrum_brick_wall",
"create:layered_ochrum",
"create:ochrum_pillar",
"create:scoria",
"create:cut_scoria",
"create:cut_scoria_stairs",
"create:cut_scoria_slab",
"create:cut_scoria_wall",
"create:polished_cut_scoria",
"create:polished_cut_scoria_stairs",
"create:polished_cut_scoria_slab",
"create:polished_cut_scoria_wall",
"create:cut_scoria_bricks",
"create:cut_scoria_brick_stairs",
"create:cut_scoria_brick_slab",
"create:cut_scoria_brick_wall",
"create:small_scoria_bricks",
"create:small_scoria_brick_stairs",
"create:small_scoria_brick_slab",
"create:small_scoria_brick_wall",
"create:layered_scoria",
"create:scoria_pillar",
"create:scorchia",
"create:cut_scorchia",
"create:cut_scorchia_stairs",
"create:cut_scorchia_slab",
"create:cut_scorchia_wall",
"create:polished_cut_scorchia",
"create:polished_cut_scorchia_stairs",
"create:polished_cut_scorchia_slab",
"create:polished_cut_scorchia_wall",
"create:cut_scorchia_bricks",
"create:cut_scorchia_brick_stairs",
"create:cut_scorchia_brick_slab",
"create:cut_scorchia_brick_wall",
"create:small_scorchia_bricks",
"create:small_scorchia_brick_stairs",
"create:small_scorchia_brick_slab",
"create:small_scorchia_brick_wall",
"create:layered_scorchia",
"create:scorchia_pillar",
"create:veridium",
"create:cut_veridium",
"create:cut_veridium_stairs",
"create:cut_veridium_slab",
"create:cut_veridium_wall",
"create:polished_cut_veridium",
"create:polished_cut_veridium_stairs",
"create:polished_cut_veridium_slab",
"create:polished_cut_veridium_wall",
"create:cut_veridium_bricks",
"create:cut_veridium_brick_stairs",
"create:cut_veridium_brick_slab",
"create:cut_veridium_brick_wall",
"create:small_veridium_bricks",
"create:small_veridium_brick_stairs",
"create:small_veridium_brick_slab",
"create:small_veridium_brick_wall",
"create:layered_veridium",
"create:veridium_pillar"
]

View file

@ -185,12 +185,17 @@ public class KineticTileEntity extends SmartTileEntity
@Override
public void setRemoved() {
super.setRemoved();
}
@Override
protected void setRemovedNotDueToChunkUnload() {
if (!level.isClientSide) {
if (hasNetwork())
getOrCreateNetwork().remove(this);
detachKinetics();
}
super.setRemoved();
super.setRemovedNotDueToChunkUnload();
}
@Override

View file

@ -42,7 +42,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState state = getRenderedBlockState(te);
RenderType type = getRenderType(te, state);
@ -117,7 +117,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
float offset = ICogWheel.isLargeCog(te.getBlockState()) ? 11.25f : 0;
double d = (((axis == Axis.X) ? 0 : pos.getX()) + ((axis == Axis.Y) ? 0 : pos.getY())
+ ((axis == Axis.Z) ? 0 : pos.getZ())) % 2;
if (d == 0)
if (d == 0)
offset = 22.5f;
return offset;
}

View file

@ -1,14 +1,17 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.core.layout.BufferLayout;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.jozufozu.flywheel.util.RenderMath;
import com.mojang.math.Quaternion;
import com.simibubi.create.content.contraptions.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;
@ -19,13 +22,13 @@ public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
}
@Override
public VertexFormat format() {
public BufferLayout getLayout() {
return AllInstanceFormats.BELT;
}
@Override
public StructWriter<BeltData> getWriter(VecBuffer backing) {
return new UnsafeBeltWriter(backing, this);
return new BeltWriterUnsafe(backing, this);
}
@Override
@ -34,7 +37,26 @@ public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
}
@Override
public BatchingTransformer<BeltData> getTransformer(Model model) {
return null;
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 Quaternion(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);
}
}
}

View file

@ -4,27 +4,16 @@ 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 UnsafeBeltWriter extends UnsafeBufferWriter<BeltData> {
public UnsafeBeltWriter(VecBuffer backingBuffer, StructType<BeltData> vertexType) {
public class BeltWriterUnsafe extends KineticWriterUnsafe<BeltData> {
public BeltWriterUnsafe(VecBuffer backingBuffer, StructType<BeltData> vertexType) {
super(backingBuffer, vertexType);
}
@Override
public void write(BeltData d) {
protected void writeInternal(BeltData d) {
super.writeInternal(d);
long addr = writePointer;
MemoryUtil.memPutByte(addr, d.blockLight);
MemoryUtil.memPutByte(addr + 1, d.skyLight);
MemoryUtil.memPutByte(addr + 2, d.r);
MemoryUtil.memPutByte(addr + 3, d.g);
MemoryUtil.memPutByte(addr + 4, d.b);
MemoryUtil.memPutByte(addr + 5, d.a);
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);
MemoryUtil.memPutFloat(addr + 26, d.qX);
MemoryUtil.memPutFloat(addr + 30, d.qY);
MemoryUtil.memPutFloat(addr + 34, d.qZ);
@ -36,7 +25,5 @@ public class UnsafeBeltWriter extends UnsafeBufferWriter<BeltData> {
MemoryUtil.memPutFloat(addr + 58, d.maxU);
MemoryUtil.memPutFloat(addr + 62, d.maxV);
MemoryUtil.memPutByte(addr + 66, d.scrollMult);
advance();
}
}

View file

@ -0,0 +1,24 @@
package com.simibubi.create.content.contraptions.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<D extends KineticData> extends BasicWriterUnsafe<D> {
public KineticWriterUnsafe(VecBuffer backingBuffer, StructType<D> 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);
}
}

View file

@ -1,14 +1,17 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.core.layout.BufferLayout;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.jozufozu.flywheel.util.RenderMath;
import com.mojang.math.Vector3f;
import com.simibubi.create.content.contraptions.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;
@ -19,13 +22,13 @@ public class RotatingType implements Instanced<RotatingData>, Batched<RotatingDa
}
@Override
public VertexFormat format() {
public BufferLayout getLayout() {
return AllInstanceFormats.ROTATING;
}
@Override
public StructWriter<RotatingData> getWriter(VecBuffer backing) {
return new UnsafeRotatingWriter(backing, this);
return new RotatingWriterUnsafe(backing, this);
}
@Override
@ -34,7 +37,17 @@ public class RotatingType implements Instanced<RotatingData>, Batched<RotatingDa
}
@Override
public BatchingTransformer<RotatingData> getTransformer(Model model) {
return null;
public void transform(RotatingData d, ModelTransformer.Params b) {
float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360);
Vector3f axis = 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);
}
}
}

View file

@ -0,0 +1,21 @@
package com.simibubi.create.content.contraptions.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<RotatingData> {
public RotatingWriterUnsafe(VecBuffer backingBuffer, StructType<RotatingData> 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);
}
}

View file

@ -1,34 +0,0 @@
package com.simibubi.create.content.contraptions.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.backend.struct.UnsafeBufferWriter;
public class UnsafeRotatingWriter extends UnsafeBufferWriter<RotatingData> {
public UnsafeRotatingWriter(VecBuffer backingBuffer, StructType<RotatingData> vertexType) {
super(backingBuffer, vertexType);
}
@Override
public void write(RotatingData d) {
long addr = writePointer;
MemoryUtil.memPutByte(addr, d.blockLight);
MemoryUtil.memPutByte(addr + 1, d.skyLight);
MemoryUtil.memPutByte(addr + 2, d.r);
MemoryUtil.memPutByte(addr + 3, d.g);
MemoryUtil.memPutByte(addr + 4, d.b);
MemoryUtil.memPutByte(addr + 5, d.a);
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);
MemoryUtil.memPutByte(addr + 26, d.rotationAxisX);
MemoryUtil.memPutByte(addr + 27, d.rotationAxisY);
MemoryUtil.memPutByte(addr + 28, d.rotationAxisZ);
advance();
}
}

View file

@ -37,7 +37,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
@OnlyIn(value = Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
if (!Backend.getInstance().canUseInstancing())
if (!Backend.isOn())
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
}

View file

@ -58,8 +58,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
@Override
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!Backend.getInstance()
.canUseInstancing())
if (!Backend.isOn())
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
}

View file

@ -1,12 +1,11 @@
package com.simibubi.create.content.contraptions.components.actors.flwdata;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.core.layout.BufferLayout;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
@ -19,7 +18,7 @@ public class ActorType implements Instanced<ActorData>, Batched<ActorData> {
}
@Override
public VertexFormat format() {
public BufferLayout getLayout() {
return AllInstanceFormats.ACTOR;
}
@ -34,7 +33,7 @@ public class ActorType implements Instanced<ActorData>, Batched<ActorData> {
}
@Override
public BatchingTransformer<ActorData> getTransformer(Model model) {
return null;
public void transform(ActorData d, ModelTransformer.Params b) {
}
}

View file

@ -12,7 +12,7 @@ public class UnsafeActorWriter extends UnsafeBufferWriter<ActorData> {
}
@Override
public void write(ActorData d) {
protected void writeInternal(ActorData d) {
long addr = writePointer;
MemoryUtil.memPutFloat(addr, d.x);
MemoryUtil.memPutFloat(addr + 4, d.y);
@ -31,6 +31,5 @@ public class UnsafeActorWriter extends UnsafeBufferWriter<ActorData> {
MemoryUtil.memPutByte(addr + 38, d.rotationCenterY);
MemoryUtil.memPutByte(addr + 39, d.rotationCenterZ);
MemoryUtil.memPutFloat(addr + 40, d.speed);
advance();
}
}

View file

@ -169,8 +169,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
BlockState blockState = te.getBlockState();
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
if (!Backend.getInstance()
.canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light);
superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING)

View file

@ -28,7 +28,7 @@ public class HandCrankRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState state = te.getBlockState();
Block block = state.getBlock();

View file

@ -257,7 +257,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
@Override
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!Backend.getInstance().canUseInstancing())
if (!Backend.isOn())
DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers);
}

View file

@ -54,7 +54,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
renderItem(te, partialTicks, ms, buffer, light, overlay);
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
renderComponents(te, partialTicks, ms, buffer, light, overlay);
}
@ -113,7 +113,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
protected void renderComponents(DeployerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light);
}
@ -193,10 +193,10 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
IRotate def = (IRotate) context.state.getBlock();
axis = def.getRotationAxis(context.state);
}
float time = AnimationTickHolder.getRenderTime(context.world) / 20;
float angle = (time * speed) % 360;
new MatrixTransformStack(m)
.centre()
.rotateY(axis == Axis.Z ? 90 : 0)

View file

@ -28,7 +28,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
Direction direction = te.getBlockState()
.getValue(FACING);

View file

@ -36,7 +36,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState blockState = te.getBlockState();
FlywheelTileEntity wte = (FlywheelTileEntity) te;

View file

@ -22,7 +22,7 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light,
int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
Block block = te.getBlockState()
.getBlock();

View file

@ -86,10 +86,15 @@ public class EngineTileEntity extends SmartTileEntity implements FlywheelRendere
@Override
public void setRemoved() {
detachWheel();
super.setRemoved();
}
@Override
protected void setRemovedNotDueToChunkUnload() {
detachWheel();
super.setRemovedNotDueToChunkUnload();
}
protected void refreshWheelSpeed() {
if (poweredWheel == null)
return;

View file

@ -31,7 +31,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState blockState = te.getBlockState();
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;

View file

@ -31,7 +31,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState blockState = te.getBlockState();
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);

View file

@ -46,8 +46,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
renderItems(te, partialTicks, ms, buffer, light, overlay);
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
renderShaft(te, ms, buffer, light, overlay);

View file

@ -224,12 +224,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
return;
}
for (Iterator<Entry<Entity, MutableInt>> iterator = collidingEntities.entrySet()
.iterator(); iterator.hasNext();)
if (iterator.next()
.getValue()
.incrementAndGet() > 3)
iterator.remove();
collidingEntities.entrySet().removeIf(e -> e.getValue().incrementAndGet() > 3);
xo = getX();
yo = getY();
@ -642,7 +637,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
public boolean hasExactlyOnePlayerPassenger() {
return false;
}
@OnlyIn(Dist.CLIENT)
public abstract void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks);

View file

@ -25,8 +25,8 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.light.ImmutableBox;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.jozufozu.flywheel.util.box.ImmutableBox;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllInteractionBehaviours;
import com.simibubi.create.AllMovementBehaviours;
@ -874,9 +874,9 @@ public abstract class Contraption {
}
ListTag paletteNBT = new ListTag();
for(int i = 0; i < palette.getSize(); ++i)
for(int i = 0; i < palette.getSize(); ++i)
paletteNBT.add(NbtUtils.writeBlockState(palette.values.byId(i)));
compound.put("Palette", paletteNBT);
compound.put("BlockList", blockList);
@ -891,7 +891,7 @@ public abstract class Contraption {
palette = new HashMapPalette<>(GameData.getBlockStateIDMap(), 16, (i, s) -> {
throw new IllegalStateException("Palette Map index exceeded maximum");
});
ListTag list = c.getList("Palette", 10);
palette.values.clear();
for (int i = 0; i < list.size(); ++i)

View file

@ -1,8 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
import com.jozufozu.flywheel.light.GPULightVolume;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.light.ImmutableBox;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.jozufozu.flywheel.util.box.ImmutableBox;
import com.jozufozu.flywheel.light.LightListener;
import com.jozufozu.flywheel.light.LightProvider;
import com.jozufozu.flywheel.light.LightUpdater;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.light.ImmutableBox;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.jozufozu.flywheel.util.box.ImmutableBox;
import com.jozufozu.flywheel.light.LightProvider;
import com.jozufozu.flywheel.light.MovingListener;
import com.simibubi.create.foundation.config.AllConfigs;

View file

@ -74,17 +74,12 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
public float prevPitch;
public float pitch;
public float targetPitch;
// When placed using a contraption item
private float initialYawOffset;
public OrientedContraptionEntity(EntityType<?> type, Level world) {
super(type, world);
motionBeforeStall = Vec3.ZERO;
attachedExtraInventories = false;
isSerializingFurnaceCart = false;
initialYawOffset = -1;
}
public static OrientedContraptionEntity create(Level world, Contraption contraption, Direction initialOrientation) {
@ -112,11 +107,6 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
return entityData.get(INITIAL_ORIENTATION);
}
public void deferOrientation(Direction newInitialAngle) {
entityData.set(INITIAL_ORIENTATION, Direction.UP);
yaw = initialYawOffset = newInitialAngle.toYRot();
}
@Override
public float getYawOffset() {
return getInitialYaw();
@ -398,7 +388,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
prevYaw = yaw;
float maxApproachSpeed = (float) (motion.length() * 12f / (Math.max(1, getBoundingBox().getXsize() / 6f)));
float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw);
float yawHint = AngleHelper.getShortestAngleDiff(yaw, yawFromVector(locationDiff));
float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw, yawHint);
approach = Mth.clamp(approach, -maxApproachSpeed, maxApproachSpeed);
yaw += approach;
if (Math.abs(AngleHelper.getShortestAngleDiff(yaw, targetYaw)) < 1f)

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;

View file

@ -27,7 +27,7 @@ public class BearingRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);

View file

@ -362,9 +362,14 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
@Override
public void setRemoved() {
super.setRemoved();
}
@Override
protected void setRemovedNotDueToChunkUnload() {
if (!level.isClientSide)
disassemble();
super.setRemoved();
super.setRemovedNotDueToChunkUnload();
}
@Override

View file

@ -59,9 +59,14 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
@Override
public void setRemoved() {
super.setRemoved();
}
@Override
protected void setRemovedNotDueToChunkUnload() {
if (!level.isClientSide)
disassemble();
super.setRemoved();
super.setRemovedNotDueToChunkUnload();
}
@Override

View file

@ -34,7 +34,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
if (Backend.getInstance().canUseInstancing()) return;
if (Backend.isOn()) return;
Direction facing = context.state.getValue(BlockStateProperties.FACING);
PartialModel top = AllBlockPartials.BEARING_TOP;

View file

@ -25,7 +25,7 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
protected void renderSafe(StickerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState state = te.getBlockState();
SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.STICKER_HEAD, state);

View file

@ -31,7 +31,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState state = te.getBlockState();
Direction facing = state.getValue(GantryCarriageBlock.FACING);

View file

@ -4,34 +4,25 @@ import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialGroup;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.ITickableInstance;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.jozufozu.flywheel.core.model.Model;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Quaternion;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllStitchedTextures;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.phys.Vec3;
public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITickableInstance {
private static final boolean USE_ATLAS = false;
private static final ResourceLocation TEXTURE = Create.asResource("textures/entity/super_glue/slime.png");
private final Quaternion rotation;
@ -52,9 +43,9 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
}
private Instancer<OrientedData> getInstancer(MaterialManager materialManager, SuperGlueEntity entity) {
MaterialGroup group = USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(RenderType.entityCutout(TEXTURE));
MaterialGroup group = GlueModel.USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(RenderType.entityCutout(TEXTURE));
return group.material(Materials.ORIENTED).model(entity.getType(), GlueModel::new);
return group.material(Materials.ORIENTED).model(entity.getType(), GlueModel::get);
}
@Override
@ -95,75 +86,4 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
|| AllItems.SUPER_GLUE.isIn(player.getOffhandItem());
}
public static class GlueModel implements Model {
@Override
public String name() {
return "glue";
}
@Override
public void buffer(VertexConsumer buffer) {
Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
Vec3 extension = diff.normalize()
.scale(1 / 32f - 1 / 128f);
Vec3 plane = VecHelper.axisAlingedPlaneOf(diff);
Direction.Axis axis = Direction.getNearest(diff.x, diff.y, diff.z)
.getAxis();
Vec3 start = Vec3.ZERO.subtract(extension);
Vec3 end = Vec3.ZERO.add(extension);
plane = plane.scale(1 / 2f);
Vec3 a1 = plane.add(start);
Vec3 b1 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a2 = plane.add(start);
Vec3 b2 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a3 = plane.add(start);
Vec3 b3 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a4 = plane.add(start);
Vec3 b4 = plane.add(end);
float minU;
float maxU;
float minV;
float maxV;
if (USE_ATLAS) {
TextureAtlasSprite sprite = AllStitchedTextures.SUPER_GLUE.get();
minU = sprite.getU0();
maxU = sprite.getU1();
minV = sprite.getV0();
maxV = sprite.getV1();
} else {
minU = minV = 0;
maxU = maxV = 1;
}
// inside quad
buffer.vertex(a1.x, a1.y, a1.z).normal(0, 0, -1f).uv(maxU, minV).endVertex();
buffer.vertex(a2.x, a2.y, a2.z).normal(0, 0, -1f).uv(maxU, maxV).endVertex();
buffer.vertex(a3.x, a3.y, a3.z).normal(0, 0, -1f).uv(minU, maxV).endVertex();
buffer.vertex(a4.x, a4.y, a4.z).normal(0, 0, -1f).uv(minU, minV).endVertex();
// outside quad
buffer.vertex(b4.x, b4.y, b4.z).normal(0, 0, 1f).uv(minU, minV).endVertex();
buffer.vertex(b3.x, b3.y, b3.z).normal(0, 0, 1f).uv(minU, maxV).endVertex();
buffer.vertex(b2.x, b2.y, b2.z).normal(0, 0, 1f).uv(maxU, maxV).endVertex();
buffer.vertex(b1.x, b1.y, b1.z).normal(0, 0, 1f).uv(maxU, minV).endVertex();
}
@Override
public int vertexCount() {
return 8;
}
@Override
public VertexFormat format() {
return Formats.UNLIT_MODEL;
}
}
}

View file

@ -0,0 +1,99 @@
package com.simibubi.create.content.contraptions.components.structureMovement.glue;
import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.vertex.PosTexNormalWriterUnsafe;
import com.jozufozu.flywheel.api.vertex.VertexList;
import com.mojang.blaze3d.platform.MemoryTracker;
import com.simibubi.create.AllStitchedTextures;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;
import net.minecraft.world.phys.Vec3;
public class GlueModel implements Model {
public static final GlueModel INSTANCE = new GlueModel();
static final boolean USE_ATLAS = false;
public static GlueModel get() {
return INSTANCE;
}
private final VertexList reader;
private GlueModel() {
PosTexNormalWriterUnsafe writer = Formats.POS_TEX_NORMAL.createWriter(MemoryTracker.create(size()));
createGlueModel(writer);
reader = writer.intoReader();
}
@Override
public String name() {
return "glue";
}
@Override
public int vertexCount() {
return 8;
}
@Override
public VertexList getReader() {
return reader;
}
public static void createGlueModel(PosTexNormalWriterUnsafe buffer) {
Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
Vec3 extension = diff.normalize()
.scale(1 / 32f - 1 / 128f);
Vec3 plane = VecHelper.axisAlingedPlaneOf(diff);
Direction.Axis axis = Direction.getNearest(diff.x, diff.y, diff.z)
.getAxis();
Vec3 start = Vec3.ZERO.subtract(extension);
Vec3 end = Vec3.ZERO.add(extension);
plane = plane.scale(1 / 2f);
Vec3 a1 = plane.add(start);
Vec3 b1 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a2 = plane.add(start);
Vec3 b2 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a3 = plane.add(start);
Vec3 b3 = plane.add(end);
plane = VecHelper.rotate(plane, -90, axis);
Vec3 a4 = plane.add(start);
Vec3 b4 = plane.add(end);
float minU;
float maxU;
float minV;
float maxV;
if (USE_ATLAS) {
TextureAtlasSprite sprite = AllStitchedTextures.SUPER_GLUE.get();
minU = sprite.getU0();
maxU = sprite.getU1();
minV = sprite.getV0();
maxV = sprite.getV1();
} else {
minU = minV = 0;
maxU = maxV = 1;
}
// inside quad
buffer.putVertex((float) a1.x, (float) a1.y, (float) a1.z, 0, 0, -1, maxU, minV);
buffer.putVertex((float) a2.x, (float) a2.y, (float) a2.z, 0, 0, -1, maxU, maxV);
buffer.putVertex((float) a3.x, (float) a3.y, (float) a3.z, 0, 0, -1, minU, maxV);
buffer.putVertex((float) a4.x, (float) a4.y, (float) a4.z, 0, 0, -1, minU, minV);
// outside quad
buffer.putVertex((float) b4.x, (float) b4.y, (float) b4.z, 0, 0, 1f, minU, minV);
buffer.putVertex((float) b3.x, (float) b3.y, (float) b3.z, 0, 0, 1f, minU, maxV);
buffer.putVertex((float) b2.x, (float) b2.y, (float) b2.z, 0, 0, 1f, maxU, maxV);
buffer.putVertex((float) b1.x, (float) b1.y, (float) b1.z, 0, 0, 1f, maxU, minV);
}
}

View file

@ -107,7 +107,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
boolean contraptionPresent = movedContraption != null;
if (needsContraption && !contraptionPresent)
return;
float movementSpeed = getMovementSpeed();
float newOffset = offset + movementSpeed;
if ((int) newOffset != (int) offset)
@ -122,7 +122,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
return;
}
}
if (!contraptionPresent || !movedContraption.isStalled())
offset = newOffset;
@ -173,10 +173,15 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
@Override
public void setRemoved() {
super.setRemoved();
}
@Override
protected void setRemovedNotDueToChunkUnload() {
this.remove = true;
if (!level.isClientSide)
disassemble();
super.setRemoved();
super.setRemovedNotDueToChunkUnload();
}
@Override
@ -261,13 +266,13 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
movedContraption.setContraptionMotion(Vec3.ZERO);
return false;
}
Vec3 motion = getMotionVector();
movedContraption.setContraptionMotion(getMotionVector());
movedContraption.move(motion.x, motion.y, motion.z);
return ContraptionCollider.collideBlocks(movedContraption);
}
protected void collided() {
if (level.isClientSide) {
waitingForSpeedChange = true;

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import net.minecraft.core.Vec3i;

View file

@ -7,8 +7,8 @@ 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.GridAlignedBB;
import com.jozufozu.flywheel.light.ImmutableBox;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.jozufozu.flywheel.util.box.ImmutableBox;
import com.jozufozu.flywheel.light.LightPacking;
import com.jozufozu.flywheel.light.LightProvider;
import com.jozufozu.flywheel.light.LightUpdater;

View file

@ -44,8 +44,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;

View file

@ -7,9 +7,9 @@ import net.minecraft.client.renderer.RenderType;
public class ContraptionGroup<P extends ContraptionProgram> extends InstancedMaterialGroup<P> {
private final RenderedContraption contraption;
private final FlwContraption contraption;
public ContraptionGroup(RenderedContraption contraption, InstancingEngine<P> owner, RenderType type) {
public ContraptionGroup(FlwContraption contraption, InstancingEngine<P> owner, RenderType type) {
super(owner, type);
this.contraption = contraption;
@ -20,7 +20,7 @@ public class ContraptionGroup<P extends ContraptionProgram> extends InstancedMat
contraption.setup(program);
}
public static <P extends ContraptionProgram> InstancingEngine.GroupFactory<P> forContraption(RenderedContraption c) {
public static <P extends ContraptionProgram> InstancingEngine.GroupFactory<P> forContraption(FlwContraption c) {
return (materialManager, type) -> new ContraptionGroup<>(c, materialManager, type);
}
}

View file

@ -1,6 +1,5 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import javax.annotation.Nullable;
@ -8,10 +7,12 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.Camera;
import net.minecraft.core.BlockPos;
@ -21,11 +22,11 @@ public class ContraptionInstanceManager extends TileInstanceManager {
protected ArrayList<ActorInstance> actors = new ArrayList<>();
private final WeakReference<RenderedContraption> contraption;
private final PlacementSimulationWorld renderWorld;
ContraptionInstanceManager(RenderedContraption contraption, MaterialManager materialManager) {
ContraptionInstanceManager(MaterialManager materialManager, PlacementSimulationWorld contraption) {
super(materialManager);
this.contraption = new WeakReference<>(contraption);
this.renderWorld = contraption;
}
public void tick() {
@ -33,8 +34,8 @@ public class ContraptionInstanceManager extends TileInstanceManager {
}
@Override
public void beginFrame(Camera info) {
super.beginFrame(info);
public void beginFrame(TaskEngine taskEngine, Camera info) {
super.beginFrame(taskEngine, info);
actors.forEach(ActorInstance::beginFrame);
}
@ -52,7 +53,7 @@ public class ContraptionInstanceManager extends TileInstanceManager {
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
if (movementBehaviour != null && movementBehaviour.hasSpecialInstancedRendering()) {
ActorInstance instance = movementBehaviour.createInstance(materialManager, getContraption().renderWorld, context);
ActorInstance instance = movementBehaviour.createInstance(materialManager, renderWorld, context);
actors.add(instance);
@ -61,9 +62,5 @@ public class ContraptionInstanceManager extends TileInstanceManager {
return null;
}
public RenderedContraption getContraption() {
return contraption.get();
}
}

View file

@ -43,7 +43,7 @@ import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(Dist.CLIENT)
public class ContraptionRenderDispatcher {
private static WorldAttached<ContraptionRenderManager<?>> WORLDS = new WorldAttached<>(SBBContraptionManager::new);
private static WorldAttached<ContraptionRenderingWorld<?>> WORLDS = new WorldAttached<>(SBBContraptionManager::new);
/**
* Reset a contraption's renderer.
@ -113,8 +113,7 @@ public class ContraptionRenderDispatcher {
// Skip individual lighting updates to prevent lag with large contraptions
renderWorld.setBlock(info.pos, info.state, Block.UPDATE_SUPPRESS_LIGHT);
renderWorld.updateLightSources();
renderWorld.lighter.runUpdates(Integer.MAX_VALUE, false, false);
renderWorld.runLightingEngine();
return renderWorld;
}
@ -176,9 +175,9 @@ public class ContraptionRenderDispatcher {
}
public static void reset() {
WORLDS.empty(ContraptionRenderManager::delete);
WORLDS.empty(ContraptionRenderingWorld::delete);
if (Backend.getInstance().available()) {
if (Backend.isOn()) {
WORLDS = new WorldAttached<>(FlwContraptionManager::new);
} else {
WORLDS = new WorldAttached<>(SBBContraptionManager::new);

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;

View file

@ -17,7 +17,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo> {
public abstract class ContraptionRenderingWorld<C extends ContraptionRenderInfo> {
protected final Level world;
private int removalTimer;
@ -25,7 +25,7 @@ public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo>
protected final Int2ObjectMap<C> renderInfos = new Int2ObjectOpenHashMap<>();
protected final List<C> visible = new ObjectArrayList<>();
public ContraptionRenderManager(LevelAccessor world) {
public ContraptionRenderingWorld(LevelAccessor world) {
this.world = (Level) world;
}

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;

View file

@ -7,13 +7,18 @@ import java.util.Map;
import java.util.function.Supplier;
import com.jozufozu.flywheel.backend.Backend;
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.TaskEngine;
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.backend.model.ModelRenderer;
import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.model.WorldModel;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
@ -30,32 +35,26 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
public class RenderedContraption extends ContraptionRenderInfo {
public class FlwContraption extends ContraptionRenderInfo {
private final ContraptionLighter<?> lighter;
public final InstancingEngine<ContraptionProgram> engine;
public final ContraptionInstanceManager kinetics;
private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>();
private final Matrix4f modelViewPartial = new Matrix4f();
private final ContraptionInstanceWorld instanceWorld;
private boolean modelViewPartialReady;
// floats because we're uploading this to the gpu
// floats because we upload this to the gpu
private AABB lightBox;
public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
public FlwContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
super(contraption, renderWorld);
this.lighter = contraption.makeLighter();
this.engine = InstancingEngine.builder(CreateContexts.CWORLD)
.setGroupFactory(ContraptionGroup.forContraption(this))
.setIgnoreOriginCoordinate(true)
.build();
this.kinetics = new ContraptionInstanceManager(this, engine);
this.engine.addListener(this.kinetics);
instanceWorld = new ContraptionInstanceWorld(this);
buildLayers();
if (Backend.getInstance().canUseInstancing()) {
if (Backend.isOn()) {
buildInstancedTiles();
buildActors();
}
@ -65,7 +64,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
return lighter;
}
public void doRenderLayer(RenderType layer, ContraptionProgram shader) {
public void renderStructureLayer(RenderType layer, ContraptionProgram shader) {
ModelRenderer structure = renderLayers.get(layer);
if (structure != null) {
setup(shader);
@ -73,6 +72,21 @@ public class RenderedContraption extends ContraptionRenderInfo {
}
}
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);
@ -81,7 +95,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
if (!isVisible()) return;
kinetics.beginFrame(event.getInfo());
instanceWorld.tileInstanceManager.beginFrame(SerialTaskEngine.INSTANCE, event.getInfo());
Vec3 cameraPos = event.getCameraPos();
@ -113,8 +127,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
lighter.delete();
engine.delete();
kinetics.invalidate();
instanceWorld.delete();
}
private void buildLayers() {
@ -141,7 +154,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
.canInstance(te.getType())) {
Level world = te.getLevel();
te.setLevel(renderWorld);
kinetics.add(te);
instanceWorld.tileInstanceManager.add(te);
te.setLevel(world);
}
}
@ -149,7 +162,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
}
private void buildActors() {
contraption.getActors().forEach(kinetics::createActor);
contraption.getActors().forEach(instanceWorld.tileInstanceManager::createActor);
}
public static void setupModelViewPartial(Matrix4f matrix, Matrix4f modelMatrix, AbstractContraptionEntity entity, double camX, double camY, double camZ, float pt) {
@ -160,4 +173,38 @@ public class RenderedContraption extends ContraptionRenderInfo {
matrix.multiply(modelMatrix);
}
public void tick() {
instanceWorld.tileInstanceManager.tick();
}
public static class ContraptionInstanceWorld {
private final Engine engine;
private final ContraptionInstanceManager tileInstanceManager;
public ContraptionInstanceWorld(FlwContraption parent) {
switch (Backend.getInstance().getEngine()) {
case INSTANCING -> {
InstancingEngine<ContraptionProgram> engine = InstancingEngine.builder(CreateContexts.CWORLD)
.setGroupFactory(ContraptionGroup.forContraption(parent))
.setIgnoreOriginCoordinate(true)
.build();
tileInstanceManager = new ContraptionInstanceManager(engine, parent.renderWorld);
engine.addListener(tileInstanceManager);
this.engine = engine;
}
case BATCHING -> {
engine = new BatchingEngine();
tileInstanceManager = new ContraptionInstanceManager(engine, parent.renderWorld);
}
default -> throw new IllegalArgumentException("Unknown engine type");
}
}
public void delete() {
engine.delete();
tileInstanceManager.invalidate();
}
}
}

View file

@ -8,7 +8,7 @@ import com.jozufozu.flywheel.backend.RenderLayer;
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.jozufozu.flywheel.util.TextureBinder;
import com.jozufozu.flywheel.util.Textures;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.render.AllProgramSpecs;
import com.simibubi.create.foundation.render.CreateContexts;
@ -17,7 +17,7 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.LevelAccessor;
public class FlwContraptionManager extends ContraptionRenderManager<RenderedContraption> {
public class FlwContraptionManager extends ContraptionRenderingWorld<FlwContraption> {
public FlwContraptionManager(LevelAccessor world) {
super(world);
@ -27,8 +27,8 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
public void tick() {
super.tick();
for (RenderedContraption contraption : visible) {
contraption.kinetics.tick();
for (FlwContraption contraption : visible) {
contraption.tick();
}
}
@ -44,7 +44,7 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
layer.setupRenderState();
TextureBinder.bindActiveTextures();
Textures.bindActiveTextures();
ContraptionProgram structureShader = CreateContexts.STRUCTURE.getProgram(AllProgramSpecs.STRUCTURE);
@ -52,17 +52,18 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
structureShader.uploadViewProjection(event.viewProjection);
structureShader.uploadCameraPos(event.camX, event.camY, event.camZ);
for (RenderedContraption renderedContraption : visible) {
renderedContraption.doRenderLayer(layer, structureShader);
for (FlwContraption flwContraption : visible) {
flwContraption.renderStructureLayer(layer, structureShader);
}
GlVertexArray.unbind();
if (Backend.getInstance().canUseInstancing()) {
if (Backend.isOn()) {
RenderLayer renderLayer = event.getLayer();
if (renderLayer != null) {
for (RenderedContraption renderer : visible) {
renderer.engine.render(event, event.buffers.bufferSource());
for (FlwContraption renderer : visible) {
renderer.renderInstanceLayer(event);
}
}
}
@ -76,9 +77,9 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
}
@Override
protected RenderedContraption create(Contraption c) {
protected FlwContraption create(Contraption c) {
PlacementSimulationWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c);
return new RenderedContraption(c, renderWorld);
return new FlwContraption(c, renderWorld);
}
@Override

View file

@ -11,7 +11,7 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.LevelAccessor;
public class SBBContraptionManager extends ContraptionRenderManager<ContraptionRenderInfo> {
public class SBBContraptionManager extends ContraptionRenderingWorld<ContraptionRenderInfo> {
public static final SuperByteBufferCache.Compartment<Pair<Contraption, RenderType>> CONTRAPTION = new SuperByteBufferCache.Compartment<>();
public SBBContraptionManager(LevelAccessor world) {

View file

@ -27,7 +27,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState blockState = te.getBlockState();

View file

@ -197,12 +197,17 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
@Override
public void setRemoved() {
onEmptied();
itemCapability.invalidate();
fluidCapability.invalidate();
super.setRemoved();
}
@Override
protected void setRemovedNotDueToChunkUnload() {
onEmptied();
super.setRemovedNotDueToChunkUnload();
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
@ -288,7 +293,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
tryClearingSpoutputOverflow();
if (!contentsChanged)
return;
contentsChanged = false;
getOperator().ifPresent(te -> te.basinChecker.scheduleUpdate());
@ -312,7 +317,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
Direction direction = blockState.getValue(BasinBlock.FACING);
BlockEntity te = level.getBlockEntity(worldPosition.below()
.relative(direction));
FilteringBehaviour filter = null;
InvManipulationBehaviour inserter = null;
if (te != null) {
@ -362,7 +367,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
update = true;
continue;
}
if (targetTank == null)
break;
@ -459,7 +464,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
Direction direction = blockState.getValue(BasinBlock.FACING);
if (direction != Direction.DOWN) {
BlockEntity te = level.getBlockEntity(worldPosition.below()
.relative(direction));
@ -472,7 +477,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
: te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, direction.getOpposite())
.orElse(null);
boolean externalTankNotPresent = targetTank == null;
if (!outputItems.isEmpty() && targetInv == null)
return false;
if (!outputFluids.isEmpty() && externalTankNotPresent) {
@ -484,7 +489,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
if (!acceptFluidOutputsIntoBasin(outputFluids, simulate, targetTank))
return false;
}
if (simulate)
return true;
for (ItemStack itemStack : outputItems) {

View file

@ -31,7 +31,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay);
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
if (!Backend.getInstance().canUseInstancing(tileEntityIn.getLevel())) {
if (!Backend.canUseInstancing(tileEntityIn.getLevel())) {
KineticTileEntityRenderer.renderRotatingBuffer(tileEntityIn, getRotatedModel(tileEntityIn), ms, builder, light);
}

View file

@ -55,7 +55,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
protected void renderSafe(BeltTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
BlockState blockState = te.getBlockState();
if (!AllBlocks.BELT.has(blockState)) return;

View file

@ -13,8 +13,8 @@ import java.util.Optional;
import java.util.function.Function;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.jozufozu.flywheel.light.GridAlignedBB;
import com.jozufozu.flywheel.light.ImmutableBox;
import com.jozufozu.flywheel.util.box.GridAlignedBB;
import com.jozufozu.flywheel.util.box.ImmutableBox;
import com.jozufozu.flywheel.light.LightListener;
import com.jozufozu.flywheel.light.LightProvider;
import com.jozufozu.flywheel.light.LightUpdater;

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.relays.elementary;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials;
@ -59,10 +59,11 @@ public class BracketedKineticTileInstance extends SingleRotatingInstance {
private PoseStack rotateToAxis(Axis axis) {
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
PoseStack poseStack = new PoseStack();
new MatrixTransformStack(poseStack).centre()
.rotateToFace(facing)
.multiply(Vector3f.XN.rotationDegrees(-90))
.unCentre();
TransformStack.cast(poseStack)
.centre()
.rotateToFace(facing)
.multiply(Vector3f.XN.rotationDegrees(-90))
.unCentre();
return poseStack;
}

View file

@ -28,8 +28,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
if (!AllBlocks.LARGE_COGWHEEL.has(te.getBlockState())) {

View file

@ -39,8 +39,7 @@ public class EncasedCogRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
BlockState blockState = te.getBlockState();

View file

@ -28,7 +28,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
Block block = te.getBlockState().getBlock();
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());

View file

@ -39,7 +39,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);

View file

@ -27,7 +27,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
final Axis boxAxis = te.getBlockState().getValue(BlockStateProperties.AXIS);
final BlockPos pos = te.getBlockPos();

View file

@ -76,7 +76,7 @@ public class TreeFertilizerItem extends Item {
return super.useOn(context);
}
private class TreesDreamWorld extends PlacementSimulationServerWorld {
private static class TreesDreamWorld extends PlacementSimulationServerWorld {
private final BlockPos saplingPos;
private final BlockState soil;

View file

@ -1,15 +1,17 @@
package com.simibubi.create.content.curiosities.toolbox;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
/**
* For inserting items into a players' inventory anywhere except the hotbar
*/
public class ItemReturnInvWrapper extends InvWrapper {
public class ItemReturnInvWrapper extends PlayerMainInvWrapper {
public ItemReturnInvWrapper(Container inv) {
public ItemReturnInvWrapper(Inventory inv) {
super(inv);
}

View file

@ -7,6 +7,8 @@ import java.util.Optional;
import javax.annotation.Nullable;
import net.minecraft.nbt.Tag;
import org.apache.commons.lang3.Validate;
import com.simibubi.create.AllEntityTypes;
@ -113,9 +115,15 @@ public class BlueprintEntity extends HangingEntity
@Override
public void readAdditionalSaveData(CompoundTag p_70037_1_) {
this.direction = Direction.from3DDataValue(p_70037_1_.getByte("Facing"));
this.verticalOrientation = Direction.from3DDataValue(p_70037_1_.getByte("Orientation"));
this.size = p_70037_1_.getInt("Size");
if (p_70037_1_.contains("Facing", Tag.TAG_ANY_NUMERIC)) {
this.direction = Direction.from3DDataValue(p_70037_1_.getByte("Facing"));
this.verticalOrientation = Direction.from3DDataValue(p_70037_1_.getByte("Orientation"));
this.size = p_70037_1_.getInt("Size");
} else {
this.direction = Direction.SOUTH;
this.verticalOrientation = Direction.DOWN;
this.size = 1;
}
super.readAdditionalSaveData(p_70037_1_);
this.updateFacingWithBoundingBox(this.direction, this.verticalOrientation);
}

View file

@ -31,7 +31,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
SuperByteBuffer flapBuffer = CachedBufferer.partial(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
VertexConsumer vb = buffer.getBuffer(RenderType.solid());

View file

@ -153,7 +153,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
}
float nextOffset = itemPosition.value + itemMotion;
if (itemMotion < 0) {
if (nextOffset < .5f) {
if (!handleDownwardOutput(true))
@ -352,7 +352,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
ChuteTileEntity targetChute = getTargetChute(blockState);
Direction direction = AbstractChuteBlock.getChuteFacing(blockState);
if (level == null)
if (level == null || direction == null || !this.canOutputItems())
return false;
if (!capBelow.isPresent())
capBelow = grabCapability(Direction.DOWN);
@ -404,7 +404,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
private boolean handleUpwardOutput(boolean simulate) {
BlockState stateAbove = level.getBlockState(worldPosition.above());
if (level == null)
if (level == null || !this.canOutputItems())
return false;
if (AbstractChuteBlock.isOpenChute(getBlockState())) {
@ -477,6 +477,10 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
return true;
}
protected boolean canOutputItems() {
return true;
}
private LazyOptional<IItemHandler> grabCapability(Direction side) {
BlockPos pos = this.worldPosition.relative(side);
if (level == null)

View file

@ -41,6 +41,12 @@ public class SmartChuteTileEntity extends ChuteTileEntity {
BlockState blockState = getBlockState();
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED);
}
@Override
protected boolean canOutputItems() {
BlockState blockState = getBlockState();
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED);
}
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {

View file

@ -47,7 +47,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer {
float lidProgress = ((EjectorTileEntity) te).getLidProgress(partialTicks);
float angle = lidProgress * 70;
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
SuperByteBuffer model = CachedBufferer.partial(AllBlockPartials.EJECTOR_TOP, te.getBlockState());
applyLidAngle(te, angle, model);
model.light(light)

View file

@ -4,6 +4,7 @@ import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.core.materials.FlatLit;
import com.mojang.math.Vector3f;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.core.BlockPos;
public class FlapData extends InstanceData implements FlatLit<FlapData> {
@ -42,18 +43,23 @@ public class FlapData extends InstanceData implements FlatLit<FlapData> {
@Override
public FlapData setBlockLight(int blockLight) {
this.blockLight = (byte) ((blockLight & 0xF) << 4);
this.blockLight = (byte) (blockLight & 0xF);
markDirty();
return this;
}
@Override
public FlapData setSkyLight(int skyLight) {
this.skyLight = (byte) ((skyLight & 0xF) << 4);
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;

View file

@ -1,12 +1,11 @@
package com.simibubi.create.content.logistics.block.flap;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.core.layout.BufferLayout;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
@ -19,7 +18,7 @@ public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
}
@Override
public VertexFormat format() {
public BufferLayout getLayout() {
return AllInstanceFormats.FLAP;
}
@ -34,7 +33,27 @@ public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
}
@Override
public BatchingTransformer<FlapData> getTransformer(Model model) {
return null;
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;
}
}
}

View file

@ -12,13 +12,13 @@ public class UnsafeFlapWriter extends UnsafeBufferWriter<FlapData> {
}
@Override
public void write(FlapData d) {
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, d.blockLight);
MemoryUtil.memPutByte(addr + 13, d.skyLight);
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);
@ -29,7 +29,5 @@ public class UnsafeFlapWriter extends UnsafeBufferWriter<FlapData> {
MemoryUtil.memPutFloat(addr + 42, d.intensity);
MemoryUtil.memPutFloat(addr + 46, d.flapScale);
MemoryUtil.memPutFloat(addr + 50, d.flapness);
advance();
}
}

View file

@ -30,7 +30,7 @@ public class FunnelRenderer extends SmartTileEntityRenderer<FunnelTileEntity> {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (!te.hasFlap() || Backend.getInstance().canUseInstancing(te.getLevel()))
if (!te.hasFlap() || Backend.canUseInstancing(te.getLevel()))
return;
BlockState blockState = te.getBlockState();

View file

@ -39,7 +39,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
ArmTileEntity arm = (ArmTileEntity) te;
ItemStack item = arm.heldItem;
boolean hasItem = !item.isEmpty();
boolean usingFlywheel = Backend.getInstance().canUseInstancing(te.getLevel());
boolean usingFlywheel = Backend.canUseInstancing(te.getLevel());
if (usingFlywheel && !hasItem) return;

View file

@ -26,7 +26,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState leverState = te.getBlockState();
float state = te.clientState.get(partialTicks);

View file

@ -31,6 +31,8 @@ import net.minecraft.world.level.block.WallBlock;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraftforge.client.model.generators.ModelFile;
import static com.simibubi.create.AllTags.pickaxeOnly;
public abstract class PaletteBlockPartial<B extends Block> {
public static final PaletteBlockPartial<StairBlock> STAIR = new Stairs();
@ -74,7 +76,7 @@ public abstract class PaletteBlockPartial<B extends Block> {
protected BlockBuilder<B, CreateRegistrate> transformBlock(BlockBuilder<B, CreateRegistrate> builder,
String variantName, PaletteBlockPattern pattern) {
getBlockTags().forEach(builder::tag);
return builder;
return builder.transform(pickaxeOnly());
}
protected ItemBuilder<BlockItem, BlockBuilder<B, CreateRegistrate>> transformItem(

View file

@ -45,7 +45,7 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor
protected List<BlockEntity> renderedTileEntities;
protected List<Entity> entities;
protected BoundingBox bounds;
public BlockPos anchor;
public boolean renderMode;
@ -149,12 +149,12 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor
public int getBrightness(LightLayer p_226658_1_, BlockPos p_226658_2_) {
return 10;
}
@Override
public LevelTickAccess<Block> getBlockTicks() {
return BlackholeTickAccess.emptyLevelList();
}
@Override
public LevelTickAccess<Fluid> getFluidTicks() {
return BlackholeTickAccess.emptyLevelList();
@ -170,7 +170,7 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor
Predicate<? super T> arg2) {
return Collections.emptyList();
}
@Override
public List<? extends Player> players() {
return Collections.emptyList();

View file

@ -38,8 +38,7 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
if (blocksLaunching)
renderLaunchedBlocks(tileEntity, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance()
.canUseInstancing(tileEntity.getLevel()))
if (Backend.canUseInstancing(tileEntity.getLevel()))
return;
BlockPos pos = tileEntity.getBlockPos();

View file

@ -1,33 +1,33 @@
package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.layout.CommonItems;
import com.jozufozu.flywheel.core.layout.BufferLayout;
public class AllInstanceFormats {
public static VertexFormat ROTATING = kineticInstance()
.addAttributes(CommonAttributes.NORMAL)
public static BufferLayout ROTATING = kineticInstance()
.addItems(CommonItems.NORMAL)
.build();
public static VertexFormat BELT = kineticInstance()
.addAttributes(CommonAttributes.QUATERNION, CommonAttributes.UV, CommonAttributes.VEC4,
CommonAttributes.NORMALIZED_BYTE)
public static BufferLayout BELT = kineticInstance()
.addItems(CommonItems.QUATERNION, CommonItems.UV, CommonItems.VEC4,
CommonItems.NORMALIZED_BYTE)
.build();
public static VertexFormat ACTOR = VertexFormat.builder()
.addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.FLOAT,
CommonAttributes.NORMAL, CommonAttributes.QUATERNION, CommonAttributes.NORMAL,
CommonAttributes.FLOAT)
public static BufferLayout ACTOR = BufferLayout.builder()
.addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.FLOAT,
CommonItems.NORMAL, CommonItems.QUATERNION, CommonItems.NORMAL,
CommonItems.FLOAT)
.build();
public static VertexFormat FLAP = VertexFormat.builder()
.addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.VEC3, CommonAttributes.VEC3,
CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT)
public static BufferLayout FLAP = BufferLayout.builder()
.addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.VEC3, CommonItems.VEC3,
CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT)
.build();
private static VertexFormat.Builder kineticInstance() {
return Formats.litInstance()
.addAttributes(CommonAttributes.VEC3, CommonAttributes.FLOAT, CommonAttributes.FLOAT);
private static BufferLayout.Builder kineticInstance() {
return BufferLayout.builder()
.addItems(CommonItems.LIGHT, CommonItems.RGBA)
.addItems(CommonItems.VEC3, CommonItems.FLOAT, CommonItems.FLOAT);
}
}

View file

@ -1,6 +1,7 @@
package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.util.BufferBuilderReader;
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
import com.jozufozu.flywheel.api.vertex.VertexList;
import com.jozufozu.flywheel.util.transform.Rotate;
import com.jozufozu.flywheel.util.transform.Scale;
import com.jozufozu.flywheel.util.transform.TStack;
@ -31,10 +32,10 @@ import net.minecraftforge.client.model.pipeline.LightUtil;
public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperByteBuffer>, Rotate<SuperByteBuffer>, TStack<SuperByteBuffer> {
private final BufferBuilderReader template;
private final VertexList template;
// Vertex Position
private PoseStack transforms;
private final PoseStack transforms;
// Vertex Coloring
private boolean shouldColor;
@ -61,12 +62,9 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
// Temporary
private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap();
private final Vector4f pos = new Vector4f();
private final Vector3f normal = new Vector3f();
private final Vector4f lightPos = new Vector4f();
public SuperByteBuffer(BufferBuilder buf) {
template = new BufferBuilderReader(buf);
template = new BlockVertexList(buf);
transforms = new PoseStack();
transforms.pushPose();
}
@ -105,6 +103,10 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
WORLD_LIGHT_CACHE.clear();
}
final Vector4f pos = new Vector4f();
final Vector3f normal = new Vector3f();
final Vector4f lightPos = new Vector4f();
float f = .5f;
int vertexCount = template.getVertexCount();
for (int i = 0; i < vertexCount; i++) {
@ -115,9 +117,9 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
byte g = template.getG(i);
byte b = template.getB(i);
byte a = template.getA(i);
float normalX = template.getNX(i) / 127f;
float normalY = template.getNY(i) / 127f;
float normalZ = template.getNZ(i) / 127f;
float normalX = template.getNX(i);
float normalY = template.getNY(i);
float normalZ = template.getNZ(i);
normal.set(normalX, normalY, normalZ);
normal.transform(normalMat);
@ -132,6 +134,7 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
pos.transform(modelMat);
builder.vertex(pos.x(), pos.y(), pos.z());
//builder.color(nx, ny, nz, 1f);
if (shouldColor) {
if (disableDiffuseMult) {
builder.color(this.r, this.g, this.b, this.a);

View file

@ -48,7 +48,7 @@ public class TileEntityRenderHelper {
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
while (iterator.hasNext()) {
BlockEntity tileEntity = iterator.next();
if (Backend.getInstance().canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance()
if (Backend.canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance()
.shouldSkipRender(tileEntity)) continue;
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity);

View file

@ -116,6 +116,32 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements IParti
read(tag, false);
}
/* TODO: Remove this hack once this issue is resolved: https://github.com/MinecraftForge/MinecraftForge/issues/8302
Once the PR linked in the issue is accepted, we should use the new method for determining whether setRemoved was
called due to a chunk unload or not, and remove this volatile workaround
*/
private boolean unloaded;
@Override
public void onChunkUnloaded() {
super.onChunkUnloaded();
unloaded = true;
}
protected void setRemovedNotDueToChunkUnload() {
}
@Override
public void setRemoved() {
forEachBehaviour(TileEntityBehaviour::remove);
super.setRemoved();
if (!unloaded) {
setRemovedNotDueToChunkUnload();
}
}
@Override
public final void saveAdditional(CompoundTag tag) {
write(tag, false);
@ -158,12 +184,6 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements IParti
}
}
@Override
public void setRemoved() {
forEachBehaviour(TileEntityBehaviour::remove);
super.setRemoved();
}
public void setLazyTickRate(int slowTickRate) {
this.lazyTickRate = slowTickRate;
this.lazyTickCounter = slowTickRate;

View file

@ -18,7 +18,7 @@ public abstract class ColoredOverlayTileEntityRenderer<T extends BlockEntity> ex
protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light);
render.renderInto(ms, buffer.getBuffer(RenderType.solid()));

View file

@ -2,6 +2,7 @@ package com.simibubi.create.foundation.utility;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.util.Mth;
public class AngleHelper {
@ -40,4 +41,12 @@ public class AngleHelper {
return (float) (((((target - current) % 360) + 540) % 360) - 180);
}
public static float getShortestAngleDiff(double current, double target, float hint) {
float diff = getShortestAngleDiff(current, target);
if (Mth.equal(Math.abs(diff), 180) && Math.signum(diff) != Math.signum(hint)) {
return diff + 360*Math.signum(hint);
}
return diff;
}
}

View file

@ -1,5 +1,7 @@
package com.simibubi.create.foundation.utility.worldWrappers;
import javax.annotation.Nullable;
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.ChunkStatus;
@ -10,7 +12,7 @@ public class DummyStatusListener implements ChunkProgressListener {
public void updateSpawnPos(ChunkPos pCenter) {}
@Override
public void onStatusChange(ChunkPos pChunkPosition, ChunkStatus pNewStatus) {}
public void onStatusChange(ChunkPos pChunkPosition, @Nullable ChunkStatus pNewStatus) {}
@Override
public void start() {}

View file

@ -7,6 +7,8 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.FlywheelWorld;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
@ -27,12 +29,12 @@ import net.minecraft.world.level.lighting.LevelLightEngine;
import javax.annotation.Nonnull;
public class PlacementSimulationWorld extends WrappedWorld implements FlywheelWorld {
public Map<BlockPos, BlockState> blocksAdded;
public Map<BlockPos, BlockEntity> tesAdded;
public Map<BlockPos, BlockState> blocksAdded = new HashMap<>();
public Map<BlockPos, BlockEntity> tesAdded = new HashMap<>();
public Set<SectionPos> spannedSections;
public Set<SectionPos> spannedSections = new HashSet<>();
public LevelLightEngine lighter;
public WrappedChunkProvider chunkProvider;
public final WrappedChunkProvider chunkSource;
private final BlockPos.MutableBlockPos scratch = new BlockPos.MutableBlockPos();
private final ContraptionWorld contraptionWorld;
@ -41,22 +43,20 @@ public class PlacementSimulationWorld extends WrappedWorld implements FlywheelWo
this(wrapped, c, new WrappedChunkProvider());
}
public PlacementSimulationWorld(Level wrapped, @Nonnull Contraption c, WrappedChunkProvider chunkProvider) {
super(wrapped, chunkProvider);
public PlacementSimulationWorld(Level wrapped, @Nonnull Contraption c, WrappedChunkProvider chunkSource) {
super(wrapped, chunkSource);
// You can't leak this before the super ctor is called.
// You can't create inner classes before super ctor is called.
chunkSource.setPlacementWorld(this);
this.chunkSource = chunkSource;
contraptionWorld = c.getContraptionWorld();
this.chunkProvider = chunkProvider.setPlacementWorld(this);
spannedSections = new HashSet<>();
lighter = new LevelLightEngine(chunkProvider, true, false); // blockLight, skyLight
blocksAdded = new HashMap<>();
tesAdded = new HashMap<>();
lighter = new LevelLightEngine(chunkSource, true, false);
}
@Override
public LevelLightEngine getLightEngine() {
return lighter;
}
public void updateLightSources() {
/**
* Run this after you're done using setBlock().
*/
public void runLightingEngine() {
for (Map.Entry<BlockPos, BlockState> entry : blocksAdded.entrySet()) {
BlockPos pos = entry.getKey();
BlockState state = entry.getValue();
@ -65,6 +65,13 @@ public class PlacementSimulationWorld extends WrappedWorld implements FlywheelWo
lighter.onBlockEmissionIncrease(pos, light);
}
}
lighter.runUpdates(Integer.MAX_VALUE, false, false);
}
@Override
public LevelLightEngine getLightEngine() {
return lighter;
}
public void setTileEntities(Collection<BlockEntity> tileEntities) {
@ -98,6 +105,7 @@ public class PlacementSimulationWorld extends WrappedWorld implements FlywheelWo
}
@Override
@Nullable
public BlockEntity getBlockEntity(BlockPos pos) {
return tesAdded.get(pos);
}
@ -142,10 +150,10 @@ public class PlacementSimulationWorld extends WrappedWorld implements FlywheelWo
// Override Starlight's ExtendedWorld interface methods:
public LevelChunk getChunkAtImmediately(final int chunkX, final int chunkZ) {
return chunkProvider.getChunk(chunkX, chunkZ, false);
return chunkSource.getChunk(chunkX, chunkZ, false);
}
public ChunkAccess getAnyChunkImmediately(final int chunkX, final int chunkZ) {
return chunkProvider.getChunk(chunkX, chunkZ);
return chunkSource.getChunk(chunkX, chunkZ);
}
}

View file

@ -11,8 +11,8 @@ import net.minecraft.world.level.material.FluidState;
public class RayTraceWorld implements BlockGetter {
private LevelAccessor template;
private BiFunction<BlockPos, BlockState, BlockState> stateGetter;
private final LevelAccessor template;
private final BiFunction<BlockPos, BlockState, BlockState> stateGetter;
public RayTraceWorld(LevelAccessor template, BiFunction<BlockPos, BlockState, BlockState> stateGetter) {
this.template = template;

View file

@ -29,11 +29,11 @@ public class WrappedChunkProvider extends ChunkSource {
fallbackWorld = world;
return this;
}
public WrappedChunkProvider setPlacementWorld(PlacementSimulationWorld world) {
// VirtualChunkSource is created before VirtualRenderWorld, so we can't initialize it in the ctor.
public void setPlacementWorld(PlacementSimulationWorld world) {
fallbackWorld = this.world = world;
this.chunks = new HashMap<>();
return this;
}
public Stream<BlockPos> getLightSources() {

View file

@ -33,8 +33,6 @@ import net.minecraft.world.level.storage.WritableLevelData;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.world.ticks.LevelTickAccess;
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class WrappedWorld extends Level {
protected Level world;
@ -68,17 +66,18 @@ public class WrappedWorld extends Level {
}
@Override
public boolean isStateAtPosition(@Nullable BlockPos p_217375_1_, @Nullable Predicate<BlockState> p_217375_2_) {
public boolean isStateAtPosition(BlockPos p_217375_1_, Predicate<BlockState> p_217375_2_) {
return world.isStateAtPosition(p_217375_1_, p_217375_2_);
}
@Override
public BlockEntity getBlockEntity(@Nullable BlockPos pos) {
@Nullable
public BlockEntity getBlockEntity(BlockPos pos) {
return world.getBlockEntity(pos);
}
@Override
public boolean setBlock(@Nullable BlockPos pos, @Nullable BlockState newState, int flags) {
public boolean setBlock(BlockPos pos, BlockState newState, int flags) {
return world.setBlock(pos, newState, flags);
}

View file

@ -0,0 +1,6 @@
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
package com.simibubi.create.foundation.utility.worldWrappers;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -32,6 +32,6 @@ Technology that empowers the player.'''
[[dependencies.create]]
modId="flywheel"
mandatory=true
versionRange="[1.18-0.4.0,1.18-0.4.2)"
versionRange="[1.18-0.5.0,1.18-0.5.1)"
ordering="AFTER"
side="BOTH"

View file

@ -5,10 +5,10 @@
struct Vertex {
vec3 pos;
vec3 normal;
vec2 texCoords;
vec4 color;
vec2 texCoords;
vec2 modelLight;
vec3 normal;
};
#use "flywheel:block.frag"

View file

@ -31,8 +31,8 @@ float getFlapAngle(float flapness, float intensity, float 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
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}

View file

@ -1,31 +0,0 @@
{
"conditions": [
{
"type": "forge:mod_loaded",
"modid": "quark"
}
],
"type": "create:crushing",
"ingredients": [
{
"item": "quark:biotite_ore"
}
],
"results": [
{
"item": "quark:biotite",
"count": 2
},
{
"item": "quark:biotite",
"count": 4,
"chance": 0.5
},
{
"item": "minecraft:end_stone",
"count": 1,
"chance": 0.125
}
],
"processingTime": 450
}

View file

@ -9,19 +9,19 @@
"group": "minecraft:misc",
"ingredients": [
{
"item": "minecraft:cactus"
"item": "minecraft:moss_block"
}
],
],
"results": [
{
"item": "quark:cactus_paste",
"item": "quark:moss_paste",
"count": 2
},
{
"item": "quark:cactus_paste",
"item": "quark:moss_paste",
"count": 1,
"chance": 0.1
}
],
"processingTime": 50
}
}