Skip to content

Commit 4325468

Browse files
committed
Update to official 1.16 mappings
1 parent 21ae125 commit 4325468

10 files changed

Lines changed: 48 additions & 47 deletions

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ dependencies {
101101
}
102102

103103
minecraft {
104-
mappings channel: "${project.mcp_mappings_channel}", version: "${project.mcp_mappings_version}"
104+
mappings channel: "official", version: "${project.minecraft_version}"
105105

106106
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
107107

gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
mod_version=0.2.2
22
minecraft_version=1.16.5
33
forge_version=36.0.14
4-
mcp_mappings_channel=snapshot
5-
mcp_mappings_version=20201028-1.16.3
64
cyclopscore_version=1.11.6-64
75
release_type=release
86
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44

src/main/java/org/cyclops/structuredcrafting/block/BlockStructuredCrafter.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@ public class BlockStructuredCrafter extends BlockTile {
3131
public BlockStructuredCrafter(Block.Properties properties) {
3232
super(properties, TileStructuredCrafter::new);
3333

34-
this.setDefaultState(this.stateContainer.getBaseState()
35-
.with(FACING, Direction.DOWN));
34+
this.registerDefaultState(this.stateDefinition.any()
35+
.setValue(FACING, Direction.DOWN));
3636
}
3737

3838
@Override
39-
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
39+
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
4040
builder.add(FACING);
4141
}
4242

4343
@Nullable
4444
@Override
4545
public BlockState getStateForPlacement(BlockItemUseContext context) {
46-
return this.getDefaultState()
47-
.with(FACING, context.getFace().getOpposite());
46+
return this.defaultBlockState()
47+
.setValue(FACING, context.getClickedFace().getOpposite());
4848
}
4949

5050
@Override
51-
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand,
51+
public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand,
5252
BlockRayTraceResult hit) {
53-
ItemStack heldItem = player.getHeldItem(hand);
53+
ItemStack heldItem = player.getItemInHand(hand);
5454
if(player != null && !heldItem.isEmpty() && heldItem.getItem() == Items.STICK) {
55-
worldIn.setBlockState(pos, state.with(FACING, hit.getFace().getOpposite()));
55+
worldIn.setBlockAndUpdate(pos, state.setValue(FACING, hit.getDirection().getOpposite()));
5656
return ActionResultType.SUCCESS;
5757
}
58-
return super.onBlockActivated(state, worldIn, pos, player, hand, hit);
58+
return super.use(state, worldIn, pos, player, hand, hit);
5959
}
6060

6161
}

src/main/java/org/cyclops/structuredcrafting/block/BlockStructuredCrafterConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public BlockStructuredCrafterConfig() {
4949
super(
5050
StructuredCrafting._instance,
5151
"structured_crafter",
52-
(eConfig) -> new BlockStructuredCrafter(Block.Properties.create(Material.ROCK)
53-
.hardnessAndResistance(2.0f)),
52+
(eConfig) -> new BlockStructuredCrafter(Block.Properties.of(Material.STONE)
53+
.strength(2.0f)),
5454
getDefaultItemConstructor(StructuredCrafting._instance)
5555
);
5656
}

src/main/java/org/cyclops/structuredcrafting/craft/WorldCraftingMatrix.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public WorldCraftingMatrix(World world, BlockPos centerPos, Direction.Axis axis,
4444

4545
protected BlockPos addInAxis(BlockPos pos, Direction.Axis axis, int i, int j) {
4646
if(axis == Direction.Axis.X) {
47-
return pos.add(0, j, i);
47+
return pos.offset(0, j, i);
4848
} else if(axis == Direction.Axis.Y) {
49-
return pos.add(i, 0, j);
49+
return pos.offset(i, 0, j);
5050
} else if(axis == Direction.Axis.Z) {
51-
return pos.add(i, j, 0);
51+
return pos.offset(i, j, 0);
5252
}
5353
return null;
5454
}
@@ -152,9 +152,9 @@ && addItemStackForOutput(world, targetPos, targetSide, outputProviders, itemStac
152152
}
153153

154154
public static WorldCraftingMatrix deriveMatrix(World world, BlockPos centerPos) {
155-
Direction side = (world.getBlockState(centerPos).get(BlockStructuredCrafter.FACING)).getOpposite();
156-
return new WorldCraftingMatrix(world, centerPos.offset(side), side.getAxis(),
157-
centerPos.offset(side.getOpposite()), side.getOpposite());
155+
Direction side = (world.getBlockState(centerPos).getValue(BlockStructuredCrafter.FACING)).getOpposite();
156+
return new WorldCraftingMatrix(world, centerPos.relative(side), side.getAxis(),
157+
centerPos.relative(side.getOpposite()), side.getOpposite());
158158
}
159159

160160
@ToString
@@ -195,7 +195,7 @@ protected IRecipe getRecipe(World world) {
195195
public ItemStack getOutput(World world) {
196196
IRecipe recipe = getRecipe(world);
197197
if (recipe != null) {
198-
return recipe.getCraftingResult(inventoryCrafting);
198+
return recipe.assemble(inventoryCrafting);
199199
}
200200
return ItemStack.EMPTY;
201201
}
@@ -210,7 +210,7 @@ public void handleRemainingItems(World world, Direction inputSide, boolean simul
210210
IRecipe recipe = getRecipe(world);
211211
NonNullList<ItemStack> remainingStacks = recipe.getRemainingItems(inventoryCrafting);
212212
for(int i = 0; i < remainingStacks.size(); i++) {
213-
ItemStack originalStack = inventoryCrafting.getStackInSlot(i);
213+
ItemStack originalStack = inventoryCrafting.getItem(i);
214214
ItemStack remainingStack = remainingStacks.get(i);
215215
if(originalStack != null && !originalStack.isEmpty()) {
216216
if (providers[i] != null) {
@@ -228,8 +228,8 @@ public void handleRemainingItems(World world, Direction inputSide, boolean simul
228228

229229
public CraftingPossibility clone() {
230230
CraftingPossibility craftingPossibility = new CraftingPossibility();
231-
for (int i = 0; i < this.inventoryCrafting.getSizeInventory(); i++) {
232-
craftingPossibility.inventoryCrafting.setInventorySlotContents(i, this.inventoryCrafting.getStackInSlot(i));
231+
for (int i = 0; i < this.inventoryCrafting.getContainerSize(); i++) {
232+
craftingPossibility.inventoryCrafting.setItem(i, this.inventoryCrafting.getItem(i));
233233
}
234234
System.arraycopy(this.positions, 0, craftingPossibility.positions, 0, this.positions.length);
235235
System.arraycopy(this.providers, 0, craftingPossibility.providers, 0, this.providers.length);

src/main/java/org/cyclops/structuredcrafting/craft/WorldInventoryCrafting.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ public class WorldInventoryCrafting extends CraftingInventory {
1717
public WorldInventoryCrafting() {
1818
super(new Container(ContainerType.CRAFTING, 0) {
1919
@Override
20-
public boolean canInteractWith(PlayerEntity playerIn) {
20+
public boolean stillValid(PlayerEntity playerIn) {
2121
return false;
2222
}
2323
}, 3, 3);
2424
}
2525

2626
public void setItemStack(int row, int col, ItemStack itemStack) {
27-
setInventorySlotContents(col * 3 + row, itemStack.copy());
27+
setItem(col * 3 + row, itemStack.copy());
2828
}
2929

3030
@Override
3131
public boolean equals(Object obj) {
3232
if (!(obj instanceof WorldInventoryCrafting)) {
3333
return false;
3434
}
35-
for (int i = 0; i < getSizeInventory(); i++) {
36-
if (!ItemStack.areItemStacksEqual(this.getStackInSlot(i), ((WorldInventoryCrafting) obj).getStackInSlot(i))) {
35+
for (int i = 0; i < getContainerSize(); i++) {
36+
if (!ItemStack.matches(this.getItem(i), ((WorldInventoryCrafting) obj).getItem(i))) {
3737
return false;
3838
}
3939
}
@@ -42,10 +42,10 @@ public boolean equals(Object obj) {
4242

4343
@Override
4444
public int hashCode() {
45-
int hash = 11 + getSizeInventory();
46-
for (int i = 0; i < getSizeInventory(); i++) {
45+
int hash = 11 + getContainerSize();
46+
for (int i = 0; i < getContainerSize(); i++) {
4747
hash = hash << 1;
48-
hash |= getItemStackHashCode(getStackInSlot(i));
48+
hash |= getItemStackHashCode(getItem(i));
4949
}
5050
return hash;
5151
}
@@ -54,15 +54,15 @@ public static int getItemStackHashCode(ItemStack itemStack) {
5454
if (itemStack == null) {
5555
return 0;
5656
}
57-
return Objects.hashCode(itemStack.getCount(), Item.getIdFromItem(itemStack.getItem()),
57+
return Objects.hashCode(itemStack.getCount(), Item.getId(itemStack.getItem()),
5858
itemStack.hasTag() ? itemStack.getTag() : 0);
5959
}
6060

6161
@Override
6262
public String toString() {
6363
StringBuilder sb = new StringBuilder();
64-
for (int i = 0; i < this.getSizeInventory(); i++) {
65-
sb.append(this.getStackInSlot(i));
64+
for (int i = 0; i < this.getContainerSize(); i++) {
65+
sb.append(this.getItem(i));
6666
sb.append(",");
6767
}
6868
return sb.toString();

src/main/java/org/cyclops/structuredcrafting/craft/provider/InventoryItemStackProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
public class InventoryItemStackProvider implements IItemStackProvider {
2020

2121
protected Pair<Integer, ItemStack> getFirstItem(IInventory inventory, Direction side) {
22-
for(int slot = 0; slot < inventory.getSizeInventory(); slot++) {
23-
ItemStack itemStack = inventory.getStackInSlot(slot);
22+
for(int slot = 0; slot < inventory.getContainerSize(); slot++) {
23+
ItemStack itemStack = inventory.getItem(slot);
2424
if(!itemStack.isEmpty()) {
2525
return Pair.of(slot, itemStack);
2626
}
@@ -91,7 +91,7 @@ public void reduceItemStack(World world, BlockPos pos, Direction side, boolean s
9191
newItemStack = ItemStack.EMPTY;
9292
}
9393
if(!simulate) {
94-
inventory.setInventorySlotContents(result.getLeft(), newItemStack);
94+
inventory.setItem(result.getLeft(), newItemStack);
9595
}
9696
}
9797
}
@@ -107,7 +107,7 @@ public boolean addItemStack(World world, BlockPos pos, Direction side, ItemStack
107107
}
108108
} else {
109109
IInventory inventory = TileHelpers.getSafeTile(world, pos, IInventory.class).orElse(null);
110-
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
110+
for (int slot = 0; slot < inventory.getContainerSize(); slot++) {
111111
if (InventoryHelpers.addToSlot(inventory, slot, itemStack, simulate)) {
112112
return true;
113113
}
@@ -130,7 +130,7 @@ public boolean setItemStack(World world, BlockPos pos, Direction side, ItemStack
130130
Pair<Integer, ItemStack> result = getFirstItem(inventory, side);
131131
if (result != null) {
132132
if(!simulate) {
133-
inventory.setInventorySlotContents(result.getLeft(), itemStack);
133+
inventory.setItem(result.getLeft(), itemStack);
134134
}
135135
return true;
136136
}

src/main/java/org/cyclops/structuredcrafting/craft/provider/WorldItemStackProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public boolean canHandleOutput() {
3030

3131
@Override
3232
public boolean isValidForResults(World world, BlockPos pos, Direction side) {
33-
return world.isAirBlock(pos);
33+
return world.isEmptyBlock(pos);
3434
}
3535

3636
protected boolean hasEmptyItemHandler(World world, BlockPos pos, Direction side) {
@@ -49,7 +49,7 @@ protected boolean hasEmptyItemHandler(World world, BlockPos pos, Direction side)
4949

5050
@Override
5151
public boolean hasItemStack(World world, BlockPos pos, Direction side) {
52-
return !world.isAirBlock(pos) && hasEmptyItemHandler(world, pos, side);
52+
return !world.isEmptyBlock(pos) && hasEmptyItemHandler(world, pos, side);
5353
}
5454

5555
@Override
@@ -58,7 +58,7 @@ public ItemStack getItemStack(World world, BlockPos pos, Direction side) {
5858

5959
ItemStack itemStack = ItemStack.EMPTY;
6060
if(blockState != null) {
61-
Item item = Item.getItemFromBlock(blockState.getBlock());
61+
Item item = Item.byBlock(blockState.getBlock());
6262
if(item != null && hasEmptyItemHandler(world, pos, side)) {
6363
itemStack = new ItemStack(item, 1);
6464
}
@@ -81,7 +81,7 @@ public boolean addItemStack(World world, BlockPos pos, Direction side, ItemStack
8181
@Override
8282
public boolean setItemStack(World world, BlockPos pos, Direction side, ItemStack itemStack, boolean simulate) {
8383
if(!simulate && itemStack.getItem() instanceof BlockItem) {
84-
world.setBlockState(pos, ((BlockItem) itemStack.getItem()).getBlock().getDefaultState());
84+
world.setBlockAndUpdate(pos, ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState());
8585
itemStack.shrink(1);
8686
}
8787
if(!simulate && itemStack.getCount() > 0) {

src/main/java/org/cyclops/structuredcrafting/modcompat/capabilities/WorkerStructuredCrafterTileCompat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public boolean hasWork() {
4343

4444
@Override
4545
public boolean canWork() {
46-
return provider.getWorld().isBlockPowered(provider.getPos());
46+
return provider.getLevel().hasNeighborSignal(provider.getBlockPos());
4747
}
4848
}
4949
}

src/main/java/org/cyclops/structuredcrafting/tileentity/TileStructuredCrafter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import org.cyclops.structuredcrafting.RegistryEntries;
66
import org.cyclops.structuredcrafting.craft.WorldCraftingMatrix;
77

8+
import org.cyclops.cyclopscore.tileentity.CyclopsTileEntity.ITickingTile;
9+
import org.cyclops.cyclopscore.tileentity.CyclopsTileEntity.TickingTileComponent;
10+
811
/**
912
* A ticking tile entity for the structured crafter.
1013
* @author rubensworks
@@ -27,16 +30,16 @@ public TileStructuredCrafter() {
2730

2831
public WorldCraftingMatrix getMatrix() {
2932
if(matrix == null) {
30-
matrix = WorldCraftingMatrix.deriveMatrix(world, pos);
33+
matrix = WorldCraftingMatrix.deriveMatrix(level, worldPosition);
3134
}
3235
return matrix;
3336
}
3437

3538
@Override
3639
protected void updateTileEntity() {
3740
tickOffset = (tickOffset + 1) % SPEED;
38-
if(!world.isRemote && tickOffset == 0) {
39-
if(world.isBlockPowered(getPos())) {
41+
if(!level.isClientSide && tickOffset == 0) {
42+
if(level.hasNeighborSignal(getBlockPos())) {
4043
getMatrix().craft(false);
4144
} else {
4245
matrix = null;

0 commit comments

Comments
 (0)