assorted trivial stuff

This commit is contained in:
TropheusJ 2023-06-28 04:28:19 -04:00
parent 55562e5d16
commit 559460e514
26 changed files with 82 additions and 88 deletions

View file

@ -709,9 +709,9 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
@Override
protected void outOfWorld() {
protected void onBelowWorld() {
ejectPassengers();
super.outOfWorld();
super.onBelowWorld();
}
@Override

View file

@ -18,7 +18,6 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.network.PacketDistributor;

View file

@ -47,7 +47,7 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe<SandPaperInv> {
List<Recipe<SandPaperInv>> matchingRecipes = getMatchingRecipes(world, stack);
if (!matchingRecipes.isEmpty())
return matchingRecipes.get(0)
.assemble(new SandPaperInv(stack))
.assemble(new SandPaperInv(stack), world.registryAccess())
.copy();
return stack;
}

View file

@ -38,7 +38,6 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraftforge.api.distmarker.Dist;
@ -271,10 +270,7 @@ public class SymmetryWandItem extends Item {
private static boolean isHoldingBlock(Player player, BlockState block) {
ItemStack itemBlock = BlockHelper.getRequiredItem(block);
return player.getMainHandItem()
.sameItem(itemBlock)
|| player.getOffhandItem()
.sameItem(itemBlock);
return player.isHolding(itemBlock.getItem());
}
public static void remove(Level world, ItemStack wand, Player player, BlockPos pos) {

View file

@ -21,6 +21,7 @@ import com.simibubi.create.infrastructure.config.AllConfigs;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
@ -144,15 +145,16 @@ public class RecipeGridHandler {
items.calcStats();
CraftingContainer craftinginventory = new MechanicalCraftingInventory(items);
ItemStack result = null;
RegistryAccess registryAccess = world.registryAccess();
if (AllConfigs.server().recipes.allowRegularCraftingInCrafter.get())
result = world.getRecipeManager()
.getRecipeFor(RecipeType.CRAFTING, craftinginventory, world)
.filter(r -> isRecipeAllowed(r, craftinginventory))
.map(r -> r.assemble(craftinginventory))
.map(r -> r.assemble(craftinginventory, registryAccess))
.orElse(null);
if (result == null)
result = AllRecipeTypes.MECHANICAL_CRAFTING.find(craftinginventory, world)
.map(r -> r.assemble(craftinginventory))
.map(r -> r.assemble(craftinginventory, registryAccess))
.orElse(null);
return result;
}

View file

@ -21,6 +21,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.infrastructure.config.AllConfigs;
import net.minecraft.core.BlockPos;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.particles.DustParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
@ -177,10 +178,11 @@ public class FanProcessing {
}
if (smeltingRecipe.isPresent()) {
if (!smokingRecipe.isPresent() || !ItemStack.isSame(smokingRecipe.get()
.getResultItem(),
RegistryAccess registryAccess = world.registryAccess();
if (smokingRecipe.isEmpty() || !ItemStack.isSameItem(smokingRecipe.get()
.getResultItem(registryAccess),
smeltingRecipe.get()
.getResultItem())) {
.getResultItem(registryAccess))) {
return RecipeApplier.applyRecipeOn(stack, smeltingRecipe.get());
}
}
@ -239,7 +241,7 @@ public class FanProcessing {
if (entity instanceof EnderMan || entity.getType() == EntityType.SNOW_GOLEM
|| entity.getType() == EntityType.BLAZE) {
entity.hurt(DamageSource.DROWN, 2);
entity.hurt(entity.damageSources().drown(), 2);
}
if (entity.isOnFire()) {
entity.clearFire();

View file

@ -653,13 +653,13 @@ public class AllArmInteractionPointTypes {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (!(blockEntity instanceof JukeboxBlockEntity jukeboxBE))
return stack;
if (!jukeboxBE.getRecord()
if (!jukeboxBE.getFirstItem()
.isEmpty())
return stack;
ItemStack remainder = stack.copy();
ItemStack toInsert = remainder.split(1);
if (!simulate) {
jukeboxBE.setRecord(toInsert);
jukeboxBE.setFirstItem(toInsert);
level.setBlock(pos, cachedState.setValue(JukeboxBlock.HAS_RECORD, true), 2);
level.levelEvent(null, 1010, pos, Item.getId(item));
}
@ -674,7 +674,7 @@ public class AllArmInteractionPointTypes {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (!(blockEntity instanceof JukeboxBlockEntity jukeboxBE))
return ItemStack.EMPTY;
ItemStack record = jukeboxBE.getRecord();
ItemStack record = jukeboxBE.getFirstItem();
if (record.isEmpty())
return ItemStack.EMPTY;
if (!simulate) {
@ -705,7 +705,7 @@ public class AllArmInteractionPointTypes {
.orElse(4) == 4)
return stack;
if (!simulate)
RespawnAnchorBlock.charge(level, pos, cachedState);
RespawnAnchorBlock.charge(null, level, pos, cachedState);
ItemStack remainder = stack.copy();
remainder.shrink(1);
return remainder;

View file

@ -337,7 +337,7 @@ public class ArmBlockEntity extends KineticBlockEntity implements ITransformable
protected int getDistributableAmount(ArmInteractionPoint armInteractionPoint, int i) {
ItemStack stack = armInteractionPoint.extract(i, true);
ItemStack remainder = simulateInsertion(stack);
if (stack.sameItem(remainder)) {
if (ItemStack.isSameItem(stack, remainder)) {
return stack.getCount() - remainder.getCount();
} else {
return stack.getCount();
@ -391,7 +391,7 @@ public class ArmBlockEntity extends KineticBlockEntity implements ITransformable
sendData();
setChanged();
if (!prevHeld.sameItem(heldItem))
if (!ItemStack.isSameItem(heldItem, prevHeld))
level.playSound(null, worldPosition, SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, .125f,
.5f + Create.RANDOM.nextFloat() * .25f);
return;

View file

@ -43,7 +43,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.crafting.IShapedRecipe;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
public class MechanicalMixerBlockEntity extends BasinOperatingBlockEntity {

View file

@ -222,7 +222,7 @@ public class EjectorBlockEntity extends KineticBlockEntity {
;
else if (remainder.isEmpty())
iterator.remove();
else if (!remainder.sameItem(stack))
else if (!ItemStack.isSameItem(remainder, stack))
transportedItemStack.stack = remainder;
}

View file

@ -546,8 +546,7 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
if (simulate)
return true;
for (ItemStack itemStack : outputItems) {
if (itemStack.hasCraftingRemainingItem() && itemStack.getCraftingRemainingItem()
.sameItem(itemStack))
if (itemStack.hasCraftingRemainingItem() && ItemStack.isSameItem(itemStack, itemStack.getCraftingRemainingItem()))
continue;
spoutputBuffer.add(itemStack.copy());
}
@ -591,8 +590,7 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
private boolean acceptItemOutputsIntoBasin(List<ItemStack> outputItems, boolean simulate, IItemHandler targetInv) {
for (ItemStack itemStack : outputItems) {
// Catalyst items are never consumed
if (itemStack.hasCraftingRemainingItem() && itemStack.getCraftingRemainingItem()
.sameItem(itemStack))
if (itemStack.hasCraftingRemainingItem() && ItemStack.isSameItem(itemStack, itemStack.getCraftingRemainingItem()))
continue;
if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate)
.isEmpty())

View file

@ -17,6 +17,7 @@ import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
@ -170,8 +171,8 @@ public abstract class ProcessingRecipe<T extends Container> implements Recipe<T>
// IRecipe<> paperwork
@Override
public ItemStack assemble(T inv) {
return getResultItem();
public ItemStack assemble(T inv, RegistryAccess registryAccess) {
return getResultItem(registryAccess);
}
@Override
@ -180,7 +181,7 @@ public abstract class ProcessingRecipe<T extends Container> implements Recipe<T>
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess registryAccess) {
return getRollableResults().isEmpty() ? ItemStack.EMPTY
: getRollableResults().get(0)
.getStack();

View file

@ -18,6 +18,7 @@ import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@ -178,7 +179,7 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
}
@Override
public ItemStack assemble(RecipeWrapper p_77572_1_) {
public ItemStack assemble(RecipeWrapper inv, RegistryAccess registryAccess) {
return ItemStack.EMPTY;
}
@ -188,7 +189,7 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess registryAccess) {
return resultPool.get(0)
.getStack();
}

View file

@ -156,7 +156,7 @@ public class LinkBehaviour extends BlockEntityBehaviour implements IRedstoneLink
stack = stack.copy();
stack.setCount(1);
ItemStack toCompare = first ? frequencyFirst.getStack() : frequencyLast.getStack();
boolean changed = !ItemStack.isSame(stack, toCompare) || !ItemStack.tagMatches(stack, toCompare);
boolean changed = !ItemStack.isSameItemSameTags(stack, toCompare);
if (changed)
getHandler().removeFromNetwork(getWorld(), this);

View file

@ -29,12 +29,12 @@ public class SchematicannonInventory extends ItemStackHandler {
case 1: // Blueprint output
return false;
case 2: // Book input
return AllBlocks.CLIPBOARD.isIn(stack) || stack.sameItem(new ItemStack(Items.BOOK))
|| stack.sameItem(new ItemStack(Items.WRITTEN_BOOK));
return AllBlocks.CLIPBOARD.isIn(stack) || stack.is(Items.BOOK)
|| stack.is(Items.WRITTEN_BOOK);
case 3: // Material List output
return false;
case 4: // Gunpowder
return stack.sameItem(new ItemStack(Items.GUNPOWDER));
return stack.is(Items.GUNPOWDER);
default:
return super.isItemValid(slot, stack);
}

View file

@ -165,7 +165,7 @@ public class ItemRequirement {
}
public boolean matches(ItemStack other) {
return stack.sameItem(other);
return ItemStack.isSameItem(stack, other);
}
}

View file

@ -18,6 +18,7 @@ import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.SignalGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
@ -57,7 +58,7 @@ public class SignalBlock extends Block implements IBE<SignalBlockEntity>, IWrenc
}
@Override
public boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) {
public boolean shouldCheckWeakPower(BlockState state, SignalGetter level, BlockPos pos, Direction side) {
return false;
}

View file

@ -16,6 +16,7 @@ import com.simibubi.create.Create;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.advancements.CriterionTrigger;
import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance;
import net.minecraft.advancements.critereon.ContextAwarePredicate;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.PlayerAdvancements;
@ -80,8 +81,8 @@ public abstract class CriterionTriggerBase<T extends CriterionTriggerBase.Instan
public abstract static class Instance extends AbstractCriterionTriggerInstance {
public Instance(ResourceLocation idIn, EntityPredicate.Composite p_i231464_2_) {
super(idIn, p_i231464_2_);
public Instance(ResourceLocation idIn, ContextAwarePredicate predicate) {
super(idIn, predicate);
}
protected abstract boolean test(@Nullable List<Supplier<Object>> suppliers);

View file

@ -9,6 +9,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
import com.google.gson.JsonObject;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.advancements.critereon.ContextAwarePredicate;
import net.minecraft.advancements.critereon.DeserializationContext;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.resources.ResourceLocation;
@ -38,7 +39,7 @@ public class SimpleCreateTrigger extends CriterionTriggerBase<SimpleCreateTrigge
public static class Instance extends CriterionTriggerBase.Instance {
public Instance(ResourceLocation idIn) {
super(idIn, EntityPredicate.Composite.ANY);
super(idIn, ContextAwarePredicate.ANY);
}
@Override

View file

@ -79,7 +79,7 @@ public class ModularGuiLineBuilder {
EditBox input = new EditBox(font, x + this.x + 5, y, width - 9, 8, Components.immutableEmpty());
input.setBordered(false);
input.setTextColor(0xffffff);
input.changeFocus(false);
input.setFocused(false);
input.mouseClicked(0, 0, 0);
TooltipArea tooltipArea = new TooltipArea(this.x + x, y - 4, width, 18);
inputTransform.accept(input, tooltipArea);

View file

@ -10,6 +10,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.TickableGuiEventListener;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.network.chat.Component;
@ -63,26 +64,22 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
public void tick() {}
@Override
public void render(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
if (visible) {
isHovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height;
beforeRender(ms, mouseX, mouseY, partialTicks);
renderButton(ms, mouseX, mouseY, partialTicks);
afterRender(ms, mouseX, mouseY, partialTicks);
wasHovered = isHoveredOrFocused();
}
public void renderWidget(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
beforeRender(graphics, mouseX, mouseY, partialTicks);
renderButton(graphics, mouseX, mouseY, partialTicks);
afterRender(graphics, mouseX, mouseY, partialTicks);
wasHovered = isHoveredOrFocused();
}
protected void beforeRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
ms.pushPose();
protected void beforeRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
graphics.pose().pushPose();
}
@Override
public void renderButton(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
protected void renderButton(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
}
protected void afterRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
ms.popPose();
protected void afterRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
graphics.pose().popPose();
}
public void runCallback(double mouseX, double mouseY) {

View file

@ -8,6 +8,7 @@ import com.simibubi.create.foundation.utility.Components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@ -71,7 +72,7 @@ public class Label extends AbstractSimiWidget {
}
@Override
public void renderButton(@Nonnull PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
protected void renderButton(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
if (text == null || text.getString().isEmpty())
return;
@ -80,10 +81,7 @@ public class Label extends AbstractSimiWidget {
if (suffix != null && !suffix.isEmpty())
copy.append(suffix);
if (hasShadow)
font.drawShadow(matrixStack, copy, getX(), getY(), color);
else
font.draw(matrixStack, copy, getX(), getY(), color);
graphics.drawString(font, copy, getX(), getY(), color, hasShadow);
}
}

View file

@ -125,7 +125,7 @@ public class ItemHelper {
return true;
if (stacks1.length == stacks2.length) {
for (int i = 0; i < stacks1.length; i++)
if (!ItemStack.isSame(stacks1[i], stacks2[i]))
if (!ItemStack.isSameItem(stacks1[i], stacks2[i]))
return false;
return true;
}

View file

@ -43,7 +43,6 @@ import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.level.BlockEvent;

View file

@ -42,7 +42,7 @@ public class WrappedWorld extends Level {
protected LevelEntityGetter<Entity> entityGetter = new DummyLevelEntityGetter<>();
public WrappedWorld(Level world) {
super((WritableLevelData) world.getLevelData(), world.dimension(), world.dimensionTypeRegistration(),
super((WritableLevelData) world.getLevelData(), world.dimension(), world.registryAccess(), world.dimensionTypeRegistration(),
world::getProfiler, world.isClientSide, world.isDebug(), 0, 0);
this.world = world;
}

View file

@ -23,7 +23,6 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
public class HosePulleyScenes {