updating destroy WIP

This commit is contained in:
gnembon committed 2020-01-30 17:36:46 -04:00
1 parent ef16ade921
commit 54f81f184a
1 file changed
+34 -9
@@ -59,6 +59,7 @@ import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@@ -1240,16 +1241,40 @@ public class CarpetExpression
long how = 0; long how = 0;
if (lv.size() > locator.offset) if (lv.size() > locator.offset)
how = NumericValue.asNumber(lv.get(locator.offset).evalValue(cc)).getLong(); how = NumericValue.asNumber(lv.get(locator.offset).evalValue(cc)).getLong();
Item item = Items.DIAMOND_PICKAXE;
if (lv.size() > locator.offset+1)
{
String itemString = lv.get(locator.offset+1).evalValue(c).getString();
item = Registry.ITEM.get(new Identifier(itemString));
if (item == Items.AIR && !itemString.equals("air")) throw new InternalExpressionException("Incorrect item: "+itemString);
}
CompoundTag tag = null;
if (lv.size() > locator.offset+2)
{
Value tagValue = lv.get(locator.offset+2).evalValue(c);
if (tagValue instanceof NBTSerializableValue)
tag = ((NBTSerializableValue) tagValue).getCompoundTag();
else
tag = NBTSerializableValue.parseString(tagValue.getString()).getCompoundTag();
}
world.clearBlockState(where, false); world.clearBlockState(where, false);
world.playLevelEvent(null, 2001, where, Block.getRawIdFromState(state)); world.playLevelEvent(null, 2001, where, Block.getRawIdFromState(state));
if (how < 0) // WIP tool still mines everything, and only enchantments count.
{ // need to verify the durability changes
Block.dropStack(world, where, new ItemStack(state.getBlock()));
} //if (how < 0)
else //{
{ // Block.dropStack(world, where, new ItemStack(state.getBlock()));
ItemStack tool = new ItemStack(Items.DIAMOND_PICKAXE, 1); //}
tool.addEnchantment(Enchantments.FORTUNE,(int)how); //else
//{
ItemStack tool = new ItemStack(item, 1);
if (tag != null)
tool.setTag(tag);
if (how > 0)
tool.addEnchantment(Enchantments.FORTUNE,(int)how);
else if (how < 0)
tool.addEnchantment(Enchantments.SILK_TOUCH, 1);
LootContext.Builder lootContext$Builder_1 = (new LootContext.Builder(world)). LootContext.Builder lootContext$Builder_1 = (new LootContext.Builder(world)).
setRandom(world.random). setRandom(world.random).
@@ -1261,7 +1286,7 @@ public class CarpetExpression
state.getDroppedStacks(lootContext$Builder_1).forEach((stack) -> Block.dropStack(world, where, stack)); state.getDroppedStacks(lootContext$Builder_1).forEach((stack) -> Block.dropStack(world, where, stack));
//Block.dropStacks(state, world, where, be, cc.s.getEntity(), tool ); //Block.dropStacks(state, world, where, be, cc.s.getEntity(), tool );
} //}
return (c_, t_) -> Value.TRUE; return (c_, t_) -> Value.TRUE;
}); });