cleanup, change dye colors

This commit is contained in:
Sen 2025-06-30 20:48:53 +02:00
parent a73901a584
commit 1fe5003028
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
77 changed files with 409 additions and 1004 deletions

View file

@ -16,7 +16,7 @@ public class ColorParser extends IntParser {
input = input.substring(1);
}
else {
DyeColor color = DyeColor.getByString(input);
DyeColor color = DyeColor.getExact(input);
if(color != null)
return color.getColor();
}

View file

@ -34,7 +34,7 @@ public class CommandItem extends Command {
ItemStack stack = ItemStack.getStack(item, null);
if(stack == null)
throw new RunException("Gegenstand '%s' existiert nicht", item);
stack.setTagCompound(tag);
stack.setTag(tag);
int done = 0;
int given = 0;
for(EntityNPC player : players) {

View file

@ -2870,69 +2870,22 @@ public class Player extends User implements ICrafting, Executor, IPlayer
public void processCheat(CPacketCheat packet)
{
NetHandler.checkThread(packet, this, this.server);
if(this.charEditor)
return;
if(!this.isAdmin())
if(this.charEditor || !this.isAdmin())
return;
// if (this.playerEntity.creative)
// {
// boolean drop = packetIn.getSlotId() < 0;
// boolean changed = false;
ItemStack itemstack = packet.getStack();
// if(itemstack != null && itemstack.getItem() == Items.barrier && !this.playerEntity.canUse(Permissions.BARRIER)) {
// changed = true;
// itemstack = null;
// }
// if(itemstack != null && !itemstack.validate()) {
// changed = true;
// }
if (itemstack.hasTagCompound() && itemstack.getTagCompound().hasObject("BlockEntityTag"))
ItemStack stack = packet.getStack();
if (stack.getItem() != null && stack.size <= stack.getMaxStackSize() && stack.size > 0 && (!stack.hasTag() || stack.getItem().isValidTag(stack.getTag())))
{
// if(!itemstack.getTagCompound().hasTag("BlockEntityTag")) {
// changed = true;
// itemstack.setTagCompound(null);
// }
// else {
TagObject tag = itemstack.getTagCompound().getObject("BlockEntityTag");
if (tag.hasInt("x") && tag.hasInt("y") && tag.hasInt("z"))
{
BlockPos pos = new BlockPos(tag.getInt("x"), tag.getInt("y"), tag.getInt("z"));
TileEntity te = this.entity.worldObj.getTileEntity(pos);
if (te != null)
{
TagObject tile = new TagObject();
te.writeTags(tile);
tile.remove("x");
tile.remove("y");
tile.remove("z");
itemstack.setTagInfo("BlockEntityTag", tile);
}
}
// }
}
// boolean validSlot = packetIn.getSlotId() >= 1 && packetIn.getSlotId() < 36 + InventoryPlayer.getHotbarSize();
boolean validItem = itemstack.getItem() != null;
boolean validData = itemstack.size <= itemstack.getMaxStackSize() && itemstack.size > 0; // TODO: max
if (validItem && validData)
{
int amount = itemstack.size;
int amount = stack.size;
if(packet.getSlot() == -1) {
this.entity.inventory.addItemStackToInventory(itemstack);
amount -= itemstack.size;
this.entity.inventory.addItemStackToInventory(stack);
amount -= stack.size;
}
else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).armorType.getArmorSlot() == packet.getSlot() - this.entity.inventory.mainInventory.length))) {
else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).armorType.getArmorSlot() == packet.getSlot() - this.entity.inventory.mainInventory.length))) {
ItemStack old = this.entity.inventory.getStackInSlot(packet.getSlot());
if(old != null) {
if(ItemStack.areItemsEqual(itemstack, old) && ItemStack.areItemStackTagsEqual(itemstack, old)) {
itemstack.size = Math.min(itemstack.getMaxStackSize(), old.size + itemstack.size);
amount = itemstack.size - old.size;
if(ItemStack.areItemsEqual(stack, old) && ItemStack.areItemStackTagsEqual(stack, old)) {
stack.size = Math.min(stack.getMaxStackSize(), old.size + stack.size);
amount = stack.size - old.size;
}
else if(old.size == 1)
this.addFeed(TextColor.DRED + "* %s zerstört",
@ -2941,7 +2894,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.addFeed(TextColor.DRED + "* %d %s zerstört", old.size,
old.getColoredName(TextColor.DRED));
}
this.entity.inventory.setInventorySlotContents(packet.getSlot(), itemstack);
this.entity.inventory.setInventorySlotContents(packet.getSlot(), stack);
}
else {
return;
@ -2952,10 +2905,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.entity.worldObj.playSoundAtEntity(this.entity, SoundEvent.POP, 0.2F);
if(amount == 1)
this.addFeed(TextColor.DGREEN + "* %s geschummelt",
itemstack.getColoredName(TextColor.DGREEN));
stack.getColoredName(TextColor.DGREEN));
else
this.addFeed(TextColor.DGREEN + "* %d %s geschummelt", amount,
itemstack.getColoredName(TextColor.DGREEN));
stack.getColoredName(TextColor.DGREEN));
}
}

View file

@ -312,6 +312,10 @@ public abstract class Converter {
private static final Map<String, String> ENTITY_MAP = Maps.newHashMap();
private static final Map<String, String> TILE_MAP = Maps.newHashMap();
private static final State[] BLOCK_MAP = new State[65536];
private static final DyeColor[] COLOR_LOOKUP = new DyeColor[] {
DyeColor.WHITE, DyeColor.ORANGE, DyeColor.MAGENTA, DyeColor.LIGHT_BLUE, DyeColor.YELLOW, DyeColor.LIME, DyeColor.PINK, DyeColor.GRAY,
DyeColor.SILVER, DyeColor.CYAN, DyeColor.PURPLE, DyeColor.BLUE, DyeColor.BROWN, DyeColor.GREEN, DyeColor.RED, DyeColor.BLACK
};
private static void mapEntity(Class<? extends Entity> clazz, String ... names) {
String name = EntityRegistry.getEntityString(clazz);
@ -575,7 +579,7 @@ public abstract class Converter {
mapBlock(Blocks.piston_head.getState().withProperty(BlockPistonHead.FACING, Facing.EAST).withProperty(BlockPistonHead.TYPE, EnumPistonType.STICKY), 34, 13);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockWool.getByColor(DyeColor.byMetadata(data)).getState();
return BlockWool.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 35);
mapBlock(Blocks.stone, 36); // mapBlockData(Blocks.piston_extension, 36);
@ -901,7 +905,7 @@ public abstract class Converter {
mapBlock(Blocks.powered_repeater.getState().withProperty(BlockRedstoneRepeater.DELAY, 4).withProperty(BlockRedstoneRepeater.FACING, Facing.EAST), 94, 15);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockStainedGlass.getByColor(DyeColor.byMetadata(data)).getState();
return BlockStainedGlass.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 95);
mapBlock(Blocks.trapdoor.getState().withProperty(BlockTrapDoor.FACING, Facing.NORTH).withProperty(BlockTrapDoor.HALF, DoorHalf.BOTTOM).withProperty(BlockTrapDoor.OPEN, false), 96, 0);
@ -1352,12 +1356,12 @@ public abstract class Converter {
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST).withProperty(BlockDropper.TRIGGERED, true), 158, 13);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockColoredClay.getByColor(DyeColor.byMetadata(data)).getState();
return BlockColoredClay.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 159);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockStainedGlassPane.getByColor(DyeColor.byMetadata(data)).getState();
return BlockStainedGlassPane.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 160);
mapBlock(Blocks.acacia_leaves_spring.getState()
@ -1425,7 +1429,7 @@ public abstract class Converter {
mapBlock(Blocks.hay_block.getState().withProperty(BlockHay.AXIS, Axis.Z), 170, 8, 9, 10, 11);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockCarpet.getByColor(DyeColor.byMetadata(data)).getState();
return BlockCarpet.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 171);
mapBlock(Blocks.hardened_clay, 172);
@ -1631,19 +1635,19 @@ public abstract class Converter {
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.WEST).withProperty(BlockDropper.TRIGGERED, true), 218, 12);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST).withProperty(BlockDropper.TRIGGERED, true), 218, 13);
for(int id = 219; id <= 234; id++) {
mapBlock(BlockWool.getByColor(DyeColor.byMetadata(id - 219)).getState(), id);
mapBlock(BlockWool.getByColor(COLOR_LOOKUP[id - 219]).getState(), id);
}
for(int id = 235; id <= 250; id++) {
mapBlock(BlockColoredClay.getByColor(DyeColor.byMetadata(id - 235)).getState(), id);
mapBlock(BlockColoredClay.getByColor(COLOR_LOOKUP[id - 235]).getState(), id);
}
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockColoredClay.getByColor(DyeColor.byMetadata(data)).getState();
return BlockColoredClay.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 251);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockColoredClay.getByColor(DyeColor.byMetadata(data)).getState();
return BlockColoredClay.getByColor(COLOR_LOOKUP[data]).getState();
}
}, 252);
mapBlock(Blocks.obsidian, 255);