Skip to content

Commit

Permalink
Down to 1096 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BrokenK3yboard committed Jan 10, 2025
1 parent 07b0d70 commit 6b21f61
Show file tree
Hide file tree
Showing 78 changed files with 495 additions and 702 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.violetmoon.quark.addons.oddities.block;

import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.RandomSource;
Expand Down Expand Up @@ -71,7 +72,7 @@ public MenuProvider getMenuProvider(@NotNull BlockState state, Level level, @Not

@NotNull
@Override
public InteractionResult use(@NotNull BlockState state, Level worldIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) {
public InteractionResult useWithoutItem(@NotNull BlockState state, Level worldIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull BlockHitResult hit) {
if(worldIn.isClientSide) {
return InteractionResult.SUCCESS;
} else {
Expand All @@ -89,10 +90,10 @@ public InteractionResult use(@NotNull BlockState state, Level worldIn, @NotNull

@Override
public void setPlacedBy(@NotNull Level worldIn, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
if(stack.hasCustomHoverName()) {
if(stack.getComponents().has(DataComponents.CUSTOM_NAME)) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if(tileentity instanceof CrateBlockEntity crate)
crate.setCustomName(stack.getHoverName());
crate.setComponents(stack.getHoverName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.BlockPlaceContext;
Expand Down Expand Up @@ -45,7 +46,6 @@ public MagnetBlock(@Nullable ZetaModule module) {

registerDefaultState(defaultBlockState().setValue(FACING, Direction.DOWN).setValue(POWERED, false).setValue(WAXED, false));


if(module == null) //auto registration below this line
return;
setCreativeTab(CreativeModeTabs.REDSTONE_BLOCKS);
Expand All @@ -55,9 +55,9 @@ public MagnetBlock(@Nullable ZetaModule module) {
}

@Override
public void appendHoverText(@NotNull ItemStack stack, @Nullable BlockGetter worldIn, @NotNull List<Component> tooltip, @NotNull TooltipFlag flagIn) {
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> components, TooltipFlag flag) {
if(stack.getHoverName().getString().equals("Q"))
tooltip.add(Component.literal("haha yes"));
components.add(Component.literal("haha yes"));
}

@Override
Expand Down Expand Up @@ -95,7 +95,7 @@ public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int act
BlockEntity tilePresent = world.getBlockEntity(targetPos);
CompoundTag tileData = new CompoundTag();
if(tilePresent != null && !(tilePresent instanceof MagnetizedBlockBlockEntity)) {
tileData = tilePresent.saveWithFullMetadata();
tileData = tilePresent.saveWithFullMetadata(world.registryAccess());
tilePresent.setRemoved();
}

Expand Down Expand Up @@ -150,5 +150,4 @@ public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState sta
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level world, @NotNull BlockState state, @NotNull BlockEntityType<T> type) {
return createTickerHelper(type, MagnetsModule.magnetType, MagnetBlockEntity::tick);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
Expand All @@ -20,6 +21,7 @@
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
Expand Down Expand Up @@ -70,12 +72,13 @@ public boolean useShapeForLightOcclusion(@NotNull BlockState state) {

@NotNull
@Override
public InteractionResult use(@NotNull BlockState state, Level worldIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) {
if(!worldIn.isClientSide && worldIn.getBlockEntity(pos) == null) {
worldIn.removeBlock(pos, false);
public InteractionResult useWithoutItem(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull BlockHitResult hit) {
if (!level.isClientSide && level.getBlockEntity(pos) == null) {
level.removeBlock(pos, false);
return InteractionResult.CONSUME;
} else
} else {
return InteractionResult.PASS;
}
}

@Override
Expand Down Expand Up @@ -105,8 +108,7 @@ private MagnetizedBlockBlockEntity getMagnetTileEntity(BlockGetter world, BlockP
}

@Override
@NotNull
public ItemStack getCloneItemStack(@NotNull BlockGetter worldIn, @NotNull BlockPos pos, @NotNull BlockState state) {
public ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state) {
return ItemStack.EMPTY;
}

Expand All @@ -128,7 +130,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
}

@Override
public boolean isPathfindable(@NotNull BlockState state, @NotNull BlockGetter worldIn, @NotNull BlockPos pos, @NotNull PathComputationType type) {
protected boolean isPathfindable(BlockState state, PathComputationType type) {
return false;
}

Expand All @@ -141,5 +143,4 @@ public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState sta
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level world, @NotNull BlockState state, @NotNull BlockEntityType<T> type) {
return createTickerHelper(type, MagnetsModule.magnetizedBlockType, MagnetizedBlockBlockEntity::tick);
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package org.violetmoon.quark.addons.oddities.block.be;

import java.util.Random;

import org.jetbrains.annotations.NotNull;
import org.violetmoon.zeta.util.MiscUtil;
import org.violetmoon.zeta.util.SimpleInventoryBlockEntity;

import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
Expand All @@ -19,6 +14,11 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import org.violetmoon.zeta.util.MiscUtil;
import org.violetmoon.zeta.util.SimpleInventoryBlockEntity;

import java.util.Random;

public abstract class AbstractEnchantingTableBlockEntity extends SimpleInventoryBlockEntity implements Nameable {

Expand All @@ -43,19 +43,19 @@ public boolean isAutomationEnabled() {
}

@Override
protected void saveAdditional(CompoundTag compoundTag) {
super.saveAdditional(compoundTag);
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.saveAdditional(tag, provider);

if(hasCustomName())
compoundTag.putString("CustomName", Component.Serializer.toJson(customName));
tag.putString("CustomName", Component.Serializer.toJson(customName, provider));
}

@Override
public void load(CompoundTag compound) {
super.load(compound);
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.loadAdditional(tag, provider);

if(compound.contains("CustomName", 8))
customName = Component.Serializer.fromJson(compound.getString("CustomName"));
if(tag.contains("CustomName", 8))
customName = Component.Serializer.fromJson(tag.getString("CustomName"), provider);
}

public void tick() {
Expand Down Expand Up @@ -141,7 +141,7 @@ public void setCustomName(Component customNameIn) {
}

@Override
public void inventoryChanged(int i) {
protected void inventoryChanged(int i) {
super.inventoryChanged(i);
sync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import net.minecraft.world.phys.AABB;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
import net.neoforged.neoforge.items.IItemHandler;
import org.jetbrains.annotations.NotNull;
import org.violetmoon.quark.addons.oddities.block.CrateBlock;
import org.violetmoon.quark.addons.oddities.capability.CrateItemHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
Expand All @@ -12,7 +13,10 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.BasePressurePlateBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
Expand All @@ -21,9 +25,6 @@
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.addons.oddities.magnetsystem.MagnetSystem;
import org.violetmoon.quark.addons.oddities.module.MagnetsModule;
import org.violetmoon.quark.api.IMagnetMoveAction;
Expand Down Expand Up @@ -229,9 +230,8 @@ public BlockEntity getSubTile(BlockPos pos) {
tileData.putInt("x", this.worldPosition.getX());
tileData.putInt("y", this.worldPosition.getY());
tileData.putInt("z", this.worldPosition.getZ());
return BlockEntity.loadStatic(pos, magnetState, subTile);
return BlockEntity.loadStatic(pos, magnetState, subTile, level.registryAccess());
}

return null;
}

Expand Down Expand Up @@ -302,26 +302,24 @@ public void tick() {
}

@Override
public void load(@NotNull CompoundTag compound) {
super.load(compound);

this.magnetState = NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), compound.getCompound("blockState"));
this.magnetFacing = Direction.from3DDataValue(compound.getInt("facing"));
this.progress = compound.getFloat("progress");
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.loadAdditional(tag, provider);
this.magnetState = NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), tag.getCompound("blockState"));
this.magnetFacing = Direction.from3DDataValue(tag.getInt("facing"));
this.progress = tag.getFloat("progress");
this.lastProgress = this.progress;
this.subTile = compound.getCompound("subTile");
this.subTile = tag.getCompound("subTile");
}

@Override
@NotNull
public CompoundTag getUpdateTag() {
return writeNBTData(serializeNBT(), false);
public CompoundTag getUpdateTag(HolderLookup.Provider provider) {
return writeNBTData(serializeAttachments(provider), false);
}

@Override
protected void saveAdditional(@NotNull CompoundTag nbt) {
super.saveAdditional(nbt);
writeNBTData(nbt, true);
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.saveAdditional(tag, provider);
writeNBTData(tag, true);
}

private CompoundTag writeNBTData(CompoundTag compound, boolean includeSubTile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.particles.DustParticleOptions;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand Down Expand Up @@ -167,7 +168,7 @@ public Iterator<PipeItem> getItemIterator() {
}

public boolean allowsFullConnection(PipeBlockEntity.ConnectionType conn) {
return blockState.getBlock() instanceof BasePipeBlock pipe && pipe.allowsFullConnection(conn);
return getBlockState().getBlock() instanceof BasePipeBlock pipe && pipe.allowsFullConnection(conn);
}

public boolean passIn(ItemStack stack, Direction face, Direction backlog, long seed, int time) {
Expand Down Expand Up @@ -291,45 +292,45 @@ public Packet<ClientGamePacketListener> getUpdatePacket() {
}

@Override
public void readSharedNBT(CompoundTag cmp) {
public void readSharedNBT(CompoundTag tag, HolderLookup.Provider provider) {
skipSync = true;
super.readSharedNBT(cmp);
super.readSharedNBT(tag, provider);
skipSync = false;

ListTag pipeItemList = cmp.getList(TAG_PIPE_ITEMS, cmp.getId());
ListTag pipeItemList = tag.getList(TAG_PIPE_ITEMS, tag.getId());
pipeItems.clear();
pipeItemList.forEach(listCmp -> {
PipeItem item = PipeItem.readFromNBT((CompoundTag) listCmp);
PipeItem item = PipeItem.readFromNBT((CompoundTag) listCmp, provider);
pipeItems.add(item);
});

if(cmp.contains(TAG_CONNECTIONS)) {
var c = cmp.getByteArray(TAG_CONNECTIONS);
if(tag.contains(TAG_CONNECTIONS)) {
var c = tag.getByteArray(TAG_CONNECTIONS);
for(int i = 0; i < c.length; i++) {
connectionsCache[i] = ConnectionType.values()[c[i]];
}
}
}

@Override
public void writeSharedNBT(CompoundTag cmp) {
super.writeSharedNBT(cmp);
public void writeSharedNBT(CompoundTag tag, HolderLookup.Provider provider) {
super.writeSharedNBT(tag, provider);

ListTag pipeItemList = new ListTag();
for(PipeItem item : pipeItems) {
CompoundTag listCmp = new CompoundTag();
item.writeToNBT(listCmp);
item.writeToNBT(listCmp, provider);
pipeItemList.add(listCmp);
}
cmp.put(TAG_PIPE_ITEMS, pipeItemList);
tag.put(TAG_PIPE_ITEMS, pipeItemList);

for(int i = 0; i < connectionsCache.length; i++) {
if(connectionsCache[i] == null) {
connectionsCache[i] = ConnectionType.NONE;
this.convert = true;
}
}
cmp.putByteArray(TAG_CONNECTIONS, (Arrays.stream(connectionsCache).map(c -> (byte) c.ordinal()).toList()));
tag.putByteArray(TAG_CONNECTIONS, (Arrays.stream(connectionsCache).map(c -> (byte) c.ordinal()).toList()));
}

protected boolean canFit(ItemStack stack, BlockPos pos, Direction face) {
Expand Down Expand Up @@ -533,8 +534,8 @@ public float getTimeFract(float partial) {
return (ticksInPipe + partial) / PipesModule.effectivePipeSpeed;
}

public void writeToNBT(CompoundTag cmp) {
stack.save(cmp);
public void writeToNBT(CompoundTag cmp, HolderLookup.Provider provider) {
stack.save(provider, cmp);
cmp.putInt(TAG_TICKS, ticksInPipe);
cmp.putInt(TAG_INCOMING, incomingFace.ordinal());
cmp.putInt(TAG_OUTGOING, outgoingFace.ordinal());
Expand All @@ -543,8 +544,8 @@ public void writeToNBT(CompoundTag cmp) {
cmp.putInt(TAG_TIME_IN_WORLD, timeInWorld);
}

public static PipeItem readFromNBT(CompoundTag cmp) {
ItemStack stack = ItemStack.of(cmp);
public static PipeItem readFromNBT(CompoundTag cmp, HolderLookup.Provider provider) {
ItemStack stack = ItemStack.parseOptional(provider, cmp);
Direction inFace = Direction.values()[cmp.getInt(TAG_INCOMING)];
long rngSeed = cmp.getLong(TAG_RNG_SEED);

Expand Down Expand Up @@ -587,7 +588,5 @@ public double getFlareShift(PipeBlockEntity pipe) {

public final boolean isSolid, allowsItems, isFlared;
private final double flareShift, fullFlareShift;

}

}
Loading

0 comments on commit 6b21f61

Please sign in to comment.