mappings
This commit is contained in:
1 parent
419b739d5e
commit
43ff0e8c11
7 files changed
+39
-41
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
# or better: https://modmuss50.me/fabric.html
|
# or better: https://modmuss50.me/fabric.html
|
||||||
minecraft_version=20w13b
|
minecraft_version=20w13b
|
||||||
yarn_mappings=20w13b+build.4
|
yarn_mappings=20w13b+build.7
|
||||||
loader_version=0.7.8+build.189
|
loader_version=0.7.8+build.189
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
|
|||||||
@@ -242,9 +242,9 @@ public class EntityPlayerActionPack
|
|||||||
private void dropItemFromSlot(int slot, boolean dropAll)
|
private void dropItemFromSlot(int slot, boolean dropAll)
|
||||||
{
|
{
|
||||||
PlayerInventory inv = player.inventory;
|
PlayerInventory inv = player.inventory;
|
||||||
if (!inv.getInvStack(slot).isEmpty())
|
if (!inv.getStack(slot).isEmpty())
|
||||||
player.dropItem(inv.takeInvStack(slot,
|
player.dropItem(inv.removeStack(slot,
|
||||||
dropAll ? inv.getInvStack(slot).getCount() : 1
|
dropAll ? inv.getStack(slot).getCount() : 1
|
||||||
), false, true); // scatter, keep owner
|
), false, true); // scatter, keep owner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ public class EntityPlayerActionPack
|
|||||||
PlayerInventory inv = player.inventory;
|
PlayerInventory inv = player.inventory;
|
||||||
if (selectedSlot == -2) // all
|
if (selectedSlot == -2) // all
|
||||||
{
|
{
|
||||||
for (int i = inv.getInvSize(); i >= 0; i--)
|
for (int i = inv.size(); i >= 0; i--)
|
||||||
dropItemFromSlot(i, dropAll);
|
dropItemFromSlot(i, dropAll);
|
||||||
}
|
}
|
||||||
else // one slot
|
else // one slot
|
||||||
|
|||||||
@@ -32,11 +32,9 @@ public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntit
|
|||||||
@Shadow
|
@Shadow
|
||||||
public abstract double getHopperZ();
|
public abstract double getHopperZ();
|
||||||
|
|
||||||
@Shadow
|
@Shadow public abstract int size();
|
||||||
public abstract void setInvStack(int int_1, ItemStack itemStack_1);
|
|
||||||
|
|
||||||
@Shadow
|
@Shadow public abstract void setStack(int slot, ItemStack stack);
|
||||||
public abstract int getInvSize();
|
|
||||||
|
|
||||||
@Inject(method = "insert", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "insert", at = @At("HEAD"), cancellable = true)
|
||||||
private void onInsert(CallbackInfoReturnable<Boolean> cir)
|
private void onInsert(CallbackInfoReturnable<Boolean> cir)
|
||||||
@@ -47,13 +45,13 @@ public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntit
|
|||||||
new BlockPos(getHopperX(), getHopperY(), getHopperZ()).offset(this.getCachedState().get(HopperBlock.FACING)));
|
new BlockPos(getHopperX(), getHopperY(), getHopperZ()).offset(this.getCachedState().get(HopperBlock.FACING)));
|
||||||
if (wool_color != null)
|
if (wool_color != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this.getInvSize(); ++i)
|
for (int i = 0; i < size(); ++i)
|
||||||
{
|
{
|
||||||
if (!this.getInvStack(i).isEmpty())
|
if (!this.getStack(i).isEmpty())
|
||||||
{
|
{
|
||||||
ItemStack itemstack = this.getInvStack(i);//.copy();
|
ItemStack itemstack = this.getStack(i);//.copy();
|
||||||
HopperCounter.COUNTERS.get(wool_color).add(this.getWorld().getServer(), itemstack);
|
HopperCounter.COUNTERS.get(wool_color).add(this.getWorld().getServer(), itemstack);
|
||||||
this.setInvStack(i, ItemStack.EMPTY);
|
this.setStack(i, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cir.setReturnValue(true);
|
cir.setReturnValue(true);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import net.minecraft.item.Items;
|
|||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.GlobalPos;
|
import net.minecraft.util.dynamic.GlobalPos;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.dynamic.Timestamp;
|
import net.minecraft.util.dynamic.Timestamp;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|||||||
@@ -1417,7 +1417,7 @@ public class CarpetExpression
|
|||||||
NBTSerializableValue.InventoryLocator inventoryLocator = NBTSerializableValue.locateInventory(cc, lv, 0);
|
NBTSerializableValue.InventoryLocator inventoryLocator = NBTSerializableValue.locateInventory(cc, lv, 0);
|
||||||
if (inventoryLocator == null)
|
if (inventoryLocator == null)
|
||||||
return (_c, _t) -> Value.NULL;
|
return (_c, _t) -> Value.NULL;
|
||||||
Value res = new NumericValue(inventoryLocator.inventory.getInvSize());
|
Value res = new NumericValue(inventoryLocator.inventory.size());
|
||||||
return (_c, _t) -> res;
|
return (_c, _t) -> res;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1427,7 +1427,7 @@ public class CarpetExpression
|
|||||||
NBTSerializableValue.InventoryLocator inventoryLocator = NBTSerializableValue.locateInventory(cc, lv, 0);
|
NBTSerializableValue.InventoryLocator inventoryLocator = NBTSerializableValue.locateInventory(cc, lv, 0);
|
||||||
if (inventoryLocator == null)
|
if (inventoryLocator == null)
|
||||||
return (_c, _t) -> Value.NULL;
|
return (_c, _t) -> Value.NULL;
|
||||||
Value res = new NumericValue(!inventoryLocator.inventory.isInvEmpty());
|
Value res = new NumericValue(!inventoryLocator.inventory.isEmpty());
|
||||||
return (_c, _t) -> res;
|
return (_c, _t) -> res;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1441,18 +1441,18 @@ public class CarpetExpression
|
|||||||
if (lv.size() == inventoryLocator.offset)
|
if (lv.size() == inventoryLocator.offset)
|
||||||
{
|
{
|
||||||
List<Value> fullInventory = new ArrayList<>();
|
List<Value> fullInventory = new ArrayList<>();
|
||||||
for (int i = 0, maxi = inventoryLocator.inventory.getInvSize(); i < maxi; i++)
|
for (int i = 0, maxi = inventoryLocator.inventory.size(); i < maxi; i++)
|
||||||
{
|
{
|
||||||
fullInventory.add(ListValue.fromItemStack(inventoryLocator.inventory.getInvStack(i)));
|
fullInventory.add(ListValue.fromItemStack(inventoryLocator.inventory.getStack(i)));
|
||||||
}
|
}
|
||||||
Value res = ListValue.wrap(fullInventory);
|
Value res = ListValue.wrap(fullInventory);
|
||||||
return (_c, _t) -> res;
|
return (_c, _t) -> res;
|
||||||
}
|
}
|
||||||
int slot = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset).evalValue(c)).getLong();
|
int slot = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset).evalValue(c)).getLong();
|
||||||
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
|
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
|
||||||
if (slot == inventoryLocator.inventory.getInvSize())
|
if (slot == inventoryLocator.inventory.size())
|
||||||
return (_c, _t) -> Value.NULL;
|
return (_c, _t) -> Value.NULL;
|
||||||
Value res = ListValue.fromItemStack(inventoryLocator.inventory.getInvStack(slot));
|
Value res = ListValue.fromItemStack(inventoryLocator.inventory.getStack(slot));
|
||||||
return (_c, _t) -> res;
|
return (_c, _t) -> res;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1467,23 +1467,23 @@ public class CarpetExpression
|
|||||||
throw new InternalExpressionException("'inventory_set' requires at least slot number and new stack size, and optional new item");
|
throw new InternalExpressionException("'inventory_set' requires at least slot number and new stack size, and optional new item");
|
||||||
int slot = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+0).evalValue(c)).getLong();
|
int slot = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+0).evalValue(c)).getLong();
|
||||||
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
|
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
|
||||||
if (slot == inventoryLocator.inventory.getInvSize())
|
if (slot == inventoryLocator.inventory.size())
|
||||||
return (_c, _t) -> Value.NULL;
|
return (_c, _t) -> Value.NULL;
|
||||||
int count = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
int count = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
// clear slot
|
// clear slot
|
||||||
ItemStack removedStack = inventoryLocator.inventory.removeInvStack(slot);
|
ItemStack removedStack = inventoryLocator.inventory.removeStack(slot);
|
||||||
syncPlayerInventory(inventoryLocator, slot);
|
syncPlayerInventory(inventoryLocator, slot);
|
||||||
//Value res = ListValue.fromItemStack(removedStack); // that tuple will be read only but cheaper if noone cares
|
//Value res = ListValue.fromItemStack(removedStack); // that tuple will be read only but cheaper if noone cares
|
||||||
return (_c, _t) -> ListValue.fromItemStack(removedStack);
|
return (_c, _t) -> ListValue.fromItemStack(removedStack);
|
||||||
}
|
}
|
||||||
if (lv.size() < inventoryLocator.offset+3)
|
if (lv.size() < inventoryLocator.offset+3)
|
||||||
{
|
{
|
||||||
ItemStack previousStack = inventoryLocator.inventory.getInvStack(slot);
|
ItemStack previousStack = inventoryLocator.inventory.getStack(slot);
|
||||||
ItemStack newStack = previousStack.copy();
|
ItemStack newStack = previousStack.copy();
|
||||||
newStack.setCount(count);
|
newStack.setCount(count);
|
||||||
inventoryLocator.inventory.setInvStack(slot, newStack);
|
inventoryLocator.inventory.setStack(slot, newStack);
|
||||||
syncPlayerInventory(inventoryLocator, slot);
|
syncPlayerInventory(inventoryLocator, slot);
|
||||||
return (_c, _t) -> ListValue.fromItemStack(previousStack);
|
return (_c, _t) -> ListValue.fromItemStack(previousStack);
|
||||||
}
|
}
|
||||||
@@ -1503,10 +1503,10 @@ public class CarpetExpression
|
|||||||
nbt
|
nbt
|
||||||
);
|
);
|
||||||
|
|
||||||
ItemStack previousStack = inventoryLocator.inventory.getInvStack(slot);
|
ItemStack previousStack = inventoryLocator.inventory.getStack(slot);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
inventoryLocator.inventory.setInvStack(slot, newitem.createStack(count, false));
|
inventoryLocator.inventory.setStack(slot, newitem.createStack(count, false));
|
||||||
syncPlayerInventory(inventoryLocator, slot);
|
syncPlayerInventory(inventoryLocator, slot);
|
||||||
}
|
}
|
||||||
catch (CommandSyntaxException e)
|
catch (CommandSyntaxException e)
|
||||||
@@ -1536,9 +1536,9 @@ public class CarpetExpression
|
|||||||
startIndex = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
startIndex = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
||||||
}
|
}
|
||||||
startIndex = NBTSerializableValue.validateSlot(startIndex, inventoryLocator.inventory);
|
startIndex = NBTSerializableValue.validateSlot(startIndex, inventoryLocator.inventory);
|
||||||
for (int i = startIndex, maxi = inventoryLocator.inventory.getInvSize(); i < maxi; i++)
|
for (int i = startIndex, maxi = inventoryLocator.inventory.size(); i < maxi; i++)
|
||||||
{
|
{
|
||||||
ItemStack stack = inventoryLocator.inventory.getInvStack(i);
|
ItemStack stack = inventoryLocator.inventory.getStack(i);
|
||||||
if ( (itemArg == null && stack.isEmpty()) || (itemArg != null && itemArg.getItem().equals(stack.getItem())) )
|
if ( (itemArg == null && stack.isEmpty()) || (itemArg != null && itemArg.getItem().equals(stack.getItem())) )
|
||||||
{
|
{
|
||||||
Value res = new NumericValue(i);
|
Value res = new NumericValue(i);
|
||||||
@@ -1566,14 +1566,14 @@ public class CarpetExpression
|
|||||||
amount = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
amount = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
||||||
}
|
}
|
||||||
// not enough
|
// not enough
|
||||||
if (((amount == 1) && (!inventoryLocator.inventory.containsAnyInInv(Sets.newHashSet(searchItem.getItem()))))
|
if (((amount == 1) && (!inventoryLocator.inventory.containsAny(Sets.newHashSet(searchItem.getItem()))))
|
||||||
|| (inventoryLocator.inventory.countInInv(searchItem.getItem()) < amount))
|
|| (inventoryLocator.inventory.count(searchItem.getItem()) < amount))
|
||||||
{
|
{
|
||||||
return (_c, _t) -> Value.FALSE;
|
return (_c, _t) -> Value.FALSE;
|
||||||
}
|
}
|
||||||
for (int i = 0, maxi = inventoryLocator.inventory.getInvSize(); i < maxi; i++)
|
for (int i = 0, maxi = inventoryLocator.inventory.size(); i < maxi; i++)
|
||||||
{
|
{
|
||||||
ItemStack stack = inventoryLocator.inventory.getInvStack(i);
|
ItemStack stack = inventoryLocator.inventory.getStack(i);
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (!stack.getItem().equals(searchItem.getItem()))
|
if (!stack.getItem().equals(searchItem.getItem()))
|
||||||
@@ -1582,13 +1582,13 @@ public class CarpetExpression
|
|||||||
if (left > 0)
|
if (left > 0)
|
||||||
{
|
{
|
||||||
stack.setCount(left);
|
stack.setCount(left);
|
||||||
inventoryLocator.inventory.setInvStack(i, stack);
|
inventoryLocator.inventory.setStack(i, stack);
|
||||||
syncPlayerInventory(inventoryLocator, i);
|
syncPlayerInventory(inventoryLocator, i);
|
||||||
return (_c, _t) -> Value.TRUE;
|
return (_c, _t) -> Value.TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inventoryLocator.inventory.removeInvStack(i);
|
inventoryLocator.inventory.removeStack(i);
|
||||||
syncPlayerInventory(inventoryLocator, i);
|
syncPlayerInventory(inventoryLocator, i);
|
||||||
amount -= stack.getCount();
|
amount -= stack.getCount();
|
||||||
}
|
}
|
||||||
@@ -1609,19 +1609,19 @@ public class CarpetExpression
|
|||||||
throw new InternalExpressionException("Slot number is required for inventory_drop");
|
throw new InternalExpressionException("Slot number is required for inventory_drop");
|
||||||
int slot = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset).evalValue(c)).getLong();
|
int slot = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset).evalValue(c)).getLong();
|
||||||
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
|
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
|
||||||
if (slot == inventoryLocator.inventory.getInvSize())
|
if (slot == inventoryLocator.inventory.size())
|
||||||
return (_c, _t) -> Value.NULL;
|
return (_c, _t) -> Value.NULL;
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
if (lv.size() > inventoryLocator.offset+1)
|
if (lv.size() > inventoryLocator.offset+1)
|
||||||
amount = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
amount = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset+1).evalValue(c)).getLong();
|
||||||
if (amount < 0)
|
if (amount < 0)
|
||||||
throw new InternalExpressionException("Cannot throw negative number of items");
|
throw new InternalExpressionException("Cannot throw negative number of items");
|
||||||
ItemStack stack = inventoryLocator.inventory.getInvStack(slot);
|
ItemStack stack = inventoryLocator.inventory.getStack(slot);
|
||||||
if (stack == null || stack.isEmpty())
|
if (stack == null || stack.isEmpty())
|
||||||
return (_c, _t) -> Value.ZERO;
|
return (_c, _t) -> Value.ZERO;
|
||||||
if (amount == 0)
|
if (amount == 0)
|
||||||
amount = stack.getCount();
|
amount = stack.getCount();
|
||||||
ItemStack droppedStack = inventoryLocator.inventory.takeInvStack(slot, amount);
|
ItemStack droppedStack = inventoryLocator.inventory.removeStack(slot, amount);
|
||||||
if (droppedStack.isEmpty())
|
if (droppedStack.isEmpty())
|
||||||
{
|
{
|
||||||
return (_c, _t) -> Value.ZERO;
|
return (_c, _t) -> Value.ZERO;
|
||||||
@@ -1662,7 +1662,7 @@ public class CarpetExpression
|
|||||||
player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(
|
player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(
|
||||||
-2,
|
-2,
|
||||||
int_1,
|
int_1,
|
||||||
inventory.inventory.getInvStack(int_1)
|
inventory.inventory.getStack(int_1)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import net.minecraft.item.ItemPlacementContext;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.GlobalPos;
|
import net.minecraft.util.dynamic.GlobalPos;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|||||||
@@ -263,11 +263,11 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
|||||||
|
|
||||||
public static int validateSlot(int slot, Inventory inv)
|
public static int validateSlot(int slot, Inventory inv)
|
||||||
{
|
{
|
||||||
int invSize = inv.getInvSize();
|
int invSize = inv.size();
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
slot = invSize + slot;
|
slot = invSize + slot;
|
||||||
if (slot < 0 || slot >= invSize)
|
if (slot < 0 || slot >= invSize)
|
||||||
return inv.getInvSize(); // outside of inventory
|
return inv.size(); // outside of inventory
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user