Merge branch 'mc1.18/dev' into mc1.19/dev

This commit is contained in:
simibubi 2024-10-09 12:00:03 +02:00
commit 285a25cf08
27 changed files with 140 additions and 77 deletions

View file

@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
# mod version info
mod_version = 0.5.1.h
mod_version = 0.5.1.i
artifact_minecraft_version = 1.19.2
minecraft_version = 1.19.2

View file

@ -1,7 +1,13 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"create:blasting/ingot_aluminium_compat_ic2"
]
},
"criteria": {
"has_item": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
@ -10,14 +16,13 @@
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "create:blasting/ingot_aluminum_compat_ic2"
},
"trigger": "minecraft:recipe_unlocked"
"recipe": "create:blasting/ingot_aluminium_compat_ic2"
}
}
},
"requirements": [
@ -25,10 +30,5 @@
"has_item",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"create:blasting/ingot_aluminum_compat_ic2"
]
}
]
}

View file

@ -1,7 +1,13 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"create:smelting/ingot_aluminium_compat_ic2"
]
},
"criteria": {
"has_item": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
@ -10,14 +16,13 @@
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "create:smelting/ingot_aluminum_compat_ic2"
},
"trigger": "minecraft:recipe_unlocked"
"recipe": "create:smelting/ingot_aluminium_compat_ic2"
}
}
},
"requirements": [
@ -25,10 +30,5 @@
"has_item",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"create:smelting/ingot_aluminum_compat_ic2"
]
}
]
}

View file

@ -1,15 +1,15 @@
{
"type": "minecraft:blasting",
"conditions": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
}
],
"cookingtime": 100,
"experience": 0.1,
"ingredient": {
"item": "create:crushed_raw_aluminum"
},
"result": "ic2:ingot_aluminum"
"result": "ic2:ingot_aluminium",
"experience": 0.1,
"cookingtime": 100,
"conditions": [
{
"modid": "ic2",
"type": "forge:mod_loaded"
}
]
}

View file

@ -1,15 +1,15 @@
{
"type": "minecraft:smelting",
"conditions": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
}
],
"cookingtime": 200,
"experience": 0.1,
"ingredient": {
"item": "create:crushed_raw_aluminum"
},
"result": "ic2:ingot_aluminum"
"result": "ic2:ingot_aluminium",
"experience": 0.1,
"cookingtime": 200,
"conditions": [
{
"modid": "ic2",
"type": "forge:mod_loaded"
}
]
}

View file

@ -1,11 +1,5 @@
{
"type": "create:splashing",
"conditions": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
}
],
"ingredients": [
{
"item": "create:crushed_raw_aluminum"
@ -13,8 +7,14 @@
],
"results": [
{
"count": 9,
"item": "ic2:nugget_aluminum"
"item": "ic2:nugget_aluminium",
"count": 9
}
],
"conditions": [
{
"modid": "ic2",
"type": "forge:mod_loaded"
}
]
}

View file

@ -60,7 +60,7 @@ public class Create {
public static final String ID = "create";
public static final String NAME = "Create";
public static final String VERSION = "0.5.1h";
public static final String VERSION = "0.5.1i";
public static final Logger LOGGER = LogUtils.getLogger();

View file

@ -1395,6 +1395,9 @@ public abstract class Contraption {
private void gatherBBsOffThread() {
getContraptionWorld();
if (simplifiedEntityColliderProvider != null) {
simplifiedEntityColliderProvider.cancel(false);
}
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
VoxelShape combinedShape = Shapes.empty();
for (Entry<BlockPos, StructureBlockInfo> entry : blocks.entrySet()) {
@ -1411,7 +1414,6 @@ public abstract class Contraption {
})
.thenAccept(r -> {
simplifiedEntityColliders = Optional.of(r);
simplifiedEntityColliderProvider = null;
});
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.content.equipment.toolbox.ToolboxInventory;
import com.simibubi.create.content.kinetics.crafter.MechanicalCrafterBlockEntity;
import com.simibubi.create.content.logistics.crate.BottomlessItemHandler;
import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity;
@ -177,6 +178,8 @@ public class MountedStorage {
CompoundTag tag = handler.serializeNBT();
if (noFuel)
NBTHelper.putMarker(tag, "NoFuel");
if (handler instanceof ToolboxInventory)
NBTHelper.putMarker(tag, "Toolbox");
if (!(handler instanceof BottomlessItemHandler))
return tag;
@ -191,6 +194,9 @@ public class MountedStorage {
storage.handler = new ItemStackHandler();
if (nbt == null)
return storage;
if (nbt.contains("Toolbox"))
storage.handler = new ToolboxInventory(null);
storage.valid = true;
storage.noFuel = nbt.contains("NoFuel");

View file

@ -68,6 +68,8 @@ public class ClipboardBlockEntity extends SmartBlockEntity {
protected void read(CompoundTag tag, boolean clientPacket) {
super.read(tag, clientPacket);
dataContainer = ItemStack.of(tag.getCompound("Item"));
if (!AllBlocks.CLIPBOARD.isIn(dataContainer))
dataContainer = AllBlocks.CLIPBOARD.asStack();
if (clientPacket)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> readClientSide(tag));

View file

@ -83,7 +83,7 @@ public class ToolboxInventory extends ItemStackHandler {
}
}
settling = false;
blockEntity.sendData();
notifyUpdate();
}
@Override
@ -109,7 +109,7 @@ public class ToolboxInventory extends ItemStackHandler {
if (!stack.isEmpty() && filters.get(compartment)
.isEmpty()) {
filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1));
blockEntity.sendData();
notifyUpdate();
}
}
@ -121,7 +121,7 @@ public class ToolboxInventory extends ItemStackHandler {
if (!stack.isEmpty() && filters.get(compartment)
.isEmpty()) {
filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1));
blockEntity.sendData();
notifyUpdate();
}
}
return insertItem;
@ -136,10 +136,9 @@ public class ToolboxInventory extends ItemStackHandler {
@Override
protected void onContentsChanged(int slot) {
if (!settling && !blockEntity.getLevel().isClientSide)
if (!settling && (blockEntity == null || !blockEntity.getLevel().isClientSide))
settle(slot / STACKS_PER_COMPARTMENT);
blockEntity.sendData();
blockEntity.setChanged();
notifyUpdate();
super.onContentsChanged(slot);
}
@ -208,4 +207,9 @@ public class ToolboxInventory extends ItemStackHandler {
return ItemHandlerHelper.canItemStacksStack(stack1, stack2);
}
private void notifyUpdate() {
if (blockEntity != null)
blockEntity.notifyUpdate();
}
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.fluids.drain;
import com.simibubi.create.content.fluids.transfer.GenericItemEmptying;
import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.item.ItemHelper;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
@ -38,7 +39,8 @@ public class ItemDrainItemHandler implements IItemHandler {
if (stack.getCount() > 1 && GenericItemEmptying.canItemBeEmptied(blockEntity.getLevel(), stack)) {
returned = ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1);
stack = ItemHandlerHelper.copyStackWithSize(stack, 1);
}
} else
returned = ItemHelper.limitCountToMaxStackSize(stack, simulate);
if (!simulate) {
TransportedItemStack heldItem = new TransportedItemStack(stack);

View file

@ -218,6 +218,8 @@ public class BeltBlock extends HorizontalKineticBlock
.copy(), false);
if (remainder.isEmpty())
itemEntity.discard();
else if (remainder.getCount() != itemEntity.getItem().getCount())
itemEntity.setItem(remainder);
});
return;
}

View file

@ -233,7 +233,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
be.getBlockPos().getZ())
.add(offsetVec);
if (this.shouldCullItem(itemPos)) {
if (this.shouldCullItem(itemPos, be.getLevel())) {
continue;
}

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.kinetics.belt.transport;
import com.simibubi.create.foundation.item.ItemHelper;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
@ -29,6 +31,7 @@ public class ItemHandlerBeltSegment implements IItemHandler {
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
if (this.beltInventory.canInsertAt(offset)) {
ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate);
if (!simulate) {
TransportedItemStack newStack = new TransportedItemStack(stack);
newStack.insertedAt = offset;
@ -38,7 +41,7 @@ public class ItemHandlerBeltSegment implements IItemHandler {
this.beltInventory.belt.setChanged();
this.beltInventory.belt.sendData();
}
return ItemStack.EMPTY;
return remainder;
}
return stack;
}

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.kinetics.deployer;
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.item.ItemHelper;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
@ -52,9 +53,10 @@ public class DeployerItemHandler implements IItemHandlerModifiable {
ItemStack held = getHeld();
if (held.isEmpty()) {
ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate);
if (!simulate)
set(stack);
return ItemStack.EMPTY;
return remainder;
}
if (!ItemHandlerHelper.canItemStacksStack(held, stack))

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.logistics.chute;
import com.simibubi.create.foundation.item.ItemHelper;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
@ -25,9 +27,10 @@ public class ChuteItemHandler implements IItemHandler {
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
if (!blockEntity.canAcceptItem(stack))
return stack;
ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate);
if (!simulate)
blockEntity.setItem(stack);
return ItemStack.EMPTY;
return remainder;
}
@Override

View file

@ -93,7 +93,7 @@ public abstract class FunnelBlock extends AbstractDirectionalFunnelBlock {
withBlockEntityDo(worldIn, pos, be -> {
ItemStack toInsert = heldItem.copy();
ItemStack remainder = tryInsert(worldIn, pos, toInsert, false);
if (!ItemStack.matches(remainder, toInsert))
if (!ItemStack.matches(remainder, toInsert) || remainder.getCount() != heldItem.getCount())
player.setItemInHand(handIn, remainder);
});
return InteractionResult.SUCCESS;

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.logistics.tunnel;
import com.simibubi.create.foundation.item.ItemHelper;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
@ -33,9 +35,11 @@ public class BrassTunnelItemHandler implements IItemHandler {
if (!blockEntity.canTakeItems())
return stack;
ItemStack remainder = ItemHelper.limitCountToMaxStackSize(stack, simulate);
if (!simulate)
blockEntity.setStackToDistribute(stack, null);
return ItemStack.EMPTY;
return remainder;
}
@Override

View file

@ -412,7 +412,8 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
if (filter != null && !filter.test(itemStack))
continue;
visualizedOutputItems.add(IntAttached.withZero(itemStack));
if (visualizedOutputItems.size() < 3)
visualizedOutputItems.add(IntAttached.withZero(itemStack));
update = true;
remainder = ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false);
@ -446,7 +447,8 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
update = true;
iterator.remove();
visualizedOutputFluids.add(IntAttached.withZero(fluidStack));
if (visualizedOutputFluids.size() < 3)
visualizedOutputFluids.add(IntAttached.withZero(fluidStack));
}
}

View file

@ -2,10 +2,13 @@ package com.simibubi.create.foundation.blockEntity.renderer;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.ponder.PonderWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB;
@ -28,7 +31,10 @@ public abstract class SafeBlockEntityRenderer<T extends BlockEntity> implements
.getBlock() == Blocks.AIR;
}
public boolean shouldCullItem(Vec3 itemPos) {
public boolean shouldCullItem(Vec3 itemPos, Level level) {
if (level instanceof PonderWorld)
return false;
Frustum frustum = Minecraft.getInstance().levelRenderer.capturedFrustum != null ?
Minecraft.getInstance().levelRenderer.capturedFrustum :
Minecraft.getInstance().levelRenderer.cullingFrustum;

View file

@ -32,6 +32,12 @@ public enum CompatMetals {
public String getName() {
return name;
}
public String getName(Mods mod) {
if (this == ALUMINUM && mod == IC2) // include in mods.builder if this happens again
return "aluminium";
return name;
}
/**
* These mods must provide an ingot and nugget variant of the corresponding metal.

View file

@ -1223,8 +1223,8 @@ public class StandardRecipeGen extends CreateRecipeProvider {
}
GeneratedRecipe blastModdedCrushedMetal(ItemEntry<? extends Item> ingredient, CompatMetals metal) {
String metalName = metal.getName();
for (Mods mod : metal.getMods()) {
String metalName = metal.getName(mod);
ResourceLocation ingot = mod.ingotOf(metalName);
String modId = mod.getId();
create(ingot).withSuffix("_compat_" + modId)

View file

@ -133,8 +133,8 @@ public class WashingRecipeGen extends ProcessingRecipeGen {
}
public GeneratedRecipe moddedCrushedOre(ItemEntry<? extends Item> crushed, CompatMetals metal) {
String metalName = metal.getName();
for (Mods mod : metal.getMods()) {
String metalName = metal.getName(mod);
ResourceLocation nugget = mod.nuggetOf(metalName);
create(mod.getId() + "/" + crushed.getId()
.getPath(),

View file

@ -276,4 +276,16 @@ public class ItemHelper {
}
return -1;
}
public static ItemStack limitCountToMaxStackSize(ItemStack stack, boolean simulate) {
int count = stack.getCount();
int max = stack.getMaxStackSize();
if (count <= max)
return ItemStack.EMPTY;
ItemStack remainder = ItemHandlerHelper.copyStackWithSize(stack, count - max);
if (!simulate)
stack.setCount(max);
return remainder;
}
}

View file

@ -9,7 +9,6 @@ import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
@ -22,7 +21,7 @@ public class BlockItemMixin {
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void create$fixDeployerPlacement(BlockPlaceContext pContext, CallbackInfoReturnable<InteractionResult> cir) {
BlockState state = pContext.getLevel().getBlockState(((UseOnContextAccessor) pContext).create$getHitResult().getBlockPos());
if (state != Blocks.AIR.defaultBlockState() && pContext.getPlayer() instanceof DeployerFakePlayer) {
if (!state.getMaterial().isReplaceable() && pContext.getPlayer() instanceof DeployerFakePlayer) {
cir.setReturnValue(InteractionResult.PASS);
}
}

View file

@ -58,7 +58,7 @@ public final class NBTProcessors {
addProcessor(AllBlockEntityTypes.CREATIVE_CRATE.get(), itemProcessor("Filter"));
addProcessor(AllBlockEntityTypes.PLACARD.get(), itemProcessor("Item"));
}
// Triggered by block tag, not BE type
private static final UnaryOperator<CompoundTag> signProcessor = data -> {
for (int i = 0; i < 4; ++i)
@ -86,14 +86,22 @@ public final class NBTProcessors {
}
public static ItemStack withUnsafeNBTDiscarded(ItemStack stack) {
if (stack.getTag() == null)
CompoundTag tag = stack.getTag();
if (tag == null)
return stack;
ItemStack copy = stack.copy();
stack.getTag()
.getAllKeys()
copy.setTag(withUnsafeNBTDiscarded(tag));
return copy;
}
public static CompoundTag withUnsafeNBTDiscarded(CompoundTag tag) {
if (tag == null)
return null;
CompoundTag copy = tag.copy();
tag.getAllKeys()
.stream()
.filter(NBTProcessors::isUnsafeItemNBTKey)
.forEach(copy::removeTagKey);
.forEach(copy::remove);
return copy;
}
@ -136,7 +144,7 @@ public final class NBTProcessors {
return signProcessor.apply(compound);
if (blockEntity.onlyOpCanSetNbt())
return null;
return compound;
return withUnsafeNBTDiscarded(compound);
}
}