mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-27 13:28:00 +01:00
assorted trivial stuff
This commit is contained in:
parent
55562e5d16
commit
559460e514
26 changed files with 82 additions and 88 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -224,7 +224,7 @@ public class ArmBlockEntity extends KineticBlockEntity implements ITransformable
|
|||
return hasLevel() && state.getOptionalValue(ArmBlock.CEILING)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
|
@ -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;
|
||||
|
@ -544,7 +544,7 @@ public class ArmBlockEntity extends KineticBlockEntity implements ITransformable
|
|||
chasedPointProgress = compound.getFloat("MovementProgress");
|
||||
interactionPointTag = compound.getList("InteractionPoints", Tag.TAG_COMPOUND);
|
||||
redstoneLocked = compound.getBoolean("Powered");
|
||||
|
||||
|
||||
boolean hadGoggles = goggles;
|
||||
goggles = compound.getBoolean("Goggles");
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
@ -98,7 +97,7 @@ public class MechanicalMixerBlockEntity extends BasinOperatingBlockEntity {
|
|||
super.addBehaviours(behaviours);
|
||||
registerAwardables(behaviours, AllAdvancements.MIXER);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected AABB createRenderBoundingBox() {
|
||||
return new AABB(worldPosition).expandTowards(0, -1.5, 0);
|
||||
|
@ -221,15 +220,15 @@ public class MechanicalMixerBlockEntity extends BasinOperatingBlockEntity {
|
|||
|
||||
if (!AllConfigs.server().recipes.allowBrewingInMixer.get())
|
||||
return matchingRecipes;
|
||||
|
||||
|
||||
Optional<BasinBlockEntity> basin = getBasin();
|
||||
if (!basin.isPresent())
|
||||
return matchingRecipes;
|
||||
|
||||
|
||||
BasinBlockEntity basinBlockEntity = basin.get();
|
||||
if (basin.isEmpty())
|
||||
return matchingRecipes;
|
||||
|
||||
|
||||
IItemHandler availableItems = basinBlockEntity
|
||||
.getCapability(ForgeCapabilities.ITEM_HANDLER)
|
||||
.orElse(null);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
@ -147,7 +148,7 @@ public abstract class ProcessingRecipe<T extends Container> implements Recipe<T>
|
|||
public List<ItemStack> rollResults() {
|
||||
return rollResults(this.getRollableResults());
|
||||
}
|
||||
|
||||
|
||||
public List<ItemStack> rollResults(List<ProcessingOutput> rollableResults) {
|
||||
List<ItemStack> results = new ArrayList<>();
|
||||
for (int i = 0; i < rollableResults.size(); i++) {
|
||||
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -29,14 +29,14 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ public class ItemRequirement {
|
|||
}
|
||||
|
||||
public boolean matches(ItemStack other) {
|
||||
return stack.sameItem(other);
|
||||
return ItemStack.isSameItem(stack, other);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -89,7 +90,7 @@ public class SignalBlock extends Block implements IBE<SignalBlockEntity>, IWrenc
|
|||
if (pState.getValue(POWERED) && !pLevel.hasNeighborSignal(pPos))
|
||||
pLevel.setBlock(pPos, pState.cycle(POWERED), 2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
IBE.onRemove(state, worldIn, pos, newState);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -40,12 +40,12 @@ public class ModularGuiLineBuilder {
|
|||
addScrollInput(input, inputTransform, dataKey);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ModularGuiLineBuilder customArea(int x, int width) {
|
||||
target.customBoxes.add(Couple.create(x, width));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ModularGuiLineBuilder speechBubble() {
|
||||
target.speechBubble = true;
|
||||
return this;
|
||||
|
@ -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);
|
||||
|
@ -88,4 +88,4 @@ public class ModularGuiLineBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -18,12 +19,12 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
|
|||
|
||||
public static final int HEADER_RGB = 0x5391E1;
|
||||
public static final int HINT_RGB = 0x96B7E0;
|
||||
|
||||
|
||||
protected float z;
|
||||
protected boolean wasHovered = false;
|
||||
protected List<Component> toolTip = new LinkedList<>();
|
||||
protected BiConsumer<Integer, Integer> onClick = (_$, _$$) -> {};
|
||||
|
||||
|
||||
public int lockedTooltipX = -1;
|
||||
public int lockedTooltipY = -1;
|
||||
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -45,12 +46,12 @@ public class Label extends AbstractSimiWidget {
|
|||
|
||||
public void setTextAndTrim(Component newText, boolean trimFront, int maxWidthPx) {
|
||||
Font fontRenderer = Minecraft.getInstance().font;
|
||||
|
||||
|
||||
if (fontRenderer.width(newText) <= maxWidthPx) {
|
||||
text = newText;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String trim = "...";
|
||||
int trimWidth = fontRenderer.width(trim);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -79,11 +80,8 @@ public class Label extends AbstractSimiWidget {
|
|||
MutableComponent copy = text.plainCopy();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -159,11 +158,11 @@ public class BlockHelper {
|
|||
float effectChance, Consumer<ItemStack> droppedItemCallback) {
|
||||
FluidState fluidState = world.getFluidState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
|
||||
if (world.random.nextFloat() < effectChance)
|
||||
world.levelEvent(2001, pos, Block.getId(state));
|
||||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
||||
|
||||
|
||||
if (player != null) {
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
@ -199,7 +198,7 @@ public class BlockHelper {
|
|||
|
||||
state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true);
|
||||
}
|
||||
|
||||
|
||||
world.setBlockAndUpdate(pos, fluidState.createLegacyBlock());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
@ -357,12 +356,12 @@ public class HosePulleyScenes {
|
|||
.pointAt(util.vector.topOf(util.grid.at(1, 3, 2)));
|
||||
|
||||
scene.idle(60);
|
||||
|
||||
|
||||
scene.world.modifyBlockEntity(util.grid.at(4, 1, 1), FluidTankBlockEntity.class, be -> be.getTankInventory()
|
||||
.fill(new FluidStack(Fluids.WATER, 24000), FluidAction.EXECUTE));
|
||||
|
||||
|
||||
scene.idle(20);
|
||||
|
||||
|
||||
scene.overlay.showText(60)
|
||||
.text("Pipe networks can limitlessly take fluids from/to such pulleys")
|
||||
.attachKeyFrame()
|
||||
|
|
Loading…
Reference in a new issue