Merge remote-tracking branch 'origin/mc1.16/dev' into mc1.16/dev

# Conflicts:
#	src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java
This commit is contained in:
zelophed 2021-08-07 01:23:43 +02:00
commit ca02ac038f
51 changed files with 495 additions and 298 deletions

View file

@ -187,6 +187,40 @@ reobf {
shadowJar {} shadowJar {}
} }
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveBaseName.set(project.archivesBaseName)
archiveVersion.set("${project.version}")
archiveClassifier.set('sources')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
archiveClassifier.set('javadoc')
}
artifacts {
archives jar, shadowJar, sourcesJar, javadocJar
}
publishing {
tasks.publish.dependsOn 'build'
publications {
mavenJava(MavenPublication) {
artifact shadowJar
artifact sourcesJar
artifact javadocJar
}
}
repositories {
if (project.hasProperty('mavendir')) {
maven { url mavendir }
}
}
}
String getChangelogText() { String getChangelogText() {
def changelogFile = file('changelog.txt') def changelogFile = file('changelog.txt')
String str = '' String str = ''

View file

@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false org.gradle.daemon = false
# mod version info # mod version info
mod_version = 0.3.2c mod_version = 0.3.2d
minecraft_version = 1.16.5 minecraft_version = 1.16.5
forge_version = 36.2.0 forge_version = 36.2.0
@ -16,7 +16,7 @@ cursegradle_version = 1.4.0
# dependency versions # dependency versions
registrate_version = 1.0.10 registrate_version = 1.0.10
flywheel_version = 1.16-0.2.0.34 flywheel_version = 1.16-0.2.3.44
jei_version = 7.7.1.116 jei_version = 7.7.1.116
# curseforge information # curseforge information

1
settings.gradle Normal file
View file

@ -0,0 +1 @@
rootProject.name = 'Create'

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"create:sand_paper",
"create:red_sand_paper"
]
}

View file

@ -228,10 +228,12 @@ public class AllItems {
public static final ItemEntry<SandPaperItem> SAND_PAPER = REGISTRATE.item("sand_paper", SandPaperItem::new) public static final ItemEntry<SandPaperItem> SAND_PAPER = REGISTRATE.item("sand_paper", SandPaperItem::new)
.transform(CreateRegistrate.customRenderedItem(() -> SandPaperModel::new)) .transform(CreateRegistrate.customRenderedItem(() -> SandPaperModel::new))
.tag(AllTags.AllItemTags.SANDPAPER.tag)
.register(); .register();
public static final ItemEntry<SandPaperItem> RED_SAND_PAPER = REGISTRATE.item("red_sand_paper", SandPaperItem::new) public static final ItemEntry<SandPaperItem> RED_SAND_PAPER = REGISTRATE.item("red_sand_paper", SandPaperItem::new)
.transform(CreateRegistrate.customRenderedItem(() -> SandPaperModel::new)) .transform(CreateRegistrate.customRenderedItem(() -> SandPaperModel::new))
.tag(AllTags.AllItemTags.SANDPAPER.tag)
.onRegister(s -> TooltipHelper.referTo(s, SAND_PAPER)) .onRegister(s -> TooltipHelper.referTo(s, SAND_PAPER))
.register(); .register();

View file

@ -79,6 +79,7 @@ public class AllTags {
SEATS(MOD), SEATS(MOD),
VALVE_HANDLES(MOD), VALVE_HANDLES(MOD),
UPRIGHT_ON_BELT(MOD), UPRIGHT_ON_BELT(MOD),
SANDPAPER(MOD),
CREATE_INGOTS(MOD), CREATE_INGOTS(MOD),
BEACON_PAYMENT(FORGE), BEACON_PAYMENT(FORGE),
INGOTS(FORGE), INGOTS(FORGE),

View file

@ -58,7 +58,7 @@ public class Create {
public static final String ID = "create"; public static final String ID = "create";
public static final String NAME = "Create"; public static final String NAME = "Create";
public static final String VERSION = "0.3.2c"; public static final String VERSION = "0.3.2d";
public static final Logger LOGGER = LogManager.getLogger(); public static final Logger LOGGER = LogManager.getLogger();
@ -109,6 +109,7 @@ public class Create {
modEventBus.addListener(AllConfigs::onReload); modEventBus.addListener(AllConfigs::onReload);
modEventBus.addListener(EventPriority.LOWEST, this::gatherData); modEventBus.addListener(EventPriority.LOWEST, this::gatherData);
forgeEventBus.addListener(EventPriority.HIGH, Create::onBiomeLoad); forgeEventBus.addListener(EventPriority.HIGH, Create::onBiomeLoad);
forgeEventBus.register(CHUNK_UTIL);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
() -> () -> CreateClient.addClientListeners(forgeEventBus, modEventBus)); () -> () -> CreateClient.addClientListeners(forgeEventBus, modEventBus));
@ -116,16 +117,14 @@ public class Create {
public static void init(final FMLCommonSetupEvent event) { public static void init(final FMLCommonSetupEvent event) {
CapabilityMinecartController.register(); CapabilityMinecartController.register();
SchematicInstances.register();
CHUNK_UTIL.init();
MinecraftForge.EVENT_BUS.register(CHUNK_UTIL);
AllPackets.registerPackets(); AllPackets.registerPackets();
AllTriggers.register(); SchematicInstances.register();
PotatoCannonProjectileTypes.register(); PotatoCannonProjectileTypes.register();
CHUNK_UTIL.init();
event.enqueueWork(() -> { event.enqueueWork(() -> {
AllTriggers.register();
SchematicProcessor.register(); SchematicProcessor.register();
AllWorldFeatures.registerFeatures(); AllWorldFeatures.registerFeatures();
}); });

View file

@ -107,12 +107,12 @@ public class CreateClient {
UIRenderHelper.init(); UIRenderHelper.init();
IResourceManager resourceManager = Minecraft.getInstance()
.getResourceManager();
if (resourceManager instanceof IReloadableResourceManager)
((IReloadableResourceManager) resourceManager).registerReloadListener(new ResourceReloadHandler());
event.enqueueWork(() -> { event.enqueueWork(() -> {
IResourceManager resourceManager = Minecraft.getInstance()
.getResourceManager();
if (resourceManager instanceof IReloadableResourceManager)
((IReloadableResourceManager) resourceManager).registerReloadListener(new ResourceReloadHandler());
registerLayerRenderers(Minecraft.getInstance() registerLayerRenderers(Minecraft.getInstance()
.getEntityRenderDispatcher()); .getEntityRenderDispatcher());
}); });

View file

@ -123,7 +123,7 @@ public class CreateJEI implements IModPlugin {
autoShapeless = register("automatic_shapeless", MixingCategory::autoShapeless) autoShapeless = register("automatic_shapeless", MixingCategory::autoShapeless)
.recipes(r -> r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && r.getIngredients() .recipes(r -> r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && r.getIngredients()
.size() > 1 && !MechanicalPressTileEntity.canCompress(r.getIngredients()), .size() > 1 && !MechanicalPressTileEntity.canCompress(r),
BasinRecipe::convertShapeless) BasinRecipe::convertShapeless)
.catalyst(AllBlocks.MECHANICAL_MIXER::get) .catalyst(AllBlocks.MECHANICAL_MIXER::get)
.catalyst(AllBlocks.BASIN::get) .catalyst(AllBlocks.BASIN::get)
@ -160,7 +160,7 @@ public class CreateJEI implements IModPlugin {
.build(), .build(),
autoSquare = register("automatic_packing", PackingCategory::autoSquare) autoSquare = register("automatic_packing", PackingCategory::autoSquare)
.recipes(r -> (r instanceof ICraftingRecipe) && MechanicalPressTileEntity.canCompress(r.getIngredients()), .recipes(r -> (r instanceof ICraftingRecipe) && MechanicalPressTileEntity.canCompress(r),
BasinRecipe::convertShapeless) BasinRecipe::convertShapeless)
.catalyst(AllBlocks.MECHANICAL_PRESS::get) .catalyst(AllBlocks.MECHANICAL_PRESS::get)
.catalyst(AllBlocks.BASIN::get) .catalyst(AllBlocks.BASIN::get)

View file

@ -44,7 +44,7 @@ public class DrillRenderer extends KineticTileEntityRenderer {
float time = AnimationTickHolder.getRenderTime() / 20; float time = AnimationTickHolder.getRenderTime() / 20;
float angle = (float) (((time * speed) % 360)); float angle = (float) (((time * speed) % 360));
MatrixStack m = matrices.contraptionStack; MatrixStack m = matrices.getModel();
m.pushPose(); m.pushPose();
MatrixTransformStack.of(m) MatrixTransformStack.of(m)
.centre() .centre()
@ -55,9 +55,9 @@ public class DrillRenderer extends KineticTileEntityRenderer {
superBuffer superBuffer
.transform(m) .transform(m)
.light(matrices.entityMatrix, .light(matrices.getWorld(),
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, buffer.getBuffer(RenderType.solid())); .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
m.popPose(); m.popPose();
} }

View file

@ -52,13 +52,13 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
if (context.contraption.stalled) if (context.contraption.stalled)
speed = 0; speed = 0;
superBuffer.transform(matrices.contraptionStack); superBuffer.transform(matrices.getModel());
transform(context.world, facing, superBuffer, speed); transform(context.world, facing, superBuffer, speed);
superBuffer superBuffer
.light(matrices.entityMatrix, .light(matrices.getWorld(),
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, buffers.getBuffer(RenderType.cutoutMipped())); .renderInto(matrices.getViewProjection(), buffers.getBuffer(RenderType.cutoutMipped()));
} }
public static void transform(World world, Direction facing, SuperByteBuffer superBuffer, float speed) { public static void transform(World world, Direction facing, SuperByteBuffer superBuffer, float speed) {

View file

@ -56,9 +56,9 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
lit = te.isConnected(); lit = te.isConnected();
} }
render(blockState, lit, progress, matrices.contraptionStack, sbb -> sbb.light(matrices.entityMatrix, render(blockState, lit, progress, matrices.getModel(), sbb -> sbb.light(matrices.getWorld(),
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, vb)); .renderInto(matrices.getViewProjection(), vb));
} }
private static void render(BlockState blockState, boolean lit, float progress, private static void render(BlockState blockState, boolean lit, float progress,

View file

@ -14,7 +14,6 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -34,7 +33,6 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
CuckooClockTileEntity clock = (CuckooClockTileEntity) te; CuckooClockTileEntity clock = (CuckooClockTileEntity) te;
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos());
Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING); Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING);
IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
@ -44,9 +42,9 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
SuperByteBuffer minuteHand = PartialBufferer.get(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState); SuperByteBuffer minuteHand = PartialBufferer.get(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
float hourAngle = clock.hourHand.get(partialTicks); float hourAngle = clock.hourHand.get(partialTicks);
float minuteAngle = clock.minuteHand.get(partialTicks); float minuteAngle = clock.minuteHand.get(partialTicks);
rotateHand(hourHand, hourAngle, direction).light(packedLightmapCoords) rotateHand(hourHand, hourAngle, direction).light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
rotateHand(minuteHand, minuteAngle, direction).light(packedLightmapCoords) rotateHand(minuteHand, minuteAngle, direction).light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
// Doors // Doors
@ -72,9 +70,9 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
} }
} }
rotateDoor(leftDoor, angle, true, direction).light(packedLightmapCoords) rotateDoor(leftDoor, angle, true, direction).light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
rotateDoor(rightDoor, angle, false, direction).light(packedLightmapCoords) rotateDoor(rightDoor, angle, false, direction).light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
// Figure // Figure
@ -85,7 +83,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
PartialBufferer.get(partialModel, blockState); PartialBufferer.get(partialModel, blockState);
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise()))); figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise())));
figure.translate(offset, 0, 0); figure.translate(offset, 0, 0);
figure.light(packedLightmapCoords) figure.light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
} }

View file

@ -22,7 +22,6 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -169,41 +168,39 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) { if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) {
SuperByteBuffer lidBuffer = SuperByteBuffer lidBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState, pos); renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState);
lidBuffer.renderInto(ms, vb); lidBuffer.light(light).renderInto(ms, vb);
} }
if (MechanicalCrafterBlock.isValidTarget(te.getLevel(), pos.relative(targetDirection), blockState)) { if (MechanicalCrafterBlock.isValidTarget(te.getLevel(), pos.relative(targetDirection), blockState)) {
SuperByteBuffer beltBuffer = SuperByteBuffer beltBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState, pos); renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState);
SuperByteBuffer beltFrameBuffer = SuperByteBuffer beltFrameBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState, pos); renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState);
if (te.phase == Phase.EXPORTING) { if (te.phase == Phase.EXPORTING) {
int textureIndex = (int) ((te.getCountDownSpeed() / 128f * AnimationTickHolder.getTicks())); int textureIndex = (int) ((te.getCountDownSpeed() / 128f * AnimationTickHolder.getTicks()));
beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1); beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1);
} }
beltBuffer.renderInto(ms, vb); beltBuffer.light(light).renderInto(ms, vb);
beltFrameBuffer.renderInto(ms, vb); beltFrameBuffer.light(light).renderInto(ms, vb);
} else { } else {
SuperByteBuffer arrowBuffer = SuperByteBuffer arrowBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState, pos); renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState);
arrowBuffer.renderInto(ms, vb); arrowBuffer.light(light).renderInto(ms, vb);
} }
} }
private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, PartialModel renderBlock, private SuperByteBuffer renderAndTransform(PartialModel renderBlock, BlockState crafterState) {
BlockState crafterState, BlockPos pos) {
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState); SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState);
float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING) float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING)
.getXRotation(); .getXRotation();
float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING)); float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING));
buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
buffer.light(WorldRenderer.getLightColor(te.getLevel(), crafterState, pos));
return buffer; return buffer;
} }

View file

@ -156,8 +156,10 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
continue; continue;
if (neighbour.getValue(BlockStateProperties.AXIS) == d.getAxis()) if (neighbour.getValue(BlockStateProperties.AXIS) == d.getAxis())
continue; continue;
KineticTileEntity wheelTe = (KineticTileEntity) world.getBlockEntity(pos.relative(d)); TileEntity adjTe = world.getBlockEntity(pos.relative(d));
te.crushingspeed = Math.abs(wheelTe.getSpeed() / 50f); if (!(adjTe instanceof KineticTileEntity))
continue;
te.crushingspeed = Math.abs(((KineticTileEntity) adjTe).getSpeed() / 50f);
te.sendData(); te.sendData();
break; break;
} }

View file

@ -6,9 +6,8 @@ import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.Create; import com.simibubi.create.AllTags.AllItemTags;
import com.simibubi.create.compat.jei.category.sequencedAssembly.SequencedAssemblySubCategory; import com.simibubi.create.compat.jei.category.sequencedAssembly.SequencedAssemblySubCategory;
import com.simibubi.create.content.contraptions.itemAssembly.IAssemblyRecipe; import com.simibubi.create.content.contraptions.itemAssembly.IAssemblyRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
@ -20,6 +19,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.IItemProvider; import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
@ -66,10 +66,10 @@ public class DeployerApplicationRecipe extends ProcessingRecipe<RecipeWrapper> i
public static List<DeployerApplicationRecipe> convert(List<IRecipe<?>> sandpaperRecipes) { public static List<DeployerApplicationRecipe> convert(List<IRecipe<?>> sandpaperRecipes) {
return sandpaperRecipes.stream() return sandpaperRecipes.stream()
.map(r -> new ProcessingRecipeBuilder<>(DeployerApplicationRecipe::new, Create.asResource(r.getId() .map(r -> new ProcessingRecipeBuilder<>(DeployerApplicationRecipe::new, new ResourceLocation(r.getId().getNamespace(), r.getId()
.getPath() + "_using_deployer")).require(r.getIngredients() .getPath() + "_using_deployer")).require(r.getIngredients()
.get(0)) .get(0))
.require(Ingredient.of(AllItems.SAND_PAPER.get(), AllItems.RED_SAND_PAPER.get())) .require(AllItemTags.SANDPAPER.tag)
.output(r.getResultItem()) .output(r.getResultItem())
.build()) .build())
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -79,7 +79,7 @@ public class DeployerApplicationRecipe extends ProcessingRecipe<RecipeWrapper> i
public void addAssemblyIngredients(List<Ingredient> list) { public void addAssemblyIngredients(List<Ingredient> list) {
list.add(ingredients.get(1)); list.add(ingredients.get(1));
} }
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public ITextComponent getDescriptionForAssembly() { public ITextComponent getDescriptionForAssembly() {
@ -95,7 +95,7 @@ public class DeployerApplicationRecipe extends ProcessingRecipe<RecipeWrapper> i
public void addRequiredMachines(Set<IItemProvider> list) { public void addRequiredMachines(Set<IItemProvider> list) {
list.add(AllBlocks.DEPLOYER.get()); list.add(AllBlocks.DEPLOYER.get());
} }
@Override @Override
public Supplier<Supplier<SequencedAssemblySubCategory>> getJEISubCategory() { public Supplier<Supplier<SequencedAssemblySubCategory>> getJEISubCategory() {
return () -> SequencedAssemblySubCategory.AssemblyDeploying::new; return () -> SequencedAssemblySubCategory.AssemblyDeploying::new;

View file

@ -29,7 +29,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
@ -39,7 +38,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f; import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.World;
public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> { public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
@ -117,16 +115,17 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
} }
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
BlockPos pos = te.getBlockPos();
Vector3d offset = getHandOffset(te, partialTicks, blockState); Vector3d offset = getHandOffset(te, partialTicks, blockState);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState); SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState);
transform(te.getLevel(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms, transform(pole.translate(offset.x, offset.y, offset.z), blockState, true)
vb); .light(light)
transform(te.getLevel(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms, .renderInto(ms, vb);
vb); transform(hand.translate(offset.x, offset.y, offset.z), blockState, false)
.light(light)
.renderInto(ms, vb);
} }
protected Vector3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) { protected Vector3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) {
@ -138,8 +137,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te)); return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te));
} }
private static SuperByteBuffer transform(World world, SuperByteBuffer buffer, BlockState deployerState, private static SuperByteBuffer transform(SuperByteBuffer buffer, BlockState deployerState, boolean axisDirectionMatters) {
BlockPos pos, boolean axisDirectionMatters) {
Direction facing = deployerState.getValue(FACING); Direction facing = deployerState.getValue(FACING);
float zRotLast = float zRotLast =
@ -151,7 +149,6 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
buffer.rotateCentered(Direction.UP, (float) ((yRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) ((yRot) / 180 * Math.PI));
buffer.rotateCentered(Direction.SOUTH, (float) ((zRotLast) / 180 * Math.PI)); buffer.rotateCentered(Direction.SOUTH, (float) ((zRotLast) / 180 * Math.PI));
buffer.light(WorldRenderer.getLightColor(world, deployerState, pos));
return buffer; return buffer;
} }
@ -159,9 +156,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
ContraptionMatrices matrices, IRenderTypeBuffer buffer) { ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
IVertexBuilder builder = buffer.getBuffer(RenderType.solid()); IVertexBuilder builder = buffer.getBuffer(RenderType.solid());
BlockState blockState = context.state; BlockState blockState = context.state;
BlockPos pos = BlockPos.ZERO;
Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class); Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class);
World world = context.world;
PartialModel handPose = getHandPose(mode); PartialModel handPose = getHandPose(mode);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
@ -181,19 +176,19 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
Vector3d offset = Vector3d.atLowerCornerOf(blockState.getValue(FACING) Vector3d offset = Vector3d.atLowerCornerOf(blockState.getValue(FACING)
.getNormal()).scale(factor); .getNormal()).scale(factor);
MatrixStack m = matrices.contraptionStack; MatrixStack m = matrices.getModel();
m.pushPose(); m.pushPose();
m.translate(offset.x, offset.y, offset.z); m.translate(offset.x, offset.y, offset.z);
pole.transform(m); pole.transform(m);
hand.transform(m); hand.transform(m);
pole = transform(world, pole, blockState, pos, true); pole = transform(pole, blockState, true);
hand = transform(world, hand, blockState, pos, false); hand = transform(hand, blockState, false);
pole.light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) pole.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, builder); .renderInto(matrices.getViewProjection(), builder);
hand.light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) hand.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, builder); .renderInto(matrices.getViewProjection(), builder);
m.popPose(); m.popPose();
} }

View file

@ -10,7 +10,6 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -38,7 +37,7 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
PartialBufferer.get(frame, te.getBlockState()) PartialBufferer.get(frame, te.getBlockState())
.rotateCentered(Direction.UP, angle) .rotateCentered(Direction.UP, angle)
.translate(0, 0, -1) .translate(0, 0, -1)
.light(WorldRenderer.getLightColor(te.getLevel(), te.getBlockState(), te.getBlockPos())) .light(light)
.renderInto(ms, buffer.getBuffer(RenderType.solid())); .renderInto(ms, buffer.getBuffer(RenderType.solid()));
} }
} }

View file

@ -13,10 +13,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
public class MechanicalMixerRenderer extends KineticTileEntityRenderer { public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
@ -37,14 +35,12 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te; MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
BlockPos pos = te.getBlockPos();
IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState); SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, pos);
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
float speed = mixer.getRenderedHeadRotationSpeed(partialTicks); float speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
float time = AnimationTickHolder.getRenderTime(te.getLevel()); float time = AnimationTickHolder.getRenderTime(te.getLevel());
@ -52,13 +48,13 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
SuperByteBuffer poleRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState); SuperByteBuffer poleRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState);
poleRender.translate(0, -renderedHeadOffset, 0) poleRender.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords) .light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
SuperByteBuffer headRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState); SuperByteBuffer headRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState);
headRender.rotateCentered(Direction.UP, angle) headRender.rotateCentered(Direction.UP, angle)
.translate(0, -renderedHeadOffset, 0) .translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords) .light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
} }

View file

@ -13,9 +13,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.math.BlockPos;
public class MechanicalPressRenderer extends KineticTileEntityRenderer { public class MechanicalPressRenderer extends KineticTileEntityRenderer {
@ -35,14 +33,12 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return; if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
BlockPos pos = te.getBlockPos();
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, pos);
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks); float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);
SuperByteBuffer headRender = PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING)); SuperByteBuffer headRender = PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING));
headRender.translate(0, -renderedHeadOffset, 0) headRender.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords) .light(light)
.renderInto(ms, buffer.getBuffer(RenderType.solid())); .renderInto(ms, buffer.getBuffer(RenderType.solid()));
} }

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
@ -31,12 +32,14 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes; import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
@ -339,7 +342,19 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
return AllRecipeTypes.PRESSING.find(pressingInv, level); return AllRecipeTypes.PRESSING.find(pressingInv, level);
} }
public static boolean canCompress(NonNullList<Ingredient> ingredients) { private static final List<ResourceLocation> RECIPE_DENY_LIST =
ImmutableList.of(new ResourceLocation("occultism", "spirit_trade"));
public static <C extends IInventory> boolean canCompress(IRecipe<C> recipe) {
NonNullList<Ingredient> ingredients = recipe.getIngredients();
if (!(recipe instanceof ICraftingRecipe))
return false;
IRecipeSerializer<?> serializer = recipe.getSerializer();
for (ResourceLocation denied : RECIPE_DENY_LIST)
if (serializer != null && denied.equals(serializer.getRegistryName()))
return false;
return AllConfigs.SERVER.recipes.allowShapedSquareInPress.get() return AllConfigs.SERVER.recipes.allowShapedSquareInPress.get()
&& (ingredients.size() == 4 || ingredients.size() == 9) && ItemHelper.condenseIngredients(ingredients) && (ingredients.size() == 4 || ingredients.size() == 9) && ItemHelper.condenseIngredients(ingredients)
.size() == 1; .size() == 1;
@ -347,7 +362,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
@Override @Override
protected <C extends IInventory> boolean matchStaticFilters(IRecipe<C> recipe) { protected <C extends IInventory> boolean matchStaticFilters(IRecipe<C> recipe) {
return (recipe instanceof ICraftingRecipe && canCompress(recipe.getIngredients())) return (recipe instanceof ICraftingRecipe && canCompress(recipe))
|| recipe.getType() == AllRecipeTypes.COMPACTING.getType(); || recipe.getType() == AllRecipeTypes.COMPACTING.getType();
} }

View file

@ -192,7 +192,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state);
} }
MatrixStack m = matrices.contraptionStack; MatrixStack m = matrices.getModel();
m.pushPose(); m.pushPose();
MatrixTransformStack.of(m) MatrixTransformStack.of(m)
.centre() .centre()
@ -205,8 +205,8 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
.unCentre(); .unCentre();
superBuffer.transform(m) superBuffer.transform(m)
.light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, buffer.getBuffer(RenderType.cutoutMipped())); .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped()));
m.popPose(); m.popPose();
} }

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement; package com.simibubi.create.content.contraptions.components.structureMovement;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -39,7 +38,7 @@ public class ContraptionEntityRenderer<C extends AbstractContraptionEntity> exte
Contraption contraption = entity.getContraption(); Contraption contraption = entity.getContraption();
if (contraption != null) { if (contraption != null) {
ContraptionRenderDispatcher.render(entity, contraption, buffers); ContraptionRenderDispatcher.renderFromEntity(entity, contraption, buffers);
} }
} }

View file

@ -53,14 +53,14 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
orientation = rotation; orientation = rotation;
superBuffer.transform(matrices.contraptionStack); superBuffer.transform(matrices.getModel());
superBuffer.rotateCentered(orientation); superBuffer.rotateCentered(orientation);
// render // render
superBuffer superBuffer
.light(matrices.entityMatrix, .light(matrices.getWorld(),
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.entityStack, buffer.getBuffer(RenderType.solid())); .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
} }
@Override @Override

View file

@ -6,64 +6,80 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Matrix3f;
import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Matrix4f;
/**
* <p>
* ContraptionMatrices must be cleared and setup per-contraption per-frame
* </p>
*/
public class ContraptionMatrices { public class ContraptionMatrices {
/** private final MatrixStack modelViewProjection = new MatrixStack();
* The results from using this are undefined. private final MatrixStack viewProjection = new MatrixStack();
*/ private final MatrixStack model = new MatrixStack();
public static final ContraptionMatrices EMPTY = new ContraptionMatrices(); private final Matrix4f world = new Matrix4f();
private final Matrix4f light = new Matrix4f();
public final MatrixStack entityStack; private boolean ready;
public final MatrixStack contraptionStack;
public final MatrixStack finalStack;
public final Matrix4f entityMatrix;
public final Matrix4f lightMatrix;
private ContraptionMatrices() { public ContraptionMatrices() {
this.entityStack = this.contraptionStack = this.finalStack = new MatrixStack(); world.setIdentity();
this.entityMatrix = new Matrix4f(); light.setIdentity();
this.lightMatrix = new Matrix4f();
} }
public ContraptionMatrices(MatrixStack entityStack, AbstractContraptionEntity entity) { public void setup(MatrixStack viewProjection, AbstractContraptionEntity entity) {
this.entityStack = copyStack(entityStack);
this.contraptionStack = new MatrixStack();
float partialTicks = AnimationTickHolder.getPartialTicks(); float partialTicks = AnimationTickHolder.getPartialTicks();
entity.doLocalTransforms(partialTicks, new MatrixStack[] { this.contraptionStack });
entityMatrix = translateTo(entity, partialTicks); this.viewProjection.pushPose();
transform(this.viewProjection, viewProjection);
model.pushPose();
entity.doLocalTransforms(partialTicks, new MatrixStack[] { model });
lightMatrix = entityMatrix.copy(); modelViewProjection.pushPose();
lightMatrix.multiply(contraptionStack.last().pose()); transform(modelViewProjection, viewProjection);
transform(modelViewProjection, model);
finalStack = copyStack(entityStack); translateToEntity(world, entity, partialTicks);
transform(finalStack, contraptionStack);
light.set(world);
light.multiply(model
.last().pose());
ready = true;
} }
public MatrixStack getFinalStack() { public void clear() {
return finalStack; clearStack(modelViewProjection);
clearStack(viewProjection);
clearStack(model);
world.setIdentity();
light.setIdentity();
ready = false;
} }
public Matrix4f getFinalModel() { public MatrixStack getModelViewProjection() {
return finalStack.last().pose(); return modelViewProjection;
} }
public Matrix3f getFinalNormal() { public MatrixStack getViewProjection() {
return finalStack.last().normal(); return viewProjection;
} }
public Matrix4f getFinalLight() { public MatrixStack getModel() {
return lightMatrix; return model;
} }
public static Matrix4f translateTo(Entity entity, float partialTicks) { public Matrix4f getWorld() {
double x = MathHelper.lerp(partialTicks, entity.xOld, entity.getX()); return world;
double y = MathHelper.lerp(partialTicks, entity.yOld, entity.getY()); }
double z = MathHelper.lerp(partialTicks, entity.zOld, entity.getZ());
return Matrix4f.createTranslateMatrix((float) x, (float) y, (float) z); public Matrix4f getLight() {
return light;
}
public boolean isReady() {
return ready;
} }
public static void transform(MatrixStack ms, MatrixStack transform) { public static void transform(MatrixStack ms, MatrixStack transform) {
@ -75,16 +91,17 @@ public class ContraptionMatrices {
.normal()); .normal());
} }
public static MatrixStack copyStack(MatrixStack ms) { public static void translateToEntity(Matrix4f matrix, Entity entity, float partialTicks) {
MatrixStack cms = new MatrixStack(); double x = MathHelper.lerp(partialTicks, entity.xOld, entity.getX());
double y = MathHelper.lerp(partialTicks, entity.yOld, entity.getY());
transform(cms, ms); double z = MathHelper.lerp(partialTicks, entity.zOld, entity.getZ());
matrix.setTranslation((float) x, (float) y, (float) z);
return cms;
} }
public Matrix4f contraptionPose() { public static void clearStack(MatrixStack ms) {
return contraptionStack.last() while (!ms.clear()) {
.pose(); ms.popPose();
}
} }
} }

View file

@ -71,13 +71,24 @@ public class ContraptionRenderDispatcher {
reset(); reset();
} }
public static void render(AbstractContraptionEntity entity, Contraption contraption, IRenderTypeBuffer buffers) { public static void renderFromEntity(AbstractContraptionEntity entity, Contraption contraption, IRenderTypeBuffer buffers) {
World world = entity.level; World world = entity.level;
ContraptionRenderInfo renderInfo = WORLDS.get(world) ContraptionRenderInfo renderInfo = WORLDS.get(world)
.getRenderInfo(contraption); .getRenderInfo(contraption);
ContraptionMatrices matrices = renderInfo.getMatrices();
renderDynamic(world, renderInfo.renderWorld, contraption, renderInfo.getMatrices(), buffers); // something went wrong with the other rendering
if (!matrices.isReady()) return;
PlacementSimulationWorld renderWorld = renderInfo.renderWorld;
renderTileEntities(world, renderWorld, contraption, matrices, buffers);
if (buffers instanceof IRenderTypeBuffer.Impl)
((IRenderTypeBuffer.Impl) buffers).endBatch();
renderActors(world, renderWorld, contraption, matrices, buffers);
} }
public static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) { public static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) {
@ -96,18 +107,10 @@ public class ContraptionRenderDispatcher {
return renderWorld; return renderWorld;
} }
public static void renderDynamic(World world, PlacementSimulationWorld renderWorld, Contraption c,
ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
renderTileEntities(world, renderWorld, c, matrices, buffer);
if (buffer instanceof IRenderTypeBuffer.Impl)
((IRenderTypeBuffer.Impl) buffer).endBatch();
renderActors(world, renderWorld, c, matrices, buffer);
}
public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, Contraption c, public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, Contraption c,
ContraptionMatrices matrices, IRenderTypeBuffer buffer) { ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities,
matrices.getFinalStack(), matrices.getFinalLight(), buffer); matrices.getModelViewProjection(), matrices.getLight(), buffer);
} }
protected static void renderActors(World world, PlacementSimulationWorld renderWorld, Contraption c, protected static void renderActors(World world, PlacementSimulationWorld renderWorld, Contraption c,
@ -120,7 +123,7 @@ public class ContraptionRenderDispatcher {
context.world = world; context.world = world;
Template.BlockInfo blockInfo = actor.getLeft(); Template.BlockInfo blockInfo = actor.getLeft();
MatrixStack m = matrices.contraptionStack; MatrixStack m = matrices.getModel();
m.pushPose(); m.pushPose();
MatrixTransformStack.of(m) MatrixTransformStack.of(m)
.translate(blockInfo.pos); .translate(blockInfo.pos);

View file

@ -1,19 +1,19 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render; package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.jozufozu.flywheel.event.BeginFrameEvent; import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
public class ContraptionRenderInfo { public class ContraptionRenderInfo {
public final Contraption contraption; public final Contraption contraption;
public final PlacementSimulationWorld renderWorld; public final PlacementSimulationWorld renderWorld;
private ContraptionMatrices matrices = ContraptionMatrices.EMPTY; private final ContraptionMatrices matrices = new ContraptionMatrices();
private boolean visible; private boolean visible;
public ContraptionRenderInfo(Contraption contraption, PlacementSimulationWorld renderWorld) { public ContraptionRenderInfo(Contraption contraption, PlacementSimulationWorld renderWorld) {
@ -30,29 +30,41 @@ public class ContraptionRenderInfo {
} }
public void beginFrame(BeginFrameEvent event) { public void beginFrame(BeginFrameEvent event) {
matrices.clear();
AbstractContraptionEntity entity = contraption.entity; AbstractContraptionEntity entity = contraption.entity;
visible = event.getClippingHelper().isVisible(entity.getBoundingBoxForCulling().inflate(2)); visible = event.getClippingHelper().isVisible(entity.getBoundingBoxForCulling().inflate(2));
event.getStack().pushPose();
Vector3d cameraPos = event.getInfo()
.getPosition();
double x = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.xOld, entity.getX()) - cameraPos.x;
double y = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.yOld, entity.getY()) - cameraPos.y;
double z = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.zOld, entity.getZ()) - cameraPos.z;
event.getStack().translate(x, y, z);
matrices = new ContraptionMatrices(event.getStack(), entity);
event.getStack().popPose();
} }
public boolean isVisible() { public boolean isVisible() {
return visible && contraption.entity.isAlive(); return visible && contraption.entity.isAlive();
} }
/**
* Need to call this during RenderLayerEvent.
*/
public void setupMatrices(MatrixStack viewProjection, double camX, double camY, double camZ) {
if (!matrices.isReady()) {
AbstractContraptionEntity entity = contraption.entity;
viewProjection.pushPose();
double x = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.xOld, entity.getX()) - camX;
double y = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.yOld, entity.getY()) - camY;
double z = MathHelper.lerp(AnimationTickHolder.getPartialTicks(), entity.zOld, entity.getZ()) - camZ;
viewProjection.translate(x, y, z);
matrices.setup(viewProjection, entity);
viewProjection.popPose();
}
}
/**
* If #setupMatrices is called correctly, the returned matrices will be ready
*/
public ContraptionMatrices getMatrices() { public ContraptionMatrices getMatrices() {
return matrices; return matrices;
} }

View file

@ -29,7 +29,11 @@ public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo>
this.world = (World) world; this.world = (World) world;
} }
public abstract void renderLayer(RenderLayerEvent event); public void renderLayer(RenderLayerEvent event) {
for (C c : visible) {
c.setupMatrices(event.stack, event.camX, event.camY, event.camZ);
}
}
protected abstract C create(Contraption c); protected abstract C create(Contraption c);
@ -50,13 +54,17 @@ public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo>
} }
public void beginFrame(BeginFrameEvent event) { public void beginFrame(BeginFrameEvent event) {
visible.clear();
renderInfos.int2ObjectEntrySet() renderInfos.int2ObjectEntrySet()
.stream() .stream()
.map(Map.Entry::getValue) .map(Map.Entry::getValue)
.forEach(renderInfo -> renderInfo.beginFrame(event)); .forEach(renderInfo -> renderInfo.beginFrame(event));
collectVisible();
}
protected void collectVisible() {
visible.clear();
renderInfos.int2ObjectEntrySet() renderInfos.int2ObjectEntrySet()
.stream() .stream()
.map(Map.Entry::getValue) .map(Map.Entry::getValue)
@ -80,6 +88,9 @@ public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo>
renderInfos.clear(); renderInfos.clear();
} }
/**
* Remove all render infos associated with dead/removed contraptions.
*/
public void removeDeadRenderers() { public void removeDeadRenderers() {
renderInfos.values().removeIf(ContraptionRenderInfo::isDead); renderInfos.values().removeIf(ContraptionRenderInfo::isDead);
} }

View file

@ -38,6 +38,8 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
@Override @Override
public void renderLayer(RenderLayerEvent event) { public void renderLayer(RenderLayerEvent event) {
super.renderLayer(event);
if (visible.isEmpty()) return; if (visible.isEmpty()) return;
RenderType layer = event.getType(); RenderType layer = event.getType();
@ -80,13 +82,17 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
@Override @Override
public void removeDeadRenderers() { public void removeDeadRenderers() {
renderInfos.values().removeIf(renderer -> { boolean removed = renderInfos.values()
if (renderer.isDead()) { .removeIf(renderer -> {
renderer.invalidate(); if (renderer.isDead()) {
return true; renderer.invalidate();
} return true;
return false; }
}); return false;
});
// we use visible in #tick() so we have to re-evaluate it if any were removed
if (removed) collectVisible();
} }
@Override @Override

View file

@ -15,6 +15,7 @@ import com.jozufozu.flywheel.core.model.IModel;
import com.jozufozu.flywheel.core.model.WorldModel; import com.jozufozu.flywheel.core.model.WorldModel;
import com.jozufozu.flywheel.event.BeginFrameEvent; import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.light.GridAlignedBB; import com.jozufozu.flywheel.light.GridAlignedBB;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
@ -40,7 +41,8 @@ public class RenderedContraption extends ContraptionRenderInfo {
private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>(); private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>();
private Matrix4f model; private final Matrix4f modelViewPartial = new Matrix4f();
private boolean modelViewPartialReady;
private AxisAlignedBB lightBox; private AxisAlignedBB lightBox;
public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) { public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
@ -74,30 +76,32 @@ public class RenderedContraption extends ContraptionRenderInfo {
public void beginFrame(BeginFrameEvent event) { public void beginFrame(BeginFrameEvent event) {
super.beginFrame(event); super.beginFrame(event);
modelViewPartial.setIdentity();
modelViewPartialReady = false;
if (!isVisible()) return; if (!isVisible()) return;
kinetics.beginFrame(event.getInfo()); kinetics.beginFrame(event.getInfo());
AbstractContraptionEntity entity = contraption.entity; Vector3d cameraPos = event.getCameraPos();
float pt = AnimationTickHolder.getPartialTicks();
AxisAlignedBB lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume());
Vector3d cameraPos = event.getInfo() lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume())
.getPosition(); .move(-cameraPos.x, -cameraPos.y, -cameraPos.z);
}
float x = (float) (MathHelper.lerp(pt, entity.xOld, entity.getX()) - cameraPos.x); @Override
float y = (float) (MathHelper.lerp(pt, entity.yOld, entity.getY()) - cameraPos.y); public void setupMatrices(MatrixStack viewProjection, double camX, double camY, double camZ) {
float z = (float) (MathHelper.lerp(pt, entity.zOld, entity.getZ()) - cameraPos.z); super.setupMatrices(viewProjection, camX, camY, camZ);
model = Matrix4f.createTranslateMatrix(x, y, z);
model.multiply(getMatrices().contraptionPose()); if (!modelViewPartialReady) {
setupModelViewPartial(modelViewPartial, getMatrices().getModel().last().pose(), contraption.entity, camX, camY, camZ, AnimationTickHolder.getPartialTicks());
this.lightBox = lightBox.move(-cameraPos.x, -cameraPos.y, -cameraPos.z); modelViewPartialReady = true;
}
} }
void setup(ContraptionProgram shader) { void setup(ContraptionProgram shader) {
if (model == null || lightBox == null) return; if (!modelViewPartialReady || lightBox == null) return;
shader.bind(model, lightBox); shader.bind(modelViewPartial, lightBox);
lighter.lightVolume.bind(); lighter.lightVolume.bind();
} }
@ -125,10 +129,13 @@ public class RenderedContraption extends ContraptionRenderInfo {
for (RenderType layer : blockLayers) { for (RenderType layer : blockLayers) {
Supplier<IModel> layerModel = () -> new WorldModel(renderWorld, layer, contraption.getBlocks().values()); Supplier<IModel> layerModel = () -> new WorldModel(renderWorld, layer, contraption.getBlocks().values());
ModelRenderer renderer;
if (Backend.getInstance().compat.vertexArrayObjectsSupported()) if (Backend.getInstance().compat.vertexArrayObjectsSupported())
renderLayers.put(layer, new ArrayModelRenderer(layerModel)); renderer = new ArrayModelRenderer(layerModel);
else else
renderLayers.put(layer, new ModelRenderer(layerModel)); renderer = new ModelRenderer(layerModel);
renderLayers.put(layer, renderer);
} }
} }
@ -151,4 +158,13 @@ public class RenderedContraption extends ContraptionRenderInfo {
private void buildActors() { private void buildActors() {
contraption.getActors().forEach(kinetics::createActor); contraption.getActors().forEach(kinetics::createActor);
} }
public static void setupModelViewPartial(Matrix4f matrix, Matrix4f modelMatrix, AbstractContraptionEntity entity, double camX, double camY, double camZ, float pt) {
float x = (float) (MathHelper.lerp(pt, entity.xOld, entity.getX()) - camX);
float y = (float) (MathHelper.lerp(pt, entity.yOld, entity.getY()) - camY);
float z = (float) (MathHelper.lerp(pt, entity.zOld, entity.getZ()) - camZ);
matrix.setTranslation(x, y, z);
matrix.multiply(modelMatrix);
}
} }

View file

@ -21,6 +21,7 @@ public class SBBContraptionManager extends ContraptionRenderManager<ContraptionR
@Override @Override
public void renderLayer(RenderLayerEvent event) { public void renderLayer(RenderLayerEvent event) {
super.renderLayer(event);
visible.forEach(info -> renderContraptionLayerSBB(event, info)); visible.forEach(info -> renderContraptionLayerSBB(event, info));
} }
@ -38,12 +39,12 @@ public class SBBContraptionManager extends ContraptionRenderManager<ContraptionR
SuperByteBuffer contraptionBuffer = CreateClient.BUFFER_CACHE.get(CONTRAPTION, Pair.of(renderInfo.contraption, layer), () -> buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer)); SuperByteBuffer contraptionBuffer = CreateClient.BUFFER_CACHE.get(CONTRAPTION, Pair.of(renderInfo.contraption, layer), () -> buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer));
if (!contraptionBuffer.isEmpty()) { if (!contraptionBuffer.isEmpty()) {
ContraptionMatrices matrices = renderInfo.getMatrices(); ContraptionMatrices matrices = renderInfo.getMatrices();
contraptionBuffer.transform(matrices.contraptionStack)
.light(matrices.entityMatrix) contraptionBuffer.transform(matrices.getModel())
.light(matrices.getWorld())
.hybridLight() .hybridLight()
.renderInto(matrices.entityStack, event.buffers.bufferSource() .renderInto(matrices.getViewProjection(), event.buffers.bufferSource()
.getBuffer(layer)); .getBuffer(layer));
} }

View file

@ -87,7 +87,7 @@ public class PipeConnection {
FlowSource flowSource = source.get(); FlowSource flowSource = source.get();
flowSource.manageSource(world); flowSource.manageSource(world);
} }
public boolean manageFlows(World world, BlockPos pos, FluidStack internalFluid, public boolean manageFlows(World world, BlockPos pos, FluidStack internalFluid,
Predicate<FluidStack> extractionPredicate) { Predicate<FluidStack> extractionPredicate) {
@ -193,7 +193,7 @@ public class PipeConnection {
if (world.isClientSide) { if (world.isClientSide) {
if (!source.isPresent()) if (!source.isPresent())
determineSource(world, pos); determineSource(world, pos);
spawnParticles(world, pos, flow.fluid); spawnParticles(world, pos, flow.fluid);
if (particleSplashNextTick) if (particleSplashNextTick)
spawnSplashOnRim(world, pos, flow.fluid); spawnSplashOnRim(world, pos, flow.fluid);
@ -282,8 +282,8 @@ public class PipeConnection {
/** /**
* @return zero if outward == inbound <br> * @return zero if outward == inbound <br>
* positive if outward > inbound <br> * positive if outward {@literal >} inbound <br>
* negative if outward < inbound * negative if outward {@literal <} inbound
*/ */
public float comparePressure() { public float comparePressure() {
return getOutwardPressure() - getInboundPressure(); return getOutwardPressure() - getInboundPressure();

View file

@ -15,7 +15,6 @@ import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -43,9 +42,9 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return; if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState gaugeState = te.getBlockState(); BlockState gaugeState = te.getBlockState();
GaugeTileEntity gaugeTE = (GaugeTileEntity) te; GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
int lightCoords = WorldRenderer.getLightColor(te.getLevel(), gaugeState, te.getBlockPos());
PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS); PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS);
SuperByteBuffer headBuffer = SuperByteBuffer headBuffer =
@ -64,12 +63,11 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot) rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot)
.rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)) .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress))
.translate(0, -dialPivot, -dialPivot) .translate(0, -dialPivot, -dialPivot)
.light(lightCoords) .light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
rotateBufferTowards(headBuffer, facing).light(lightCoords) rotateBufferTowards(headBuffer, facing).light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
} }
} }
@Override @Override

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.curiosities.bell; package com.simibubi.create.content.curiosities.bell;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -11,7 +10,6 @@ import net.minecraft.block.BellBlock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.BellAttachment; import net.minecraft.state.properties.BellAttachment;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -39,9 +37,8 @@ public class BellRenderer<TE extends AbstractBellTileEntity> extends SafeTileEnt
rY += 90; rY += 90;
bell.rotateCentered(Direction.UP, AngleHelper.rad(rY)); bell.rotateCentered(Direction.UP, AngleHelper.rad(rY));
IVertexBuilder vb = buffer.getBuffer(RenderType.cutout()); bell.light(light)
int lightCoords = WorldRenderer.getLightColor(te.getLevel(), state, te.getBlockPos()); .renderInto(ms, buffer.getBuffer(RenderType.cutout()));
bell.light(lightCoords).renderInto(ms, vb);
} }
public static float getSwingAngle(float time) { public static float getSwingAngle(float time) {

View file

@ -77,7 +77,7 @@ public class PotatoCannonProjectileTypes {
.velocity(1.25f) .velocity(1.25f)
.knockback(0.5f) .knockback(0.5f)
.renderTumbling() .renderTumbling()
.onEntityHit(setFire(3)) .preEntityHit(setFire(3))
.registerAndAssign(Items.BAKED_POTATO), .registerAndAssign(Items.BAKED_POTATO),
CARROT = create("carrot").damage(4) CARROT = create("carrot").damage(4)
@ -247,17 +247,21 @@ public class PotatoCannonProjectileTypes {
.velocity(1.1f) .velocity(1.1f)
.renderTumbling() .renderTumbling()
.sticky() .sticky()
.onEntityHit(setFire(12)) .preEntityHit(setFire(12))
.soundPitch(1.0f) .soundPitch(1.0f)
.registerAndAssign(AllItems.BLAZE_CAKE.get()) .registerAndAssign(AllItems.BLAZE_CAKE.get())
; ;
public static void registerType(ResourceLocation resLoc, PotatoCannonProjectileTypes type) { public static void registerType(ResourceLocation resLoc, PotatoCannonProjectileTypes type) {
ALL.put(resLoc, type); synchronized (ALL) {
ALL.put(resLoc, type);
}
} }
public static void assignType(IRegistryDelegate<Item> item, PotatoCannonProjectileTypes type) { public static void assignType(IRegistryDelegate<Item> item, PotatoCannonProjectileTypes type) {
ITEM_MAP.put(item, type); synchronized (ITEM_MAP) {
ITEM_MAP.put(item, type);
}
} }
public static Optional<PotatoCannonProjectileTypes> getProjectileTypeOf(ItemStack item) { public static Optional<PotatoCannonProjectileTypes> getProjectileTypeOf(ItemStack item) {
@ -282,7 +286,8 @@ public class PotatoCannonProjectileTypes {
private float fwoompPitch = 1; private float fwoompPitch = 1;
private boolean sticky = false; private boolean sticky = false;
private PotatoProjectileRenderMode renderMode = new PotatoProjectileRenderMode.Billboard(); private PotatoProjectileRenderMode renderMode = new PotatoProjectileRenderMode.Billboard();
private Predicate<EntityRayTraceResult> onEntityHit = e -> false; private Predicate<EntityRayTraceResult> preEntityHit = e -> false; // True if hit should be canceled
private Predicate<EntityRayTraceResult> onEntityHit = e -> false; // True if shouldn't recover projectile
private BiPredicate<IWorld, BlockRayTraceResult> onBlockHit = (w, ray) -> false; private BiPredicate<IWorld, BlockRayTraceResult> onBlockHit = (w, ray) -> false;
public float getGravityMultiplier() { public float getGravityMultiplier() {
@ -323,6 +328,10 @@ public class PotatoCannonProjectileTypes {
public boolean isSticky() { return sticky; } public boolean isSticky() { return sticky; }
public boolean preEntityHit(EntityRayTraceResult ray) {
return preEntityHit.test(ray);
}
public boolean onEntityHit(EntityRayTraceResult ray) { public boolean onEntityHit(EntityRayTraceResult ray) {
return onEntityHit.test(ray); return onEntityHit.test(ray);
} }
@ -538,6 +547,11 @@ public class PotatoCannonProjectileTypes {
return this; return this;
} }
public Builder preEntityHit(Predicate<EntityRayTraceResult> callback) {
result.preEntityHit = callback;
return this;
}
public Builder onEntityHit(Predicate<EntityRayTraceResult> callback) { public Builder onEntityHit(Predicate<EntityRayTraceResult> callback) {
result.onEntityHit = callback; result.onEntityHit = callback;
return this; return this;

View file

@ -190,6 +190,8 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements
if (target instanceof WitherEntity && ((WitherEntity) target).isPowered()) if (target instanceof WitherEntity && ((WitherEntity) target).isPowered())
return; return;
if (projectileType.preEntityHit(ray))
return;
boolean targetIsEnderman = target.getType() == EntityType.ENDERMAN; boolean targetIsEnderman = target.getType() == EntityType.ENDERMAN;
int k = target.getRemainingFireTicks(); int k = target.getRemainingFireTicks();

View file

@ -13,7 +13,6 @@ import com.simibubi.create.foundation.utility.Color;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.AttachFace; import net.minecraft.state.properties.AttachFace;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -31,7 +30,6 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
if (Backend.getInstance().canUseInstancing(te.getLevel())) return; if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
BlockState leverState = te.getBlockState(); BlockState leverState = te.getBlockState();
int lightCoords = WorldRenderer.getLightColor(te.getLevel(), leverState, te.getBlockPos());
float state = te.clientState.get(partialTicks); float state = te.clientState.get(partialTicks);
IVertexBuilder vb = buffer.getBuffer(RenderType.solid()); IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
@ -42,13 +40,13 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f) transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f)
.rotate(Direction.EAST, angle) .rotate(Direction.EAST, angle)
.translate(-1 / 2f, -1 / 16f, -1 / 2f); .translate(-1 / 2f, -1 / 16f, -1 / 2f);
handle.light(lightCoords) handle.light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
// Indicator // Indicator
int color = Color.mixColors(0x2C0300, 0xCD0000, state / 15f); int color = Color.mixColors(0x2C0300, 0xCD0000, state / 15f);
SuperByteBuffer indicator = transform(PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState); SuperByteBuffer indicator = transform(PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState);
indicator.light(lightCoords) indicator.light(light)
.color(color) .color(color)
.renderInto(ms, vb); .renderInto(ms, vb);
} }

View file

@ -26,12 +26,12 @@ public class LecternControllerRenderer extends SafeTileEntityRenderer<LecternCon
ItemStack stack = AllItems.LINKED_CONTROLLER.asStack(); ItemStack stack = AllItems.LINKED_CONTROLLER.asStack();
TransformType transformType = TransformType.NONE; TransformType transformType = TransformType.NONE;
LinkedControllerModel mainModel = ((LinkedControllerModel) Minecraft.getInstance() LinkedControllerModel mainModel = (LinkedControllerModel) Minecraft.getInstance()
.getItemRenderer() .getItemRenderer()
.getModel(stack, null, null)); .getModel(stack, null, null);
PartialItemModelRenderer renderer = PartialItemModelRenderer.of(stack, transformType, ms, buffer, overlay); PartialItemModelRenderer renderer = PartialItemModelRenderer.of(stack, transformType, ms, buffer, overlay);
boolean active = te.hasUser(); boolean active = te.hasUser();
boolean usedByMe = te.isUsedBy(Minecraft.getInstance().player); boolean renderDepression = te.isUsedBy(Minecraft.getInstance().player);
Direction facing = te.getBlockState().getValue(LecternControllerBlock.FACING); Direction facing = te.getBlockState().getValue(LecternControllerBlock.FACING);
MatrixTransformStack msr = MatrixTransformStack.of(ms); MatrixTransformStack msr = MatrixTransformStack.of(ms);
@ -41,7 +41,7 @@ public class LecternControllerRenderer extends SafeTileEntityRenderer<LecternCon
msr.rotateY(AngleHelper.horizontalAngle(facing) - 90); msr.rotateY(AngleHelper.horizontalAngle(facing) - 90);
msr.translate(0.28, 0, 0); msr.translate(0.28, 0, 0);
msr.rotateZ(-22.0); msr.rotateZ(-22.0);
LinkedControllerItemRenderer.renderLinkedController(stack, mainModel, renderer, transformType, ms, light, active, usedByMe); LinkedControllerItemRenderer.renderInLectern(stack, mainModel, renderer, transformType, ms, light, active, renderDepression);
ms.popPose(); ms.popPose();
} }

View file

@ -35,10 +35,6 @@ import net.minecraft.util.text.TextFormatting;
public class LinkedControllerClientHandler { public class LinkedControllerClientHandler {
enum Mode {
IDLE, ACTIVE, BIND
}
public static Mode MODE = Mode.IDLE; public static Mode MODE = Mode.IDLE;
public static int PACKET_RATE = 5; public static int PACKET_RATE = 5;
public static Collection<Integer> currentlyPressed = new HashSet<>(); public static Collection<Integer> currentlyPressed = new HashSet<>();
@ -112,6 +108,8 @@ public class LinkedControllerClientHandler {
if (!currentlyPressed.isEmpty()) if (!currentlyPressed.isEmpty())
AllPackets.channel.sendToServer(new LinkedControllerInputPacket(currentlyPressed, false)); AllPackets.channel.sendToServer(new LinkedControllerInputPacket(currentlyPressed, false));
currentlyPressed.clear(); currentlyPressed.clear();
LinkedControllerItemRenderer.resetButtons();
} }
protected static boolean isActuallyPressed(KeyBinding kb) { protected static boolean isActuallyPressed(KeyBinding kb) {
@ -124,6 +122,7 @@ public class LinkedControllerClientHandler {
public static void tick() { public static void tick() {
LinkedControllerItemRenderer.tick(); LinkedControllerItemRenderer.tick();
if (MODE == Mode.IDLE) if (MODE == Mode.IDLE)
return; return;
if (packetCooldown > 0) if (packetCooldown > 0)
@ -269,4 +268,8 @@ public class LinkedControllerClientHandler {
} }
public enum Mode {
IDLE, ACTIVE, BIND
}
} }

View file

@ -50,35 +50,56 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere
} }
} }
static void resetButtons() {
for (int i = 0; i < buttons.size(); i++) {
buttons.get(i).startWithValue(0);
}
}
@Override @Override
protected void render(ItemStack stack, LinkedControllerModel model, PartialItemModelRenderer renderer, protected void render(ItemStack stack, LinkedControllerModel model, PartialItemModelRenderer renderer,
ItemCameraTransforms.TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, ItemCameraTransforms.TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light,
int overlay) { int overlay) {
renderNormal(stack, model, renderer, transformType, ms, light);
renderLinkedController(stack, model, renderer, transformType, ms, light, null, null);
} }
public static void renderLinkedController(ItemStack stack, LinkedControllerModel model, protected static void renderNormal(ItemStack stack, LinkedControllerModel model,
PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, MatrixStack ms, PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, MatrixStack ms,
int light, Boolean active, Boolean usedByMe) { int light) {
render(stack, model, renderer, transformType, ms, light, RenderType.NORMAL, false, false);
}
public static void renderInLectern(ItemStack stack, LinkedControllerModel model,
PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, MatrixStack ms,
int light, boolean active, boolean renderDepression) {
render(stack, model, renderer, transformType, ms, light, RenderType.LECTERN, active, renderDepression);
}
protected static void render(ItemStack stack, LinkedControllerModel model,
PartialItemModelRenderer renderer, ItemCameraTransforms.TransformType transformType, MatrixStack ms,
int light, RenderType renderType, boolean active, boolean renderDepression) {
float pt = AnimationTickHolder.getPartialTicks(); float pt = AnimationTickHolder.getPartialTicks();
MatrixTransformStack msr = MatrixTransformStack.of(ms); MatrixTransformStack msr = MatrixTransformStack.of(ms);
ms.pushPose(); ms.pushPose();
Minecraft mc = Minecraft.getInstance(); if (renderType == RenderType.NORMAL) {
boolean rightHanded = mc.options.mainHand == HandSide.RIGHT; Minecraft mc = Minecraft.getInstance();
TransformType mainHand = boolean rightHanded = mc.options.mainHand == HandSide.RIGHT;
rightHanded ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND; TransformType mainHand =
TransformType offHand = rightHanded ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND;
rightHanded ? TransformType.FIRST_PERSON_LEFT_HAND : TransformType.FIRST_PERSON_RIGHT_HAND; TransformType offHand =
rightHanded ? TransformType.FIRST_PERSON_LEFT_HAND : TransformType.FIRST_PERSON_RIGHT_HAND;
if (active == null) {
active = false; active = false;
boolean noControllerInMain = !AllItems.LINKED_CONTROLLER.isIn(mc.player.getMainHandItem()); boolean noControllerInMain = !AllItems.LINKED_CONTROLLER.isIn(mc.player.getMainHandItem());
if (transformType == mainHand || (transformType == offHand && noControllerInMain)) { if (transformType == mainHand || (transformType == offHand && noControllerInMain)) {
float equip = equipProgress.getValue(pt);
int handModifier = transformType == TransformType.FIRST_PERSON_LEFT_HAND ? -1 : 1;
msr.translate(0, equip / 4, equip / 4 * handModifier);
msr.rotateY(equip * -30 * handModifier);
msr.rotateZ(equip * -30);
active = true; active = true;
} }
@ -89,56 +110,62 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere
active = true; active = true;
} }
active &= LinkedControllerClientHandler.MODE != Mode.IDLE && !LinkedControllerClientHandler.inLectern(); active &= LinkedControllerClientHandler.MODE != Mode.IDLE;
usedByMe = active;
if (active && (transformType == mainHand || transformType == offHand)) { renderDepression = true;
float equip = equipProgress.getValue(pt);
int handModifier = transformType == TransformType.FIRST_PERSON_LEFT_HAND ? -1 : 1;
msr.translate(0, equip / 4, equip / 4 * handModifier);
msr.rotateY(equip * -30 * handModifier);
msr.rotateZ(equip * -30);
}
} }
renderer.render(active ? model.getPartial("powered") : model.getOriginalModel(), light); renderer.render(active ? model.getPartial("powered") : model.getOriginalModel(), light);
if (!active) {
ms.popPose();
return;
}
IBakedModel button = model.getPartial("button"); IBakedModel button = model.getPartial("button");
float s = 1 / 16f; float s = 1 / 16f;
float b = s * -.75f; float b = s * -.75f;
int index = 0; int index = 0;
if (LinkedControllerClientHandler.MODE == Mode.BIND) { if (renderType == RenderType.NORMAL) {
int i = (int) MathHelper.lerp((MathHelper.sin(AnimationTickHolder.getRenderTime() / 4f) + 1) / 2, 5, 15); if (LinkedControllerClientHandler.MODE == Mode.BIND) {
light = i << 20; int i = (int) MathHelper.lerp((MathHelper.sin(AnimationTickHolder.getRenderTime() / 4f) + 1) / 2, 5, 15);
light = i << 20;
}
} }
ms.pushPose(); ms.pushPose();
msr.translate(2 * s, 0, 8 * s); msr.translate(2 * s, 0, 8 * s);
button(renderer, ms, light, pt, button, b, index++, usedByMe); renderButton(renderer, ms, light, pt, button, b, index++, renderDepression);
msr.translate(4 * s, 0, 0); msr.translate(4 * s, 0, 0);
button(renderer, ms, light, pt, button, b, index++, usedByMe); renderButton(renderer, ms, light, pt, button, b, index++, renderDepression);
msr.translate(-2 * s, 0, 2 * s); msr.translate(-2 * s, 0, 2 * s);
button(renderer, ms, light, pt, button, b, index++, usedByMe); renderButton(renderer, ms, light, pt, button, b, index++, renderDepression);
msr.translate(0, 0, -4 * s); msr.translate(0, 0, -4 * s);
button(renderer, ms, light, pt, button, b, index++, usedByMe); renderButton(renderer, ms, light, pt, button, b, index++, renderDepression);
ms.popPose(); ms.popPose();
msr.translate(3 * s, 0, 3 * s); msr.translate(3 * s, 0, 3 * s);
button(renderer, ms, light, pt, button, b, index++, usedByMe); renderButton(renderer, ms, light, pt, button, b, index++, renderDepression);
msr.translate(2 * s, 0, 0); msr.translate(2 * s, 0, 0);
button(renderer, ms, light, pt, button, b, index++, usedByMe); renderButton(renderer, ms, light, pt, button, b, index++, renderDepression);
ms.popPose(); ms.popPose();
} }
protected static void button(PartialItemModelRenderer renderer, MatrixStack ms, int light, float pt, IBakedModel button, protected static void renderButton(PartialItemModelRenderer renderer, MatrixStack ms, int light, float pt, IBakedModel button,
float b, int index, boolean usedByMe) { float b, int index, boolean renderDepression) {
ms.pushPose(); ms.pushPose();
float depression = usedByMe ? b * buttons.get(index).getValue(pt) : 0; if (renderDepression) {
ms.translate(0, depression, 0); float depression = b * buttons.get(index).getValue(pt);
ms.translate(0, depression, 0);
}
renderer.renderSolid(button, light); renderer.renderSolid(button, light);
ms.popPose(); ms.popPose();
} }
protected enum RenderType {
NORMAL, LECTERN;
}
} }

View file

@ -220,6 +220,8 @@ public class FilterItem extends Item implements INamedContainerProvider {
for (INBT inbt : attributes) { for (INBT inbt : attributes) {
CompoundNBT compound = (CompoundNBT) inbt; CompoundNBT compound = (CompoundNBT) inbt;
ItemAttribute attribute = ItemAttribute.fromNBT(compound); ItemAttribute attribute = ItemAttribute.fromNBT(compound);
if (attribute == null)
continue;
boolean matches = attribute.appliesTo(stack, world) != compound.getBoolean("Inverted"); boolean matches = attribute.appliesTo(stack, world) != compound.getBoolean("Inverted");
if (matches) { if (matches) {

View file

@ -51,7 +51,14 @@ public class SchematicPrinter {
public void fromTag(CompoundNBT compound, boolean clientPacket) { public void fromTag(CompoundNBT compound, boolean clientPacket) {
if (compound.contains("CurrentPos")) if (compound.contains("CurrentPos"))
currentPos = NBTUtil.readBlockPos(compound.getCompound("CurrentPos")); currentPos = NBTUtil.readBlockPos(compound.getCompound("CurrentPos"));
if (clientPacket) {
schematicLoaded = false;
if (compound.contains("Anchor")) {
schematicAnchor = NBTUtil.readBlockPos(compound.getCompound("Anchor"));
schematicLoaded = true;
}
}
printingEntityIndex = compound.getInt("EntityProgress"); printingEntityIndex = compound.getInt("EntityProgress");
printStage = PrintStage.valueOf(compound.getString("PrintStage")); printStage = PrintStage.valueOf(compound.getString("PrintStage"));
compound.getList("DeferredBlocks", 10).stream() compound.getList("DeferredBlocks", 10).stream()
@ -62,7 +69,9 @@ public class SchematicPrinter {
public void write(CompoundNBT compound) { public void write(CompoundNBT compound) {
if (currentPos != null) if (currentPos != null)
compound.put("CurrentPos", NBTUtil.writeBlockPos(currentPos)); compound.put("CurrentPos", NBTUtil.writeBlockPos(currentPos));
if (schematicAnchor != null)
compound.put("Anchor", NBTUtil.writeBlockPos(schematicAnchor));
compound.putInt("EntityProgress", printingEntityIndex); compound.putInt("EntityProgress", printingEntityIndex);
compound.putString("PrintStage", printStage.name()); compound.putString("PrintStage", printStage.name());
ListNBT tagDeferredBlocks = new ListNBT(); ListNBT tagDeferredBlocks = new ListNBT();
@ -78,15 +87,19 @@ public class SchematicPrinter {
Template activeTemplate = SchematicItem.loadSchematic(blueprint); Template activeTemplate = SchematicItem.loadSchematic(blueprint);
PlacementSettings settings = SchematicItem.getSettings(blueprint, processNBT); PlacementSettings settings = SchematicItem.getSettings(blueprint, processNBT);
schematicAnchor = NBTUtil.readBlockPos(blueprint.getTag().getCompound("Anchor")); schematicAnchor = NBTUtil.readBlockPos(blueprint.getTag()
.getCompound("Anchor"));
blockReader = new SchematicWorld(schematicAnchor, originalWorld); blockReader = new SchematicWorld(schematicAnchor, originalWorld);
activeTemplate.placeInWorldChunk(blockReader, schematicAnchor, settings, blockReader.getRandom()); activeTemplate.placeInWorldChunk(blockReader, schematicAnchor, settings, blockReader.getRandom());
BlockPos extraBounds = Template.calculateRelativePosition(settings, activeTemplate.getSize()
.offset(-1, -1, -1));
blockReader.bounds.expand(new MutableBoundingBox(extraBounds, extraBounds));
StructureTransform transform = new StructureTransform(settings.getRotationPivot(), Direction.Axis.Y, StructureTransform transform = new StructureTransform(settings.getRotationPivot(), Direction.Axis.Y,
settings.getRotation(), settings.getMirror()); settings.getRotation(), settings.getMirror());
for (TileEntity te : blockReader.tileEntities.values()) { for (TileEntity te : blockReader.tileEntities.values())
transform.apply(te); transform.apply(te);
}
printingEntityIndex = -1; printingEntityIndex = -1;
printStage = PrintStage.BLOCKS; printStage = PrintStage.BLOCKS;

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.schematics.packet;
import java.util.function.Supplier; import java.util.function.Supplier;
import com.simibubi.create.content.schematics.SchematicPrinter; import com.simibubi.create.content.schematics.SchematicPrinter;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.networking.SimplePacketBase;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
@ -38,12 +39,20 @@ public class SchematicPlacePacket extends SimplePacketBase {
World world = player.getLevel(); World world = player.getLevel();
SchematicPrinter printer = new SchematicPrinter(); SchematicPrinter printer = new SchematicPrinter();
printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks()); printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks());
if (!printer.isLoaded())
return;
boolean includeAir = AllConfigs.SERVER.schematics.creativePrintIncludesAir.get();
while (printer.advanceCurrentPos()) { while (printer.advanceCurrentPos()) {
if (!printer.shouldPlaceCurrent(world)) if (!printer.shouldPlaceCurrent(world))
continue; continue;
printer.handleCurrentTarget((pos, state, tile) -> { printer.handleCurrentTarget((pos, state, tile) -> {
boolean placingAir = state.getBlock().isAir(state, world, pos);
if (placingAir && !includeAir)
return;
CompoundNBT tileData = tile != null ? tile.save(new CompoundNBT()) : null; CompoundNBT tileData = tile != null ? tile.save(new CompoundNBT()) : null;
BlockHelper.placeSchematicBlock(world, state, pos, null, tileData); BlockHelper.placeSchematicBlock(world, state, pos, null, tileData);
}, (pos, entity) -> { }, (pos, entity) -> {

View file

@ -2,6 +2,7 @@ package com.simibubi.create.foundation.config;
public class CSchematics extends ConfigBase { public class CSchematics extends ConfigBase {
public ConfigBool creativePrintIncludesAir = b(false, "creativePrintIncludesAir", Comments.creativePrintIncludesAir);
public ConfigInt maxSchematics = i(10, 1, "maxSchematics", Comments.maxSchematics); public ConfigInt maxSchematics = i(10, 1, "maxSchematics", Comments.maxSchematics);
public ConfigInt maxTotalSchematicSize = i(256, 16, "maxSchematics", Comments.kb, Comments.maxSize); public ConfigInt maxTotalSchematicSize = i(256, 16, "maxSchematics", Comments.kb, Comments.maxSize);
public ConfigInt maxSchematicPacketSize = public ConfigInt maxSchematicPacketSize =
@ -33,6 +34,8 @@ public class CSchematics extends ConfigBase {
static String skips = "Amount of block positions per tick scanned by a running cannon. Higher => Faster"; static String skips = "Amount of block positions per tick scanned by a running cannon. Higher => Faster";
static String gunpowderWorth = "% of Schematicannon's Fuel filled by 1 Gunpowder."; static String gunpowderWorth = "% of Schematicannon's Fuel filled by 1 Gunpowder.";
static String fuelUsage = "% of Schematicannon's Fuel used for each fired block."; static String fuelUsage = "% of Schematicannon's Fuel used for each fired block.";
static String creativePrintIncludesAir =
"Whether placing a Schematic directly in Creative Mode should replace world blocks with Air";
} }
} }

View file

@ -41,23 +41,32 @@ public class PonderRegistry {
// Map from item ids to all storyboards // Map from item ids to all storyboards
public static final Map<ResourceLocation, List<PonderStoryBoardEntry>> ALL = new HashMap<>(); public static final Map<ResourceLocation, List<PonderStoryBoardEntry>> ALL = new HashMap<>();
private static String currentNamespace; private static final ThreadLocal<String> CURRENT_NAMESPACE = new ThreadLocal<>();
private static String getCurrentNamespace() {
return CURRENT_NAMESPACE.get();
}
private static void setCurrentNamespace(String namespace) {
CURRENT_NAMESPACE.set(namespace);
}
public static void startRegistration(String namespace) { public static void startRegistration(String namespace) {
if (currentNamespace != null) { if (getCurrentNamespace() != null) {
throw new IllegalStateException("Cannot start registration when already started!"); throw new IllegalStateException("Cannot start registration when already started!");
} }
currentNamespace = namespace; setCurrentNamespace(namespace);
} }
public static void endRegistration() { public static void endRegistration() {
if (currentNamespace == null) { if (getCurrentNamespace() == null) {
throw new IllegalStateException("Cannot end registration when not started!"); throw new IllegalStateException("Cannot end registration when not started!");
} }
currentNamespace = null; setCurrentNamespace(null);
} }
private static String getNamespaceOrThrow() { private static String getNamespaceOrThrow() {
String currentNamespace = getCurrentNamespace();
if (currentNamespace == null) { if (currentNamespace == null) {
throw new IllegalStateException("Cannot register storyboard without starting registration!"); throw new IllegalStateException("Cannot register storyboard without starting registration!");
} }
@ -71,8 +80,10 @@ public class PonderRegistry {
PonderSceneBuilder builder = new PonderSceneBuilder(entry); PonderSceneBuilder builder = new PonderSceneBuilder(entry);
if (tags.length > 0) if (tags.length > 0)
builder.highlightTags(tags); builder.highlightTags(tags);
ALL.computeIfAbsent(id, _$ -> new ArrayList<>()) synchronized (ALL) {
.add(entry); ALL.computeIfAbsent(id, _$ -> new ArrayList<>())
.add(entry);
}
return builder; return builder;
} }

View file

@ -165,7 +165,7 @@ public class SceneBuilder {
* Use this in case you are not happy with the scale of the scene relative to * Use this in case you are not happy with the scale of the scene relative to
* the overlay * the overlay
* *
* @param factor >1 will make the scene appear larger, smaller otherwise * @param factor {@literal >}1 will make the scene appear larger, smaller otherwise
*/ */
public void scaleSceneView(float factor) { public void scaleSceneView(float factor) {
scene.scaleFactor = factor; scene.scaleFactor = factor;
@ -175,7 +175,7 @@ public class SceneBuilder {
* Use this in case you are not happy with the vertical alignment of the scene * Use this in case you are not happy with the vertical alignment of the scene
* relative to the overlay * relative to the overlay
* *
* @param yOffset >0 moves the scene up, down otherwise * @param yOffset {@literal >}0 moves the scene up, down otherwise
*/ */
public void setSceneOffsetY(float yOffset) { public void setSceneOffsetY(float yOffset) {
scene.yOffset = yOffset; scene.yOffset = yOffset;

View file

@ -22,11 +22,16 @@ public class PonderChapterRegistry {
} }
public void addStoriesToChapter(@Nonnull PonderChapter chapter, PonderStoryBoardEntry... entries) { public void addStoriesToChapter(@Nonnull PonderChapter chapter, PonderStoryBoardEntry... entries) {
chapters.get(chapter.getId()).getSecond().addAll(Arrays.asList(entries)); List<PonderStoryBoardEntry> entryList = chapters.get(chapter.getId()).getSecond();
synchronized (entryList) {
entryList.addAll(Arrays.asList(entries));
}
} }
PonderChapter addChapter(@Nonnull PonderChapter chapter) { PonderChapter addChapter(@Nonnull PonderChapter chapter) {
chapters.put(chapter.getId(), Pair.of(chapter, new ArrayList<>())); synchronized (chapters) {
chapters.put(chapter.getId(), Pair.of(chapter, new ArrayList<>()));
}
return chapter; return chapter;
} }

View file

@ -445,17 +445,17 @@ public class PonderIndex {
.add(Blocks.HONEY_BLOCK); .add(Blocks.HONEY_BLOCK);
PonderRegistry.TAGS.forTag(PonderTag.CONTRAPTION_ACTOR) PonderRegistry.TAGS.forTag(PonderTag.CONTRAPTION_ACTOR)
.add(AllBlocks.MECHANICAL_HARVESTER) .add(AllBlocks.MECHANICAL_HARVESTER)
.add(AllBlocks.MECHANICAL_PLOUGH) .add(AllBlocks.MECHANICAL_PLOUGH)
.add(AllBlocks.MECHANICAL_DRILL) .add(AllBlocks.MECHANICAL_DRILL)
.add(AllBlocks.MECHANICAL_SAW) .add(AllBlocks.MECHANICAL_SAW)
.add(AllBlocks.DEPLOYER) .add(AllBlocks.DEPLOYER)
.add(AllBlocks.PORTABLE_STORAGE_INTERFACE) .add(AllBlocks.PORTABLE_STORAGE_INTERFACE)
.add(AllBlocks.PORTABLE_FLUID_INTERFACE) .add(AllBlocks.PORTABLE_FLUID_INTERFACE)
.add(AllBlocks.MECHANICAL_BEARING) .add(AllBlocks.MECHANICAL_BEARING)
.add(AllBlocks.ANDESITE_FUNNEL) .add(AllBlocks.ANDESITE_FUNNEL)
.add(AllBlocks.BRASS_FUNNEL) .add(AllBlocks.BRASS_FUNNEL)
.add(AllBlocks.SEATS.get(DyeColor.WHITE)) .add(AllBlocks.SEATS.get(DyeColor.WHITE))
.add(AllBlocks.REDSTONE_CONTACT) .add(AllBlocks.REDSTONE_CONTACT)
.add(Blocks.BELL) .add(Blocks.BELL)
.add(Blocks.DISPENSER) .add(Blocks.DISPENSER)

View file

@ -49,11 +49,15 @@ public class PonderTagRegistry {
} }
public void add(PonderTag tag, ResourceLocation item) { public void add(PonderTag tag, ResourceLocation item) {
tags.put(item, tag); synchronized (tags) {
tags.put(item, tag);
}
} }
public void add(PonderTag tag, PonderChapter chapter) { public void add(PonderTag tag, PonderChapter chapter) {
chapterTags.put(chapter, tag); synchronized (chapterTags) {
chapterTags.put(chapter, tag);
}
} }
public ItemBuilder forItems(ResourceLocation... items) { public ItemBuilder forItems(ResourceLocation... items) {

View file

@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos;
public class SuperByteBufferCache { public class SuperByteBufferCache {
Map<Compartment<?>, Cache<Object, SuperByteBuffer>> cache; private Map<Compartment<?>, Cache<Object, SuperByteBuffer>> cache;
public SuperByteBufferCache() { public SuperByteBufferCache() {
cache = new HashMap<>(); cache = new HashMap<>();
@ -87,14 +87,18 @@ public class SuperByteBufferCache {
} }
public void registerCompartment(Compartment<?> instance) { public void registerCompartment(Compartment<?> instance) {
cache.put(instance, CacheBuilder.newBuilder() synchronized (cache) {
.build()); cache.put(instance, CacheBuilder.newBuilder()
.build());
}
} }
public void registerCompartment(Compartment<?> instance, long ticksUntilExpired) { public void registerCompartment(Compartment<?> instance, long ticksUntilExpired) {
cache.put(instance, CacheBuilder.newBuilder() synchronized (cache) {
.expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS) cache.put(instance, CacheBuilder.newBuilder()
.build()); .expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS)
.build());
}
} }
private SuperByteBuffer standardBlockRender(BlockState renderedState) { private SuperByteBuffer standardBlockRender(BlockState renderedState) {

View file

@ -5,7 +5,7 @@ license="MIT"
[[mods]] [[mods]]
modId="create" modId="create"
version="v0.3.2c for 1.16.5" version="v0.3.2d"
displayName="Create" displayName="Create"
#updateJSONURL="" #updateJSONURL=""
displayURL="https://www.curseforge.com/minecraft/mc-mods/create" displayURL="https://www.curseforge.com/minecraft/mc-mods/create"
@ -32,6 +32,6 @@ Technology that empowers the player.'''
[[dependencies.create]] [[dependencies.create]]
modId="flywheel" modId="flywheel"
mandatory=true mandatory=true
versionRange="[1.16-0.2,1.16-0.3)" versionRange="[1.16-0.2.3,1.16-0.3)"
ordering="AFTER" ordering="AFTER"
side="CLIENT" side="CLIENT"