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

This commit is contained in:
zelophed 2024-07-15 14:45:36 +02:00
commit 398eb64880
21 changed files with 154 additions and 52 deletions

View file

@ -3329,7 +3329,7 @@ c2b075008849e152f20e8da946e89c9722325df6 data/create/loot_tables/blocks/content_
69b4b25d7d271458177fbbaeba2c797daccc38a2 data/create/loot_tables/blocks/contraption_controls.json 69b4b25d7d271458177fbbaeba2c797daccc38a2 data/create/loot_tables/blocks/contraption_controls.json
28856dc862efc6bcc421d035d26386740458f868 data/create/loot_tables/blocks/controller_rail.json 28856dc862efc6bcc421d035d26386740458f868 data/create/loot_tables/blocks/controller_rail.json
2c2785e39e1891dff2c50cba93e814b56d935154 data/create/loot_tables/blocks/controls.json 2c2785e39e1891dff2c50cba93e814b56d935154 data/create/loot_tables/blocks/controls.json
3abf04f6132955275ad490668cd28f481afb4ec2 data/create/loot_tables/blocks/copper_backtank.json 830949a5dc64982392db2c1f651d2a9d0ff659a8 data/create/loot_tables/blocks/copper_backtank.json
6697e619d5c6dcb81aad4f5c88ba319d13665b35 data/create/loot_tables/blocks/copper_bars.json 6697e619d5c6dcb81aad4f5c88ba319d13665b35 data/create/loot_tables/blocks/copper_bars.json
8010db6b2427536c74312c85425b3ba83abc363c data/create/loot_tables/blocks/copper_casing.json 8010db6b2427536c74312c85425b3ba83abc363c data/create/loot_tables/blocks/copper_casing.json
ea5fb942c8dfb792daac538e09d286ac120aa199 data/create/loot_tables/blocks/copper_door.json ea5fb942c8dfb792daac538e09d286ac120aa199 data/create/loot_tables/blocks/copper_door.json
@ -3590,7 +3590,7 @@ afdff197c9d1a6940e988c00435135f9705fd0e5 data/create/loot_tables/blocks/metal_gi
b83a90fbe83906b171fc0de6bdc2d9aa3a8c542e data/create/loot_tables/blocks/millstone.json b83a90fbe83906b171fc0de6bdc2d9aa3a8c542e data/create/loot_tables/blocks/millstone.json
5c1df8443043b3fe3b665dba348e2ff188bcbe31 data/create/loot_tables/blocks/minecart_anchor.json 5c1df8443043b3fe3b665dba348e2ff188bcbe31 data/create/loot_tables/blocks/minecart_anchor.json
1e73d28fdd2e54910074aeadbe5617425a8ae656 data/create/loot_tables/blocks/mysterious_cuckoo_clock.json 1e73d28fdd2e54910074aeadbe5617425a8ae656 data/create/loot_tables/blocks/mysterious_cuckoo_clock.json
a5fa8fdc10efe534e5c7d8bdb687f226b39f63ef data/create/loot_tables/blocks/netherite_backtank.json 9be92bab82bc1e83533f1d4679b09bd0513b07eb data/create/loot_tables/blocks/netherite_backtank.json
2e21a06c0d671e543bffecb0b67d97b51fa83ddc data/create/loot_tables/blocks/nixie_tube.json 2e21a06c0d671e543bffecb0b67d97b51fa83ddc data/create/loot_tables/blocks/nixie_tube.json
f6b4095a518a01081f3663d7268d67063bdb44ee data/create/loot_tables/blocks/nozzle.json f6b4095a518a01081f3663d7268d67063bdb44ee data/create/loot_tables/blocks/nozzle.json
d378be8f13fc7ed625813eae3a50b68e8706a297 data/create/loot_tables/blocks/oak_window.json d378be8f13fc7ed625813eae3a50b68e8706a297 data/create/loot_tables/blocks/oak_window.json
@ -5012,7 +5012,7 @@ e6aa8895186358e9d069f5a99909132be49f3bf1 data/create/recipes/diorite_from_stone_
a90268d38f976327ff5e1b87ff1d72ca2d1ebad6 data/create/recipes/dripstone_block_from_stone_types_dripstone_stonecutting.json a90268d38f976327ff5e1b87ff1d72ca2d1ebad6 data/create/recipes/dripstone_block_from_stone_types_dripstone_stonecutting.json
27d9bf05a610447e90314e658dbbcd191f378fc9 data/create/recipes/dripstone_pillar_from_stone_types_dripstone_stonecutting.json 27d9bf05a610447e90314e658dbbcd191f378fc9 data/create/recipes/dripstone_pillar_from_stone_types_dripstone_stonecutting.json
d81ceba2946286d374801e698a4ca2116395cbad data/create/recipes/emptying/builders_tea.json d81ceba2946286d374801e698a4ca2116395cbad data/create/recipes/emptying/builders_tea.json
318ab703224ff1d6f7200675e1e0a4c138b28456 data/create/recipes/emptying/compat/alexsmobs/lava_bottle.json d62f4682fe6cc61df5a1c0231a2004a4ee78a329 data/create/recipes/emptying/compat/alexsmobs/lava_bottle.json
c26d003e921720308c05ad7b9f3cb57de94a10a8 data/create/recipes/emptying/compat/farmersdelight/milk_bottle.json c26d003e921720308c05ad7b9f3cb57de94a10a8 data/create/recipes/emptying/compat/farmersdelight/milk_bottle.json
60c0edfb5b759e4f13427b631861f503f8552923 data/create/recipes/emptying/compat/neapolitan/milk_bottle.json 60c0edfb5b759e4f13427b631861f503f8552923 data/create/recipes/emptying/compat/neapolitan/milk_bottle.json
20b7c7c62fa2e33199e08188dd8836844a6d9cfd data/create/recipes/emptying/honey_bottle.json 20b7c7c62fa2e33199e08188dd8836844a6d9cfd data/create/recipes/emptying/honey_bottle.json

View file

@ -8,6 +8,17 @@
{ {
"type": "minecraft:item", "type": "minecraft:item",
"functions": [ "functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "FullNBT",
"target": "{}",
"op": "merge"
}
]
},
{ {
"function": "minecraft:copy_name", "function": "minecraft:copy_name",
"source": "block_entity" "source": "block_entity"

View file

@ -8,6 +8,17 @@
{ {
"type": "minecraft:item", "type": "minecraft:item",
"functions": [ "functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "FullNBT",
"target": "{}",
"op": "merge"
}
]
},
{ {
"function": "minecraft:copy_name", "function": "minecraft:copy_name",
"source": "block_entity" "source": "block_entity"

View file

@ -16,7 +16,7 @@
], ],
"conditions": [ "conditions": [
{ {
"modid": "atmospheric", "modid": "alexsmobs",
"type": "forge:mod_loaded" "type": "forge:mod_loaded"
} }
] ]

View file

@ -3,12 +3,14 @@ package com.simibubi.create.content.decoration.encasing;
import java.util.List; import java.util.List;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
@ -31,9 +33,16 @@ public interface EncasableBlock {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
encased.handleEncasing(state, level, pos, heldItem, player, hand, ray); encased.handleEncasing(state, level, pos, heldItem, player, hand, ray);
playEncaseSound(level, pos);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
} }
return InteractionResult.PASS; return InteractionResult.PASS;
} }
default void playEncaseSound(Level level, BlockPos pos) {
BlockState newState = level.getBlockState(pos);
SoundType soundType = newState.getSoundType();
level.playSound(null, pos, soundType.getPlaceSound(), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);
}
} }

View file

@ -10,6 +10,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -33,8 +34,8 @@ public class PlacardRenderer extends SafeBlockEntityRenderer<PlacardBlockEntity>
ItemRenderer itemRenderer = Minecraft.getInstance() ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer(); .getItemRenderer();
boolean blockItem = itemRenderer.getModel(heldItem, null, null, 0) BakedModel bakedModel = itemRenderer.getModel(heldItem, null, null, 0);
.isGui3d(); boolean blockItem = bakedModel.isGui3d();
ms.pushPose(); ms.pushPose();
TransformStack.cast(ms) TransformStack.cast(ms)
@ -46,7 +47,7 @@ public class PlacardRenderer extends SafeBlockEntityRenderer<PlacardBlockEntity>
.translate(0, 0, 4.5 / 16f) .translate(0, 0, 4.5 / 16f)
.scale(blockItem ? .5f : .375f); .scale(blockItem ? .5f : .375f);
itemRenderer.renderStatic(heldItem, TransformType.FIXED, light, overlay, ms, buffer, 0); itemRenderer.render(heldItem, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
ms.popPose(); ms.popPose();
} }

View file

@ -121,6 +121,7 @@ public class BacktankBlock extends HorizontalKineticBlock
be.setEnchantmentTag(stack.getEnchantmentTags()); be.setEnchantmentTag(stack.getEnchantmentTags());
if (stack.hasCustomHoverName()) if (stack.hasCustomHoverName())
be.setCustomName(stack.getHoverName()); be.setCustomName(stack.getHoverName());
be.setFullNbt(stack.getOrCreateTag());
}); });
} }
@ -157,9 +158,10 @@ public class BacktankBlock extends HorizontalKineticBlock
ItemStack stack = new ItemStack(item); ItemStack stack = new ItemStack(item);
Optional<BacktankBlockEntity> blockEntityOptional = getBlockEntityOptional(blockGetter, pos); Optional<BacktankBlockEntity> blockEntityOptional = getBlockEntityOptional(blockGetter, pos);
CompoundTag tag = blockEntityOptional.map(BacktankBlockEntity::getFullNbt).orElse(stack.getOrCreateTag());
int air = blockEntityOptional.map(BacktankBlockEntity::getAirLevel) int air = blockEntityOptional.map(BacktankBlockEntity::getAirLevel)
.orElse(0); .orElse(0);
CompoundTag tag = stack.getOrCreateTag();
tag.putInt("Air", air); tag.putInt("Air", air);
ListTag enchants = blockEntityOptional.map(BacktankBlockEntity::getEnchantmentTag) ListTag enchants = blockEntityOptional.map(BacktankBlockEntity::getEnchantmentTag)
@ -174,6 +176,7 @@ public class BacktankBlock extends HorizontalKineticBlock
.orElse(null); .orElse(null);
if (customName != null) if (customName != null)
stack.setHoverName(customName); stack.setHoverName(customName);
stack.setTag(tag);
return stack; return stack;
} }

View file

@ -37,10 +37,13 @@ public class BacktankBlockEntity extends KineticBlockEntity implements Nameable
private int capacityEnchantLevel; private int capacityEnchantLevel;
private ListTag enchantmentTag; private ListTag enchantmentTag;
private CompoundTag fullNbt;
public BacktankBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) { public BacktankBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state); super(type, pos, state);
defaultName = getDefaultName(state); defaultName = getDefaultName(state);
enchantmentTag = new ListTag(); enchantmentTag = new ListTag();
fullNbt = new CompoundTag();
} }
public static Component getDefaultName(BlockState state) { public static Component getDefaultName(BlockState state) {
@ -118,6 +121,7 @@ public class BacktankBlockEntity extends KineticBlockEntity implements Nameable
if (this.customName != null) if (this.customName != null)
compound.putString("CustomName", Component.Serializer.toJson(this.customName)); compound.putString("CustomName", Component.Serializer.toJson(this.customName));
compound.put("Enchantments", enchantmentTag); compound.put("Enchantments", enchantmentTag);
compound.put("FullNBT", fullNbt);
} }
@Override @Override
@ -128,6 +132,7 @@ public class BacktankBlockEntity extends KineticBlockEntity implements Nameable
airLevel = compound.getInt("Air"); airLevel = compound.getInt("Air");
airLevelTimer = compound.getInt("Timer"); airLevelTimer = compound.getInt("Timer");
enchantmentTag = compound.getList("Enchantments", Tag.TAG_COMPOUND); enchantmentTag = compound.getList("Enchantments", Tag.TAG_COMPOUND);
this.fullNbt = compound.getCompound("FullNBT");
if (compound.contains("CustomName", 8)) if (compound.contains("CustomName", 8))
this.customName = Component.Serializer.fromJson(compound.getString("CustomName")); this.customName = Component.Serializer.fromJson(compound.getString("CustomName"));
if (prev != 0 && prev != airLevel && airLevel == BacktankUtil.maxAir(capacityEnchantLevel) && clientPacket) if (prev != 0 && prev != airLevel && airLevel == BacktankUtil.maxAir(capacityEnchantLevel) && clientPacket)
@ -182,4 +187,14 @@ public class BacktankBlockEntity extends KineticBlockEntity implements Nameable
this.capacityEnchantLevel = capacityEnchantLevel; this.capacityEnchantLevel = capacityEnchantLevel;
} }
public CompoundTag getFullNbt()
{
return fullNbt;
}
public void setFullNbt(CompoundTag fullNbt)
{
this.fullNbt = fullNbt;
}
} }

View file

@ -19,6 +19,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -78,8 +79,8 @@ public class ItemDrainRenderer extends SmartBlockEntityRenderer<ItemDrainBlockEn
.getItemRenderer(); .getItemRenderer();
int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2; int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2;
boolean renderUpright = BeltHelper.isItemUpright(itemStack); boolean renderUpright = BeltHelper.isItemUpright(itemStack);
boolean blockItem = itemRenderer.getModel(itemStack, null, null, 0) BakedModel bakedModel = itemRenderer.getModel(itemStack, null, null, 0);
.isGui3d(); boolean blockItem = bakedModel.isGui3d();
if (renderUpright) if (renderUpright)
ms.translate(0, 3 / 32d, 0); ms.translate(0, 3 / 32d, 0);
@ -117,7 +118,7 @@ public class ItemDrainRenderer extends SmartBlockEntityRenderer<ItemDrainBlockEn
ms.scale(.5f, .5f, .5f); ms.scale(.5f, .5f, .5f);
if (!blockItem && !renderUpright) if (!blockItem && !renderUpright)
msr.rotateX(90); msr.rotateX(90);
itemRenderer.renderStatic(itemStack, TransformType.FIXED, light, overlay, ms, buffer, 0); itemRenderer.render(itemStack, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
ms.popPose(); ms.popPose();
if (!renderUpright) { if (!renderUpright) {

View file

@ -30,6 +30,7 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection; import net.minecraft.core.Direction.AxisDirection;
@ -194,14 +195,12 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
boolean slopeAlongX = beltFacing boolean slopeAlongX = beltFacing
.getAxis() == Axis.X; .getAxis() == Axis.X;
Minecraft mc = Minecraft.getInstance();
ItemRenderer itemRenderer = mc.getItemRenderer();
boolean onContraption = be.getLevel() instanceof WrappedWorld; boolean onContraption = be.getLevel() instanceof WrappedWorld;
for (TransportedItemStack transported : be.getInventory() for (TransportedItemStack transported : be.getInventory()
.getTransportedItems()) { .getTransportedItems()) {
ms.pushPose();
TransformStack.cast(ms)
.nudge(transported.angle);
float offset; float offset;
float sideOffset; float sideOffset;
float verticalMovement; float verticalMovement;
@ -228,6 +227,18 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
.getAxis() == Axis.Z); .getAxis() == Axis.Z);
float slopeAngle = onSlope ? tiltForward ? -45 : 45 : 0; float slopeAngle = onSlope ? tiltForward ? -45 : 45 : 0;
Vec3 itemPos = beltStartOffset.add(
be.getBlockPos().getX(),
be.getBlockPos().getY(),
be.getBlockPos().getZ())
.add(offsetVec);
if (this.shouldCullItem(itemPos)) {
continue;
}
ms.pushPose();
TransformStack.cast(ms).nudge(transported.angle);
ms.translate(offsetVec.x, offsetVec.y, offsetVec.z); ms.translate(offsetVec.x, offsetVec.y, offsetVec.z);
boolean alongX = beltFacing boolean alongX = beltFacing
@ -238,12 +249,15 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
ms.translate(alongX ? sideOffset : 0, 0, alongX ? 0 : sideOffset); ms.translate(alongX ? sideOffset : 0, 0, alongX ? 0 : sideOffset);
int stackLight = onContraption ? light : getPackedLight(be, offset); int stackLight = onContraption ? light : getPackedLight(be, offset);
ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer();
boolean renderUpright = BeltHelper.isItemUpright(transported.stack); boolean renderUpright = BeltHelper.isItemUpright(transported.stack);
boolean blockItem = itemRenderer.getModel(transported.stack, be.getLevel(), null, 0) BakedModel bakedModel = itemRenderer.getModel(transported.stack, be.getLevel(), null, 0);
.isGui3d(); boolean blockItem = bakedModel.isGui3d();
int count = (int) (Mth.log2((int) (transported.stack.getCount()))) / 2;
int count = 0;
if (mc.player.getEyePosition(1.0F).distanceTo(itemPos) < 16)
count = (int) (Mth.log2((int) (transported.stack.getCount()))) / 2;
Random r = new Random(transported.angle); Random r = new Random(transported.angle);
boolean slopeShadowOnly = renderUpright && onSlope; boolean slopeShadowOnly = renderUpright && onSlope;
@ -264,7 +278,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
} }
if (renderUpright) { if (renderUpright) {
Entity renderViewEntity = Minecraft.getInstance().cameraEntity; Entity renderViewEntity = mc.cameraEntity;
if (renderViewEntity != null) { if (renderViewEntity != null) {
Vec3 positionVec = renderViewEntity.position(); Vec3 positionVec = renderViewEntity.position();
Vec3 vectorForOffset = BeltHelper.getVectorForOffset(be, offset); Vec3 vectorForOffset = BeltHelper.getVectorForOffset(be, offset);
@ -289,7 +303,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
} }
ms.scale(.5f, .5f, .5f); ms.scale(.5f, .5f, .5f);
itemRenderer.renderStatic(null, transported.stack, TransformType.FIXED, false, ms, buffer, be.getLevel(), stackLight, overlay, 0); itemRenderer.render(transported.stack, TransformType.FIXED, false, ms, buffer, stackLight, overlay, bakedModel);
ms.popPose(); ms.popPose();
if (!renderUpright) { if (!renderUpright) {

View file

@ -378,6 +378,8 @@ public class BeltInventory {
float min = offset; float min = offset;
float max = offset + 1; float max = offset + 1;
for (TransportedItemStack stack : items) { for (TransportedItemStack stack : items) {
if (toRemove.contains(stack))
continue;
if (stack.beltPosition > max) if (stack.beltPosition > max)
continue; continue;
if (stack.beltPosition > min) if (stack.beltPosition > min)

View file

@ -50,13 +50,15 @@ public class ItemHandlerBeltSegment implements IItemHandler {
return ItemStack.EMPTY; return ItemStack.EMPTY;
amount = Math.min(amount, transported.stack.getCount()); amount = Math.min(amount, transported.stack.getCount());
ItemStack extracted = simulate ? transported.stack.copy().split(amount) : transported.stack.split(amount); ItemStack extracted = simulate ? transported.stack.copy()
.split(amount) : transported.stack.split(amount);
if (!simulate) { if (!simulate) {
if (transported.stack.isEmpty()) if (transported.stack.isEmpty())
this.beltInventory.toRemove.add(transported); beltInventory.toRemove.add(transported);
this.beltInventory.belt.setChanged(); else
this.beltInventory.belt.sendData(); beltInventory.belt.notifyUpdate();
} }
return extracted; return extracted;
} }

View file

@ -34,6 +34,7 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -89,9 +90,8 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
.getItemRenderer(); .getItemRenderer();
TransformType transform = TransformType.NONE; TransformType transform = TransformType.NONE;
boolean isBlockItem = (be.heldItem.getItem() instanceof BlockItem) BakedModel bakedModel = itemRenderer.getModel(be.heldItem, be.getLevel(), null, 0);
&& itemRenderer.getModel(be.heldItem, be.getLevel(), null, 0) boolean isBlockItem = (be.heldItem.getItem() instanceof BlockItem) && bakedModel.isGui3d();
.isGui3d();
if (displayMode) { if (displayMode) {
float scale = isBlockItem ? 1.25f : 1; float scale = isBlockItem ? 1.25f : 1;
@ -106,7 +106,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
transform = punching ? TransformType.THIRD_PERSON_RIGHT_HAND : TransformType.FIXED; transform = punching ? TransformType.THIRD_PERSON_RIGHT_HAND : TransformType.FIXED;
} }
itemRenderer.renderStatic(be.heldItem, transform, light, overlay, ms, buffer, 0); itemRenderer.render(be.heldItem, transform, false, ms, buffer, light, overlay, bakedModel);
ms.popPose(); ms.popPose();
} }

View file

@ -19,6 +19,7 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -45,9 +46,8 @@ public class ArmRenderer extends KineticBlockEntityRenderer<ArmBlockEntity> {
ItemRenderer itemRenderer = Minecraft.getInstance() ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer(); .getItemRenderer();
boolean isBlockItem = BakedModel bakedModel = itemRenderer.getModel(item, be.getLevel(), null, 0);
hasItem && (item.getItem() instanceof BlockItem) && itemRenderer.getModel(item, be.getLevel(), null, 0) boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) && bakedModel.isGui3d();
.isGui3d();
VertexConsumer builder = buffer.getBuffer(be.goggles ? RenderType.cutout() : RenderType.solid()); VertexConsumer builder = buffer.getBuffer(be.goggles ? RenderType.cutout() : RenderType.solid());
BlockState blockState = be.getBlockState(); BlockState blockState = be.getBlockState();
@ -102,7 +102,7 @@ public class ArmRenderer extends KineticBlockEntityRenderer<ArmBlockEntity> {
.multiply(msLocal.last() .multiply(msLocal.last()
.pose()); .pose());
itemRenderer.renderStatic(item, TransformType.FIXED, light, overlay, ms, buffer, 0); itemRenderer.render(item, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
ms.popPose(); ms.popPose();
} }

View file

@ -134,7 +134,7 @@ public class SawRenderer extends SafeBlockEntityRenderer<SawBlockEntity> {
if (alongZ) if (alongZ)
ms.mulPose(Vector3f.YP.rotationDegrees(90)); ms.mulPose(Vector3f.YP.rotationDegrees(90));
ms.mulPose(Vector3f.XP.rotationDegrees(90)); ms.mulPose(Vector3f.XP.rotationDegrees(90));
itemRenderer.renderStatic(stack, ItemTransforms.TransformType.FIXED, light, overlay, ms, buffer, 0); itemRenderer.render(stack, ItemTransforms.TransformType.FIXED, false, ms, buffer, light, overlay, modelWithOverrides);
break; break;
} }

View file

@ -16,6 +16,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -104,8 +105,8 @@ public class DepotRenderer extends SafeBlockEntityRenderer<DepotBlockEntity> {
TransformStack msr = TransformStack.cast(ms); TransformStack msr = TransformStack.cast(ms);
int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2; int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2;
boolean renderUpright = BeltHelper.isItemUpright(itemStack); boolean renderUpright = BeltHelper.isItemUpright(itemStack);
boolean blockItem = itemRenderer.getModel(itemStack, null, null, 0) BakedModel bakedModel = itemRenderer.getModel(itemStack, null, null, 0);
.isGui3d(); boolean blockItem = bakedModel.isGui3d();
ms.pushPose(); ms.pushPose();
msr.rotateY(angle); msr.rotateY(angle);
@ -131,7 +132,7 @@ public class DepotRenderer extends SafeBlockEntityRenderer<DepotBlockEntity> {
ms.translate(0, -3 / 16f, 0); ms.translate(0, -3 / 16f, 0);
msr.rotateX(90); msr.rotateX(90);
} }
itemRenderer.renderStatic(itemStack, TransformType.FIXED, light, overlay, ms, buffer, 0); itemRenderer.render(itemStack, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
ms.popPose(); ms.popPose();
if (!renderUpright) { if (!renderUpright) {

View file

@ -2,10 +2,14 @@ package com.simibubi.create.foundation.blockEntity.renderer;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
public abstract class SafeBlockEntityRenderer<T extends BlockEntity> implements BlockEntityRenderer<T> { public abstract class SafeBlockEntityRenderer<T extends BlockEntity> implements BlockEntityRenderer<T> {
@Override @Override
@ -23,4 +27,21 @@ public abstract class SafeBlockEntityRenderer<T extends BlockEntity> implements
return !be.hasLevel() || be.getBlockState() return !be.hasLevel() || be.getBlockState()
.getBlock() == Blocks.AIR; .getBlock() == Blocks.AIR;
} }
public boolean shouldCullItem(Vec3 itemPos) {
Frustum frustum = Minecraft.getInstance().levelRenderer.capturedFrustum != null ?
Minecraft.getInstance().levelRenderer.capturedFrustum :
Minecraft.getInstance().levelRenderer.cullingFrustum;
AABB itemBB = new AABB(
itemPos.x - 0.25,
itemPos.y - 0.25,
itemPos.z - 0.25,
itemPos.x + 0.25,
itemPos.y + 0.25,
itemPos.z + 0.25
);
return !frustum.isVisible(itemBB);
}
} }

View file

@ -435,6 +435,8 @@ public class BuilderTransformers {
.when(survivesExplosion) .when(survivesExplosion)
.setRolls(ConstantValue.exactly(1)) .setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(drop.get()) .add(LootItem.lootTableItem(drop.get())
.apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY)
.copy("FullNBT", "{}", CopyNbtFunction.MergeStrategy.MERGE))
.apply(CopyNameFunction.copyName(CopyNameFunction.NameSource.BLOCK_ENTITY)) .apply(CopyNameFunction.copyName(CopyNameFunction.NameSource.BLOCK_ENTITY))
.apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY) .apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY)
.copy("Air", "Air")) .copy("Air", "Air"))

View file

@ -50,6 +50,14 @@ public class FluidHelper {
return convertToStill(fluid) == Fluids.LAVA; return convertToStill(fluid) == Fluids.LAVA;
} }
public static boolean isSame(FluidStack fluidStack, FluidStack fluidStack2) {
return fluidStack.getFluid() == fluidStack2.getFluid();
}
public static boolean isSame(FluidStack fluidStack, Fluid fluid) {
return fluidStack.getFluid() == fluid;
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static boolean isTag(Fluid fluid, TagKey<Fluid> tag) { public static boolean isTag(Fluid fluid, TagKey<Fluid> tag) {
return fluid.is(tag); return fluid.is(tag);

View file

@ -152,7 +152,7 @@ public abstract class FluidIngredient implements Predicate<FluidStack> {
@Override @Override
protected boolean testInternal(FluidStack t) { protected boolean testInternal(FluidStack t) {
if (t.getFluid() != fluid) if (!FluidHelper.isSame(t, fluid))
return false; return false;
if (tagToMatch.isEmpty()) if (tagToMatch.isEmpty())
return true; return true;
@ -200,17 +200,15 @@ public abstract class FluidIngredient implements Predicate<FluidStack> {
protected TagKey<Fluid> tag; protected TagKey<Fluid> tag;
@SuppressWarnings("deprecation")
@Override @Override
protected boolean testInternal(FluidStack t) { protected boolean testInternal(FluidStack t) {
if (tag == null) { if (tag != null)
return FluidHelper.isTag(t, tag);
for (FluidStack accepted : getMatchingFluidStacks()) for (FluidStack accepted : getMatchingFluidStacks())
if (accepted.getFluid() != t.getFluid()) if (FluidHelper.isSame(accepted, t))
return true; return true;
return false; return false;
} }
return t.getFluid().is(tag);
}
@Override @Override
protected void readInternal(FriendlyByteBuf buffer) { protected void readInternal(FriendlyByteBuf buffer) {

View file

@ -42,3 +42,6 @@ public net.minecraft.client.model.AgeableListModel f_102012_ # bodyYOffset
public net.minecraft.client.gui.components.CommandSuggestions f_93866_ # suggestions public net.minecraft.client.gui.components.CommandSuggestions f_93866_ # suggestions
public net.minecraft.client.gui.components.CommandSuggestions$SuggestionsList <init>(Lnet/minecraft/client/gui/components/CommandSuggestions;IIILjava/util/List;Z)V # <init> public net.minecraft.client.gui.components.CommandSuggestions$SuggestionsList <init>(Lnet/minecraft/client/gui/components/CommandSuggestions;IIILjava/util/List;Z)V # <init>
public net.minecraft.client.renderer.LevelRenderer f_172938_ # cullingFrustum
public net.minecraft.client.renderer.LevelRenderer f_109442_ # capturedFrustum