From 13b6a4e2800042529dd5fa0618e73eb581ff1993 Mon Sep 17 00:00:00 2001 From: Sen Date: Mon, 14 Jul 2025 22:15:46 +0200 Subject: [PATCH] fixes, starting to replace redstone --- client/src/main/java/client/Client.java | 12 +++- .../client/gui/container/GuiContainer.java | 63 ++++++++++-------- .../java/client/gui/options/GuiStyle.java | 1 + .../textures/blocks/jukebox_side.png | Bin 395 -> 0 bytes .../resources/textures/blocks/jukebox_top.png | Bin 356 -> 0 bytes .../resources/textures/blocks/noteblock.png | Bin 395 -> 0 bytes common/src/main/java/common/block/Block.java | 30 ++++----- .../common/block/artificial/BlockCake.java | 4 +- .../block/artificial/BlockPortalFrame.java | 4 +- .../common/block/tech/BlockBrewingStand.java | 4 +- .../java/common/block/tech/BlockCauldron.java | 4 +- .../java/common/block/tech/BlockChest.java | 4 +- .../common/block/tech/BlockDispenser.java | 4 +- .../java/common/block/tech/BlockFurnace.java | 4 +- .../java/common/block/tech/BlockHopper.java | 4 +- .../java/common/block/tech/BlockJukebox.java | 30 --------- .../java/common/block/tech/BlockMachine.java | 4 +- .../java/common/block/tech/BlockNote.java | 44 ------------ .../common/block/tech/BlockRailDetector.java | 4 +- .../block/tech/BlockRedstoneComparator.java | 17 ++--- .../main/java/common/block/tech/BlockTNT.java | 23 ------- .../java/common/entity/npc/EntityNPC.java | 2 - .../entity/projectile/EntityBullet.java | 4 ++ .../entity/projectile/EntityMissile.java | 2 +- .../main/java/common/init/BlockRegistry.java | 8 +-- common/src/main/java/common/init/Blocks.java | 2 - .../java/common/init/CraftingRegistry.java | 2 - common/src/main/java/common/init/Items.java | 2 - .../java/common/inventory/ContainerChest.java | 2 +- .../tileentity/DeviceEffectGenerator.java | 15 +++-- .../common/tileentity/TileEntityChest.java | 4 +- .../src/main/java/common/world/Explosion.java | 7 +- common/src/main/java/common/world/World.java | 4 +- .../src/main/java/server/world/Converter.java | 4 +- 34 files changed, 109 insertions(+), 209 deletions(-) delete mode 100755 client/src/main/resources/textures/blocks/jukebox_side.png delete mode 100755 client/src/main/resources/textures/blocks/jukebox_top.png delete mode 100755 client/src/main/resources/textures/blocks/noteblock.png delete mode 100755 common/src/main/java/common/block/tech/BlockJukebox.java delete mode 100755 common/src/main/java/common/block/tech/BlockNote.java diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 460f2910..c30174c9 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -241,6 +241,12 @@ public class Client implements IThreadListener { } } + public static class ItemRedrawFunction implements BoolFunction { + public void apply(BoolVar cv, boolean value) { + Client.CLIENT.rescale(); + } + } + public static class LevelFunction implements EnumFunction { public void apply(EnumVar cv, LogLevel value) { Log.setLevel(value); @@ -440,9 +446,11 @@ public class Client implements IThreadListener { private int savedX = 0x80000000; @Variable(name = "win_pos_y", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster Y-Position") private int savedY = 0x80000000; - + @Variable(name = "gui_scale", category = CVarCategory.GUI, min = 1, max = 5, display = "Skalierung", unit = "x", callback = RedrawFunction.class) private int scaleVar = 2; + @Variable(name = "gui_scale_items", category = CVarCategory.GUI, display = "Gegenstände vergrößern", callback = ItemRedrawFunction.class) + public boolean scaleItems = true; @Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%") private float sensitivity = 1.0f; @Variable(name = "gui_dclick_delay", category = CVarCategory.INPUT, min = 150, max = 750, display = "Doppelklick bei", unit = "ms") @@ -1101,7 +1109,7 @@ public class Client implements IThreadListener { ItemStack itemstack = this.player.inventory.mainInventory[index]; if(itemstack != null) { GuiContainer.renderItemOverlay(itemstack, - this.fbX / 2 - 180 + 4 + 1 + index * 40, this.fbY - 40 + 1, null, index == this.player.inventory.currentItem ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax()); + this.fbX / 2 - 180 + 4 + 1 + index * 40, this.fbY - 40 + 1, null, index == this.player.inventory.currentItem ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), 2); } } } diff --git a/client/src/main/java/client/gui/container/GuiContainer.java b/client/src/main/java/client/gui/container/GuiContainer.java index bbd2581d..2b3e6120 100755 --- a/client/src/main/java/client/gui/container/GuiContainer.java +++ b/client/src/main/java/client/gui/container/GuiContainer.java @@ -10,6 +10,7 @@ import java.util.Map.Entry; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; +import client.Client; import client.gui.Font; import client.gui.Gui; import client.gui.element.ActButton; @@ -84,6 +85,7 @@ public abstract class GuiContainer extends Gui protected int container_y; protected int container_w; protected int container_h; + protected int container_scale; private int hover_x; private int hover_y; @@ -192,41 +194,41 @@ public abstract class GuiContainer extends Gui } public Label label(String text, int x, int y) { - x = x * 2 + this.container_x; - y = y * 2 + this.container_y; + x = x * this.container_scale + this.container_x; + y = y * this.container_scale + this.container_y; return this.add(new Label(x, y, 300, 0, text, true)); } public void rect(int x, int y, int width, int height, int color) { - Drawing.drawRect(this.container_x + x * 2, this.container_y + y * 2, width * 2, height * 2, 0xff000000 | color); + Drawing.drawRect(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, width * this.container_scale, height * this.container_scale, 0xff000000 | color); } public void grad(int x, int y, int width, int height, int top, int bottom, int topleft, int btmright) { - Drawing.drawGradient(this.container_x + x * 2, this.container_y + y * 2, width * 2, height * 2, 0xff000000 | top, 0xff000000 | bottom, 0xff000000 | topleft, 0xff000000 | btmright); + Drawing.drawGradient(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, width * this.container_scale, height * this.container_scale, 0xff000000 | top, 0xff000000 | bottom, 0xff000000 | topleft, 0xff000000 | btmright); } public InventoryButton slot(int x, int y, int w, int h) { - return this.add(new InventoryButton(this.container_x + x * 2, this.container_y + y * 2, w * 2, h * 2)); + return this.add(new InventoryButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale)); } public ActButton button(int x, int y, int w, int h, ButtonCallback callback, String text) { - return this.add(new ActButton(this.container_x + x * 2, this.container_y + y * 2, w * 2, h * 2, callback, text)); + return this.add(new ActButton(this.container_x + x * this.container_scale, this.container_y + y * this.container_scale, w * this.container_scale, h * this.container_scale, callback, text)); } public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) { super.mouse(btn, x, y, ctrl, shift); - this.mouseClicked((x - this.container_x) / 2, (y - this.container_y) / 2, btn.ordinal()); //TODO: enum + this.mouseClicked((x - this.container_x) / this.container_scale, (y - this.container_y) / this.container_scale, btn.ordinal()); //TODO: enum } public void mouserel(Button btn, int x, int y) { super.mouserel(btn, x, y); - this.mouseReleased((x - this.container_x) / 2, (y - this.container_y) / 2, btn.ordinal()); //TODO: enum + this.mouseReleased((x - this.container_x) / this.container_scale, (y - this.container_y) / this.container_scale, btn.ordinal()); //TODO: enum } public void drag(int x, int y) { super.drag(x, y); if(Button.MOUSE_LEFT.isDown() || Button.MOUSE_RIGHT.isDown() || Button.MOUSE_MIDDLE.isDown()) - this.mouseDragged((x - this.container_x) / 2, (y - this.container_y) / 2); + this.mouseDragged((x - this.container_x) / this.container_scale, (y - this.container_y) / this.container_scale); } public GuiContainer(Container container) @@ -239,8 +241,9 @@ public abstract class GuiContainer extends Gui this.itemRender = this.gm.getRenderItem(); this.tooltip = null; this.cheatStack = null; - this.container_x = (width - (this.container_w = (this.xSize * 2))) / 2; - this.container_y = (height - (this.container_h = (this.ySize * 2))) / 2; + this.container_scale = this.gm.scaleItems && this.xSize * 2 <= Client.MIN_WIDTH && this.ySize * 2 <= Client.MIN_HEIGHT ? 2 : 1; + this.container_x = (width - (this.container_w = (this.xSize * this.container_scale))) / 2; + this.container_y = (height - (this.container_h = (this.ySize * this.container_scale))) / 2; this.initGui(); this.addButtons(); this.addElements(); @@ -248,8 +251,8 @@ public abstract class GuiContainer extends Gui public void hover(String text, int x, int y) { this.tooltip = text; - this.hover_x = x * 2 + this.container_x + 16; - this.hover_y = y * 2 + this.container_y + 16; + this.hover_x = x * this.container_scale + this.container_x + 16; + this.hover_y = y * this.container_scale + this.container_y + 16; } public String getTitle() { @@ -302,8 +305,9 @@ public abstract class GuiContainer extends Gui if(this.gm.itemCheat) { GL11.glPushMatrix(); - GL11.glTranslatef(-(float)((this.gm.fbX - this.xSize * 2) / 2) * 0.5f, -(float)((this.gm.fbY - this.ySize * 2) / 2) * 0.5f, 0.0f); - GL11.glScalef(0.5f, 0.5f, 0.5f); + GL11.glTranslatef(-(float)((this.gm.fbX - this.xSize * this.container_scale) / 2) * (1.0f / (float)this.container_scale), -(float)((this.gm.fbY - this.ySize * this.container_scale) / 2) * (1.0f / (float)this.container_scale), 0.0f); + if(this.container_scale != 1) + GL11.glScalef(1.0f / (float)this.container_scale, 1.0f / (float)this.container_scale, 1.0f / (float)this.container_scale); int i = (ITEM_LIST.size() + this.cheatWidth - 1) / this.cheatWidth - this.cheatHeight; int j = (int)((double)(this.currentScroll * (float)i) + 0.5D); @@ -496,9 +500,10 @@ public abstract class GuiContainer extends Gui public void drawPost() { GL11.glPushMatrix(); - GL11.glTranslatef((float)((this.gm.fbX - this.xSize * 2) / 2), (float)((this.gm.fbY - this.ySize * 2) / 2), 0.0f); - GL11.glScalef(2.0f, 2.0f, 2.0f); - this.drawScreen((this.gm.mouseX - this.container_x) / 2, (this.gm.mouseY - this.container_y) / 2); + GL11.glTranslatef((float)((this.gm.fbX - this.xSize * this.container_scale) / 2), (float)((this.gm.fbY - this.ySize * this.container_scale) / 2), 0.0f); + if(this.container_scale != 1) + GL11.glScalef((float)this.container_scale, (float)this.container_scale, (float)this.container_scale); + this.drawScreen((this.gm.mouseX - this.container_x) / this.container_scale, (this.gm.mouseY - this.container_y) / this.container_scale); GL11.glPopMatrix(); ItemRenderer.disableStandardItemLighting(); } @@ -862,10 +867,10 @@ public abstract class GuiContainer extends Gui public void renderItemOverlayIntoGUI(ItemStack stack, int xPosition, int yPosition, String text) { - renderItemOverlay(stack, this.container_x + xPosition * 2, this.container_y + yPosition * 2, text, 0, 0); + renderItemOverlay(stack, this.container_x + xPosition * this.container_scale, this.container_y + yPosition * this.container_scale, text, 0, 0, this.container_scale); } - public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text, int bar2, int bar2max) + public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text, int bar2, int bar2max, int scale) { if (stack != null) { @@ -877,25 +882,25 @@ public abstract class GuiContainer extends Gui { s = TextColor.RED + formatAmount(stack.getSize()); } - Drawing.drawTextRight(s, xPosition + 32, yPosition + 33 - Font.YGLYPH, 0xffffffff); + Drawing.drawTextRight(s, xPosition + scale * 16, yPosition + scale * 16 + 1 - Font.YGLYPH, 0xffffffff); } if (stack.isItemDamaged()) { - int j = (int)Math.round(28.0D - (double)stack.getItemDamage() * 28.0D / (double)stack.getMaxDamage()); + int j = (int)Math.round(14.0D * (double)scale - (double)stack.getItemDamage() * (14.0D * (double)scale) / (double)stack.getMaxDamage()); int i = (int)Math.round(255.0D - (double)stack.getItemDamage() * 255.0D / (double)stack.getMaxDamage()); - draw(xPosition + 2, yPosition + 26, 28, 4, 0, 0, 0); - draw(xPosition + 2, yPosition + 26, 26, 2, (255 - i) / 4, 64, 0); - draw(xPosition + 2, yPosition + 26, j, 2, 255 - i, i, 0); + draw(xPosition + scale, yPosition + 13 * scale, 14 * scale, scale * 2, 0, 0, 0); + draw(xPosition + scale, yPosition + 13 * scale, 13 * scale, scale, (255 - i) / 4, 64, 0); + draw(xPosition + scale, yPosition + 13 * scale, j, scale, 255 - i, i, 0); } if (bar2 > 0) { - int j = (int)Math.round(28.0D - (double)bar2 * 28.0D / (double)bar2max); + int j = (int)Math.round(14.0D * (double)scale - (double)bar2 * (14.0D * (double)scale) / (double)bar2max); int i = (int)Math.round(255.0D - (double)bar2 * 255.0D / (double)bar2max); - draw(xPosition + 2, yPosition + 4, 28, 4, 0, 0, 0); - draw(xPosition + 2, yPosition + 4, 26, 2, (255 - i) / 8, (255 - i) / 16, i / 4); - draw(xPosition + 2 + 28 - j, yPosition + 4, j, 2, (255 - i) / 2, (255 - i) / 4, i); + draw(xPosition + scale, yPosition + scale * 2, 14 * scale, scale * 2, 0, 0, 0); + draw(xPosition + scale, yPosition + scale * 2, 13 * scale, scale, (255 - i) / 8, (255 - i) / 16, i / 4); + draw(xPosition + scale + 14 * scale - j, yPosition + scale * 2, j, scale, (255 - i) / 2, (255 - i) / 4, i); } } } diff --git a/client/src/main/java/client/gui/options/GuiStyle.java b/client/src/main/java/client/gui/options/GuiStyle.java index d38d6e2b..7a8808a7 100644 --- a/client/src/main/java/client/gui/options/GuiStyle.java +++ b/client/src/main/java/client/gui/options/GuiStyle.java @@ -76,6 +76,7 @@ public class GuiStyle extends GuiOptions { this.addSelector("gui_scale", 0, 3 * 34 + 20, 240, 0); this.addSelector("gui_font", 242, 3 * 34 + 20, 240, 0); + this.addSelector("gui_scale_items", 0, 3 * 34 + 40, 240, 0); super.init(width, height); } diff --git a/client/src/main/resources/textures/blocks/jukebox_side.png b/client/src/main/resources/textures/blocks/jukebox_side.png deleted file mode 100755 index a3c27c1899ec70358f3658f1f7b47c7dfbdf69d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 395 zcmV;60d)R}P)rIhjEz167lhJcPa1F3;CD~6p80?eT6;uVg+b4-FdYxQeCqo%!d-C%zl15QXnUC|HUS{Ev#)LI@I!*w_R?6cOxv0vkI?Qlu4$xPknv76bnltN=QA2fF{P8H90iGG`!)p#;593SDpE^kLGjNix#jfEti{`Aq(& zp*jd{bZbwJF{nNiO$+Fsz~2C}6^sA&oyPSHL;MBeAnMGGV~ySb0000rIhjEz167lhJcPa1F3;CD~6p80?eT6;uVg+b4-FdYxQeCqo%!d-C%zl list = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, bb); - for(EntityLiving entity : list) { - entity.addEffect(new StatusEffect(effect.getPotion(), 180, effect.getAmplifier())); + List list = this.worldObj.getEntitiesWithinAABB(EntityNPC.class, bb); + for(EntityNPC entity : list) { + if(!entity.hasEffect(effect.getPotion()) || entity.getEffect(effect.getPotion()).getAmplifier() < effect.getAmplifier() || entity.getEffect(effect.getPotion()).getRemaining() < 40) { + entity.addEffect(new StatusEffect(effect.getPotion(), 180, effect.getAmplifier())); + this.decrStackSize(1, effect.getAmplifier() + 1); + if(!this.hasAmount(1, effect.getAmplifier() + 1)) + break; + } } return true; } diff --git a/common/src/main/java/common/tileentity/TileEntityChest.java b/common/src/main/java/common/tileentity/TileEntityChest.java index 048cf7d9..555921e8 100755 --- a/common/src/main/java/common/tileentity/TileEntityChest.java +++ b/common/src/main/java/common/tileentity/TileEntityChest.java @@ -136,7 +136,7 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory for (int i = 0; i < nbttaglist.size(); ++i) { TagObject nbttagcompound = nbttaglist.get(i); - int j = nbttagcompound.getByte("Slot") & 255; + int j = nbttagcompound.getShort("Slot"); if (j >= 0 && j < this.chestContents.length) { @@ -157,7 +157,7 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory if (this.chestContents[i] != null) { TagObject nbttagcompound = new TagObject(); - nbttagcompound.setByte("Slot", (byte)i); + nbttagcompound.setShort("Slot", (short)i); this.chestContents[i].writeTags(nbttagcompound); nbttaglist.add(nbttagcompound); } diff --git a/common/src/main/java/common/world/Explosion.java b/common/src/main/java/common/world/Explosion.java index 4be79ef4..7e7c7eb7 100755 --- a/common/src/main/java/common/world/Explosion.java +++ b/common/src/main/java/common/world/Explosion.java @@ -13,6 +13,7 @@ import common.entity.DamageSource; import common.entity.Entity; import common.entity.item.EntityTnt; import common.entity.npc.EntityNPC; +import common.entity.projectile.EntityMissile; import common.entity.types.EntityLiving; import common.init.Blocks; import common.init.SoundEvent; @@ -355,12 +356,10 @@ public class Explosion return this.playerKnockbackMap; } - /** - * Returns either the entity that placed the explosive block, the entity that caused the explosion or null. - */ public EntityLiving getExplosivePlacedBy() { - return this.exploder == null ? null : (this.exploder instanceof EntityTnt ? ((EntityTnt)this.exploder).getTntPlacedBy() : (this.exploder instanceof EntityLiving ? (EntityLiving)this.exploder : null)); + return this.exploder == null ? null : (this.exploder instanceof EntityTnt ? ((EntityTnt)this.exploder).getTntPlacedBy() : + (this.exploder instanceof EntityMissile missile && missile.getShooter() instanceof EntityLiving shooter ? shooter :(this.exploder instanceof EntityLiving ? (EntityLiving)this.exploder : null))); } public void clearAffectedBlockPositions() diff --git a/common/src/main/java/common/world/World.java b/common/src/main/java/common/world/World.java index 39cb1070..dad7b6db 100755 --- a/common/src/main/java/common/world/World.java +++ b/common/src/main/java/common/world/World.java @@ -238,7 +238,7 @@ public abstract class World implements IWorldAccess { if(!this.client && (flags & 1) != 0) { this.notifyNeighborsOfStateChange(pos, iblockstate.getBlock()); - if(block.hasComparatorInputOverride()) { + if(block.hasSignalProcessing()) { this.updateComparatorOutputLevel(pos, block); } } @@ -1840,7 +1840,7 @@ public abstract class World implements IWorldAccess { return iblockstate.getBlock().getStrongPower(this, pos, iblockstate, direction); } - public int getStrongPower(BlockPos pos) { + private int getStrongPower(BlockPos pos) { int i = 0; i = Math.max(i, this.getStrongPower(pos.down(), Facing.DOWN)); diff --git a/server/src/main/java/server/world/Converter.java b/server/src/main/java/server/world/Converter.java index e04d6328..9ef07465 100644 --- a/server/src/main/java/server/world/Converter.java +++ b/server/src/main/java/server/world/Converter.java @@ -494,7 +494,7 @@ public abstract class Converter { mapBlock(Blocks.sandstone, 24); mapBlock(Blocks.carved_sandstone, 24, 1); mapBlock(Blocks.smooth_sandstone, 24, 2); - mapBlock(Blocks.noteblock, 25); + mapBlock(Blocks.spruce_planks, 25); mapBlock(Blocks.red_bed.getState().withProperty(BlockBed.FACING, Facing.SOUTH).withProperty(BlockBed.PART, EnumPartType.FOOT), 26, 0, 4); mapBlock(Blocks.red_bed.getState().withProperty(BlockBed.FACING, Facing.WEST).withProperty(BlockBed.PART, EnumPartType.FOOT), 26, 1, 5); mapBlock(Blocks.red_bed.getState().withProperty(BlockBed.FACING, Facing.NORTH).withProperty(BlockBed.PART, EnumPartType.FOOT), 26, 2, 6); @@ -841,7 +841,7 @@ public abstract class Converter { mapBlock(Blocks.reeds.getState().withProperty(BlockReed.AGE, 13), 83, 13); mapBlock(Blocks.reeds.getState().withProperty(BlockReed.AGE, 14), 83, 14); mapBlock(Blocks.reeds.getState().withProperty(BlockReed.AGE, 15), 83, 15); - mapBlock(Blocks.jukebox, 84); + mapBlock(Blocks.spruce_planks, 84); mapBlock(Blocks.oak_fence, 85); mapBlock(Blocks.pumpkin.getState().withProperty(BlockPumpkin.FACING, Facing.SOUTH), 86, 0, 4, 8, 12); mapBlock(Blocks.pumpkin.getState().withProperty(BlockPumpkin.FACING, Facing.WEST), 86, 1, 5, 9, 13);