add RUDIMENTARY displays

This commit is contained in:
Sen 2025-07-06 13:20:13 +02:00
parent f6b036b517
commit e18a151f6c
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
31 changed files with 795 additions and 483 deletions

View file

@ -960,7 +960,9 @@ public class Client implements IThreadListener {
public void renderHud() {
this.setupOverlay();
if(this.world != null && this.open == null && this.thirdPersonView == 0 && this.viewEntity != null) {
if(this.world != null && !(this.open instanceof GuiConsole) && this.player != null && this.viewEntity == this.player) {
if(this.open == null) {
if(this.thirdPersonView == 0) {
if(this.drawDebug) {
this.renderWorldDirections((float)this.tick_fraction);
}
@ -969,23 +971,20 @@ public class Client implements IThreadListener {
Drawing.drawRect(this.fb_x / 2 - this.crosshairSize, this.fb_y / 2 - 1, this.crosshairSize * 2, 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase);
}
}
if(this.world != null && this.open == null) {
int selected = // this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer() ? 9 : 0,
this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer() ?
((EntityNPC)this.getRenderViewEntity()).inventory.currentItem : -1;
int selected = this.player.inventory.currentItem;
for(int n = 0; n < 9; n++) {
int x = this.fb_x / 2 - 180 + n * 40 + 4;
int y = this.fb_y - 40;
// Drawing.drawRect2Border(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xffafafaf);
Drawing.drawRectBorder(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xff000000, 0xffafafaf, 0xff4f4f4f);
}
ItemStack itemstack = this.player != null ? this.player.inventory.getCurrentItem() : null;
ItemStack itemstack = this.player.inventory.getCurrentItem();
String current = itemstack != null ? itemstack.getItem().getHotbarText(this.player, itemstack) : "";
if(!current.isEmpty())
Drawing.drawTextUpward(current, this.fb_x / 2, this.fb_y - 60, 0xffffffff);
}
if(this.world != null && !(this.open instanceof GuiConsole)) {
int x = this.fb_x / 2;
int y = 0;
Iterator<Entry<Integer, Long>> iter = this.bars.entrySet().iterator();
@ -1011,7 +1010,7 @@ public class Client implements IThreadListener {
}
}
if(this.player != null && (!this.drawDebug || this.open != null)) {
if(!this.drawDebug || this.open != null) {
x = 40;
y = 40;
for(PotionEffect effect : this.player.getEffects()) {
@ -1028,8 +1027,7 @@ public class Client implements IThreadListener {
}
}
if(this.getRenderViewEntity() instanceof EntityLiving) {
EntityLiving entity = (EntityLiving)this.getRenderViewEntity();
EntityNPC entity = this.player;
int absorb = entity.getAbsorptionAmount();
int armor = entity.getTotalArmorValue();
int stats = 1 + (absorb > 0 ? 1 : 0) + (armor > 0 ? 1 : 0) + (entity.vehicle instanceof EntityLiving ? 1 : 0)
@ -1066,23 +1064,13 @@ public class Client implements IThreadListener {
y = stats(x, y, TextColor.LGRAY + type.display, energy, emax, entity.hasEnergyEffect(type) ? type.effect : type.color);
}
}
}
if(this.player != null) {
x = 40;
y = this.fb_y - 40 - (this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f ? 2 : 1) * 40;
if(this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f) // {
y = bar(x, y, String.format(TextColor.NEON + "Sprungkraft: " + TextColor.CYAN + "%d %%", (int)(this.player.getHorseJumpPower() * 100.0f)),
this.player.getHorseJumpPower(), 0x4040ff);
// }
// else {
y = bar(x, y, String.format(TextColor.ACID + "EXP: " + TextColor.GREEN + "Level %d, %d/%d", this.player.experienceLevel, (int)((float)this.player.xpBarCap() * this.player.experience), this.player.xpBarCap()), this.player.experience, 0x40ff40);
// }
}
// SKC.pointed(this.pointed != null && this.pointed.type != ObjectType.MISS);
// SKC.crosshair(this.thirdPersonView == 0);
}
// gdr.shader = 0;
@ -1098,8 +1086,7 @@ public class Client implements IThreadListener {
GlState.setActiveTexture(GL13.GL_TEXTURE0);
GlState.enableTexture2D();
// GlState.disableDepth();
if(this.open == null && this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer()) {
EntityNPC player = (EntityNPC)this.getRenderViewEntity();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
GlState.enableRescaleNormal();
GlState.enableBlend();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
@ -1113,7 +1100,7 @@ public class Client implements IThreadListener {
for(int index = 0; index < 9; ++index) {
int xPos = index * 20;
// int yPos = this.fb_y - 40;
ItemStack itemstack = player.inventory.mainInventory[index];
ItemStack itemstack = this.player.inventory.mainInventory[index];
if(itemstack != null) {
GlState.enableDepth();
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0);
@ -1135,10 +1122,9 @@ public class Client implements IThreadListener {
// java_check_exc();
GlState.disableDepth();
// SKC.foreground();
if(this.open == null && this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer()) {
EntityNPC player = (EntityNPC)this.getRenderViewEntity();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
for(int index = 0; index < 9; ++index) {
ItemStack itemstack = player.inventory.mainInventory[index];
ItemStack itemstack = this.player.inventory.mainInventory[index];
if(itemstack != null) {
GuiContainer.renderItemOverlay(itemstack,
this.fb_x / 2 - 180 + 4 + 1 + index * 40, this.fb_y - 40 + 1, null);
@ -1158,10 +1144,20 @@ public class Client implements IThreadListener {
this.drawOverlay(this.chat, this.chatSize, true, -1, this.fb_x, this.fb_y);
}
if(this.drawFps) { // && !(this.open instanceof GuiConsole)
if(this.drawDebug && this.open == null) {
if(this.drawDebug) {
if(this.open == null) {
this.renderStats();
this.renderLagometer();
}
else {
Drawing.drawText(String.format("%s%.2f" + TextColor.RESET + " %s [%s" + TextColor.RESET + "], %.3f ms, W %d x %d%s",
this.framecode(), this.framerate < 1.0f ? 1.0f / this.framerate : this.framerate, this.framerate < 1.0f ? "SPF" : "FPS",
this.vsync ? TextColor.DGRAY + "VSYNC" : (this.syncLimited ? TextColor.GREEN + "" + this.syncLimit : TextColor.RED + "UNL"),
(float)PerfSection.getTotal(false) / 1000.0f, this.fb_raw_x, this.fb_raw_y,
this.fullscreen ? " @ " + (this.vidMode == null ? "?" : this.vidMode.refresh()) + " Hz" : ""),
0, 0, 0xffffffff);
}
}
else {
Drawing.drawText(String.format("%s%.2f", framecode(), this.framerate), 0, 0, 0xffffffff);
}

View file

@ -115,6 +115,7 @@ import common.packet.SPacketSpawnObject;
import common.packet.SPacketSpawnPlayer;
import common.packet.SPacketTimeUpdate;
import common.packet.SPacketTrades;
import common.packet.SPacketUpdateDisplay;
import common.packet.SPacketUpdateHealth;
import common.packet.SPacketWorld;
import common.potion.PotionEffect;
@ -122,6 +123,7 @@ import common.rng.Random;
import common.sound.Sound;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDevice;
import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntitySign;
import common.village.MerchantRecipeList;
import common.world.Explosion;
@ -1314,6 +1316,20 @@ public class ClientPlayer implements IClientPlayer
// }
}
public void handleUpdateDisplay(SPacketUpdateDisplay packet) {
NetHandler.checkThread(packet, this, this.gm, this.world);
if(this.gm.world.isBlockLoaded(packet.getPos())) {
TileEntity tileentity = this.gm.world.getTileEntity(packet.getPos());
if(tileentity instanceof TileEntityDisplay display) {
System.arraycopy(packet.getPixels(), 0, display.data, 0, 256);
display.lastUpdated = System.currentTimeMillis();
display.markDirty();
}
}
}
/**
* Updates the metadata of instances of the following entitytypes: Mob spawners, command blocks,
* beacons, skulls, flowerpot

View file

@ -29,19 +29,6 @@ public abstract class Drawing {
}
}
// public static void drawTexturedModalRect(int tw, int th, int x, int y, int textureX, int textureY, int width, int height)
// {
// float xs = 1.0f / (float)tw; // 0.00390625F;
// float ys = 1.0f / (float)th; // 0.00390625F;
// RenderBuffer rb = Tessellator.getBuffer();
// rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
// rb.pos((double)(x + 0), (double)(y + height), 0.0).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + height) * ys)).endVertex();
// rb.pos((double)(x + width), (double)(y + height), 0.0).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + height) * ys)).endVertex();
// rb.pos((double)(x + width), (double)(y + 0), 0.0).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + 0) * ys)).endVertex();
// rb.pos((double)(x + 0), (double)(y + 0), 0.0).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + 0) * ys)).endVertex();
// Tessellator.draw();
// }
public static void txt_draw(int x, int y, int x1, int y1, int x2, int y2, int color, String str) {
GlState.enableTexture2D();
GlState.enableBlend();
@ -586,4 +573,29 @@ public abstract class Drawing {
GlState.disableTexture2D();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
public static void drawTexturedRect(Client gm, String texture, int texWidth, int texHeight, int x, int y, int u, int v, int width, int height)
{
GlState.enableTexture2D();
// GlState.disableFog();
RenderBuffer buf = Tessellator.getBuffer();
gm.getTextureManager().bindTexture(texture);
// GlState.color(color);
float xs = 1.0f / (float)texWidth; // 0.00390625F;
float ys = 1.0f / (float)texHeight; // 0.00390625F;
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
buf.pos((double)(x + 0), (double)(y + height), 0.0).tex((double)((float)(u + 0) * xs), (double)((float)(v + height) * ys)).endVertex();
buf.pos((double)(x + width), (double)(y + height), 0.0).tex((double)((float)(u + width) * xs), (double)((float)(v + height) * ys)).endVertex();
buf.pos((double)(x + width), (double)(y + 0), 0.0).tex((double)((float)(u + width) * xs), (double)((float)(v + 0) * ys)).endVertex();
buf.pos((double)(x + 0), (double)(y + 0), 0.0).tex((double)((float)(u + 0) * xs), (double)((float)(v + 0) * ys)).endVertex();
// double scale = 32.0;
// buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
// buf.pos((double)x, (double)y + (double)height, 0.0D).tex(0.0D, (double)height / scale).endVertex();
// buf.pos((double)x + (double)width, (double)y + (double)height, 0.0D).tex((double)width / scale, (double)height / scale).endVertex();
// buf.pos((double)x + (double)width, (double)y, 0.0D).tex((double)width / scale, 0.0).endVertex();
// buf.pos((double)x, (double)y, 0.0D).tex(0.0D, 0.0).endVertex();
Tessellator.draw();
// GlState.disableTexture2D();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
}

View file

@ -20,14 +20,20 @@ import common.util.BlockPos;
import common.util.ExtMath;
import common.world.State;
public class TileEntityBannerRenderer extends TileEntitySpecialRenderer<TileEntityBanner>
{
private static final Map<String, TileEntityBannerRenderer.TimedBannerTexture> DESIGNS = Maps.<String, TileEntityBannerRenderer.TimedBannerTexture>newHashMap();
public class TileEntityBannerRenderer extends TileEntitySpecialRenderer<TileEntityBanner> {
private static class TimedTexture {
public long time;
public String texture;
private TimedTexture() {
}
}
private static final Map<String, TimedTexture> DESIGNS = Maps.<String, TimedTexture>newHashMap();
private static final String BANNERTEXTURES = "textures/blocks/banner.png";
private ModelBanner bannerModel = new ModelBanner();
public void renderTileEntityAt(TileEntityBanner te, double x, double y, double z, float partialTicks, int destroyStage)
{
public void renderTileEntityAt(TileEntityBanner te, double x, double y, double z, float partialTicks, int destroyStage) {
boolean flag = te.getWorld() != null;
boolean flag1 = !flag || te.getBlockType() == Blocks.banner;
int i = 0;
@ -41,29 +47,24 @@ public class TileEntityBannerRenderer extends TileEntitySpecialRenderer<TileEnti
GL11.glPushMatrix();
float f = 0.6666667F;
if (flag1)
{
if(flag1) {
GL11.glTranslatef((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
float f1 = (float)(i * 360) / 16.0F;
GL11.glRotatef(-f1, 0.0F, 1.0F, 0.0F);
this.bannerModel.bannerStand.showModel = true;
}
else
{
else {
float f2 = 0.0F;
if (i == 2)
{
if(i == 2) {
f2 = 180.0F;
}
if (i == 4)
{
if(i == 4) {
f2 = 90.0F;
}
if (i == 5)
{
if(i == 5) {
f2 = -90.0F;
}
@ -77,10 +78,9 @@ public class TileEntityBannerRenderer extends TileEntitySpecialRenderer<TileEnti
float f3 = (float)(blockpos.getX() * 7 + blockpos.getY() * 9 + blockpos.getZ() * 13) + (float)j; // + partialTicks;
this.bannerModel.bannerSlate.rotateAngleX = (-0.0125F + 0.01F * ExtMath.cos(f3 * (float)Math.PI * 0.02F)) * (float)Math.PI;
GlState.enableRescaleNormal();
String resourcelocation = this.func_178463_a(te);
String resourcelocation = this.getTexture(te);
if (resourcelocation != null)
{
if(resourcelocation != null) {
this.bindTexture(resourcelocation);
GL11.glPushMatrix();
GL11.glScalef(f, -f, -f);
@ -92,70 +92,51 @@ public class TileEntityBannerRenderer extends TileEntitySpecialRenderer<TileEnti
GL11.glPopMatrix();
}
private String func_178463_a(TileEntityBanner bannerObj)
{
String s = bannerObj.getPatternResourceLocation();
private String getTexture(TileEntityBanner te) {
String s = te.getPatternResourceLocation();
if (s.isEmpty())
{
if(s.isEmpty()) {
return null;
}
else
{
TileEntityBannerRenderer.TimedBannerTexture tileentitybannerrenderer$timedbannertexture = (TileEntityBannerRenderer.TimedBannerTexture)DESIGNS.get(s);
else {
TimedTexture tex = (TimedTexture)DESIGNS.get(s);
if (tileentitybannerrenderer$timedbannertexture == null)
{
if (DESIGNS.size() >= 256)
{
if(tex == null) {
if(DESIGNS.size() >= 256) {
long i = System.currentTimeMillis();
Iterator<String> iterator = DESIGNS.keySet().iterator();
while (iterator.hasNext())
{
while(iterator.hasNext()) {
String s1 = (String)iterator.next();
TileEntityBannerRenderer.TimedBannerTexture tileentitybannerrenderer$timedbannertexture1 = (TileEntityBannerRenderer.TimedBannerTexture)DESIGNS.get(s1);
TimedTexture tileentitybannerrenderer$timedbannertexture1 = (TimedTexture)DESIGNS.get(s1);
if (i - tileentitybannerrenderer$timedbannertexture1.systemTime > 60000L)
{
Client.CLIENT.getTextureManager().deleteTexture(tileentitybannerrenderer$timedbannertexture1.bannerTexture);
if(i - tileentitybannerrenderer$timedbannertexture1.time > 60000L) {
Client.CLIENT.getTextureManager().deleteTexture(tileentitybannerrenderer$timedbannertexture1.texture);
iterator.remove();
}
}
if (DESIGNS.size() >= 256)
{
if(DESIGNS.size() >= 256) {
return null;
}
}
List<TileEntityBanner.EnumBannerPattern> list1 = bannerObj.getPatternList();
List<DyeColor> list = bannerObj.getColorList();
List<TileEntityBanner.EnumBannerPattern> list1 = te.getPatternList();
List<DyeColor> list = te.getColorList();
List<String> list2 = Lists.<String>newArrayList();
for (TileEntityBanner.EnumBannerPattern tileentitybanner$enumbannerpattern : list1)
{
for(TileEntityBanner.EnumBannerPattern tileentitybanner$enumbannerpattern : list1) {
list2.add("textures/blocks/banner_" + tileentitybanner$enumbannerpattern.getPatternName() + ".png");
}
tileentitybannerrenderer$timedbannertexture = new TileEntityBannerRenderer.TimedBannerTexture();
tileentitybannerrenderer$timedbannertexture.bannerTexture = s;
Client.CLIENT.getTextureManager().loadTexture(tileentitybannerrenderer$timedbannertexture.bannerTexture, new LayeredColorMaskTexture(BANNERTEXTURES, list2, list));
DESIGNS.put(s, tileentitybannerrenderer$timedbannertexture);
tex = new TimedTexture();
tex.texture = s;
Client.CLIENT.getTextureManager().loadTexture(tex.texture, new LayeredColorMaskTexture(BANNERTEXTURES, list2, list));
DESIGNS.put(s, tex);
}
tileentitybannerrenderer$timedbannertexture.systemTime = System.currentTimeMillis();
return tileentitybannerrenderer$timedbannertexture.bannerTexture;
}
}
static class TimedBannerTexture
{
public long systemTime;
public String bannerTexture;
private TimedBannerTexture()
{
tex.time = System.currentTimeMillis();
return tex.texture;
}
}
}

View file

@ -0,0 +1,104 @@
package client.renderer.tileentity;
import java.util.Iterator;
import java.util.Map;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.Drawing;
import client.renderer.GlState;
import client.renderer.texture.DynamicTexture;
import common.block.Block;
import common.block.tech.BlockDisplay;
import common.collect.Maps;
import common.tileentity.TileEntityDisplay;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
public class TileEntityDisplayRenderer extends TileEntitySpecialRenderer<TileEntityDisplay> {
private static class TimedTexture {
public long time;
public long updated;
public String texture;
}
private static final Map<String, TimedTexture> DISPLAYS = Maps.<String, TimedTexture>newHashMap();
private static String getTextureLocation(BlockPos pos) {
return "display/" + pos.getX() + "," + pos.getY() + "," + pos.getZ();
}
private static String getTexture(TileEntityDisplay te) {
String id = getTextureLocation(te.getPos());
TimedTexture tex = DISPLAYS.get(id);
if(tex == null) {
if(DISPLAYS.size() >= 256) {
long i = System.currentTimeMillis();
Iterator<String> iterator = DISPLAYS.keySet().iterator();
while(iterator.hasNext()) {
String oid = iterator.next();
TimedTexture ttex = DISPLAYS.get(oid);
if(i - ttex.time > 60000L) {
Client.CLIENT.getTextureManager().deleteTexture(ttex.texture);
iterator.remove();
}
}
if(DISPLAYS.size() >= 256) {
return null;
}
}
tex = new TimedTexture();
tex.texture = id;
tex.updated = te.lastUpdated;
DynamicTexture dtex = new DynamicTexture(16, 16);
System.arraycopy(te.data, 0, dtex.getData(), 0, 256);
dtex.updateTexture();
Client.CLIENT.getTextureManager().loadTexture(tex.texture, dtex);
DISPLAYS.put(id, tex);
}
else if(te.lastUpdated != tex.updated) {
tex.updated = te.lastUpdated;
if(Client.CLIENT.getTextureManager().getTexture(tex.texture) instanceof DynamicTexture dtex) {
System.arraycopy(te.data, 0, dtex.getData(), 0, 256);
dtex.updateTexture();
}
}
tex.time = System.currentTimeMillis();
return tex.texture;
}
public void renderTileEntityAt(TileEntityDisplay te, double x, double y, double z, float partialTicks, int destroyStage) {
Block block = te.getBlockType();
State state = te.getBlockState();
Facing dir = state.getBlock() instanceof BlockDisplay ? state.getValue(BlockDisplay.FACING) : Facing.SOUTH;
float rot = 0.0F;
if(dir == Facing.NORTH)
rot = 180.0F;
else if(dir == Facing.WEST)
rot = 90.0F;
else if(dir == Facing.EAST)
rot = -90.0F;
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.0f, (float)z + 0.5F);
GL11.glRotatef(-rot, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, 0.0f, -0.5f + 0.0625f + 0.005f);
GL11.glScalef(0.0625f, -0.0625f, 0.0625f);
GlState.disableLighting();
Drawing.drawTexturedRect(Client.CLIENT, getTexture(te), 16, 16, 0, 0, 0, 0, 16, 16);
GlState.enableLighting();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
}

View file

@ -11,6 +11,7 @@ import common.entity.Entity;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityBanner;
import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntityPiston;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
@ -46,6 +47,7 @@ public class TileEntityRendererDispatcher
private TileEntityRendererDispatcher()
{
this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
this.mapSpecialRenderers.put(TileEntityDisplay.class, new TileEntityDisplayRenderer());
this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());

View file

@ -13,7 +13,7 @@ public abstract class BlockContainer extends Block implements ITileEntityProvide
this.hasTile = true;
}
protected boolean isInvalidNeighbor(World world, BlockPos pos, Facing face) {
private boolean isInvalidNeighbor(World world, BlockPos pos, Facing face) {
return world.getState(pos.offset(face)).getBlock().getMaterial() == Material.BLOCKING;
}

View file

@ -0,0 +1,153 @@
package common.block.tech;
import common.block.BlockContainer;
import common.block.Material;
import common.block.Rotatable;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDisplay;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockDisplay extends BlockContainer implements Rotatable
{
public BlockDisplay()
{
super(Material.SOLID);
float f = 0.25F;
float f1 = 1.0F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.TECHNOLOGY);
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
State iblockstate = worldIn.getState(pos);
if (iblockstate.getBlock() == this)
{
float f = 0.0625F;
switch (iblockstate.getValue(FACING))
{
case NORTH:
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
break;
case SOUTH:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
break;
case WEST:
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case EAST:
default:
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
}
}
protected Property[] getProperties()
{
return new Property[] {FACING};
}
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getCollisionBoundingBox(worldIn, pos, state);
}
public BoundingBox getSelectedBoundingBox(World worldIn, BlockPos pos)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getSelectedBoundingBox(worldIn, pos);
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* Return true if an entity can be spawned inside the block (used to get the player's bed spawn location)
*/
public boolean canSpawnInBlock()
{
return true;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn)
{
return new TileEntityDisplay();
}
public boolean isXrayVisible()
{
return true;
}
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {
return this.getState().withProperty(FACING, facing.getAxis().isVertical() ? placer.getHorizontalFacing() : facing);
}
public int getRenderType() {
return 3;
}
public boolean shouldSideBeRendered(IWorldAccess worldIn, BlockPos pos, Facing side)
{
return true;
}
//
// public Transforms getTransform() {
// return Transforms.LAYER;
// }
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("iron_block").add(0, 0, 15, 16, 16, 16).n().noCull().s().du().we().rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if (!worldIn.client)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityDisplay display)
{
display.setPixel(1, 12, 0xff0000);
display.setPixel(2, 12, 0x00ff00);
display.setPixel(3, 12, 0x0000ff);
display.markDirty();
worldIn.markBlockForUpdate(pos);
}
}
return true;
}
}

View file

@ -8,6 +8,7 @@ import common.model.ParticleType;
import common.tags.TagObject;
import common.util.ExtMath;
import common.world.AWorldClient;
import common.world.AWorldServer;
import common.world.World;
public class EntityFireworks extends Entity
@ -143,6 +144,7 @@ public class EntityFireworks extends Entity
{
this.worldObj.setEntityState(this, (byte)17);
this.setDead();
this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 3.0f, false, false, false);
}
}

View file

@ -12,124 +12,104 @@ import common.rng.Random;
import common.util.BlockPos;
import common.world.World;
public class EntityArachnoid extends EntityNPC
{
public EntityArachnoid(World worldIn)
{
super(worldIn);
// this.setSize(1.4F, 1.6F);
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
// this.tasks.addTask(4, new AISpiderAttack(this, EntityNPC.class));
this.tasks.addTask(4, new AISpiderAttack(this, EntityNPC.class));
// this.targets.addTask(2, new EntitySpider.AISpiderTarget(this, EntityNPC.class));
// this.targets.addTask(3, new EntitySpider.AISpiderTarget(this, EntityNPC.class));
public class EntityArachnoid extends EntityNPC {
static class AISpiderAttack extends EntityAIAttackOnCollide {
public AISpiderAttack(EntityArachnoid spider, Class<? extends Entity> targetClass) {
super(spider, targetClass, 1.0D, true);
}
// public double getMountedYOffset()
// {
// return (double)(this.height * 0.5F);
// }
public boolean continueExecuting() {
float f = this.attacker.getBrightness(1.0F);
// public float getRenderScale()
// {
// return 0.9375f * this.height / 1.6f;
// }
if(f >= 0.5F && this.attacker.getRNG().chance(100)) {
this.attacker.setAttackTarget((EntityLiving)null);
return false;
}
else {
return super.continueExecuting();
}
}
protected PathNavigate getNewNavigator(World worldIn)
{
protected double getAttackRange(EntityLiving attackTarget) {
return (double)(4.0F + attackTarget.width);
}
}
public static class GroupData {
public Potion potionEffectId;
public boolean isChild;
public GroupData(boolean isChild) {
this.isChild = isChild;
}
public void pickEffect(Random rand) {
this.potionEffectId = rand.pick(Potion.SPEED, Potion.SPEED, Potion.STRENGTH, Potion.REGENERATION);
}
}
public EntityArachnoid(World worldIn) {
super(worldIn);
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(4, new AISpiderAttack(this, EntityNPC.class));
}
protected PathNavigate getNewNavigator(World worldIn) {
return new PathNavigateClimber(this, worldIn);
}
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataWatcher.addObject(23, (byte)0);
}
public void onUpdate()
{
public void onUpdate() {
super.onUpdate();
if (!this.worldObj.client)
{
if(!this.worldObj.client) {
this.setBesideClimbableBlock(this.collidedHorizontally);
}
}
// protected void applyEntityAttributes()
// {
// super.applyEntityAttributes();
// this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D);
// }
// protected String getLivingSound()
// {
// return "mob.spider.say";
// }
public boolean isOnLadder()
{
public boolean isOnLadder() {
return super.isOnLadder() || (this.client != null ? this.collidedHorizontally && !this.noclip : this.isBesideClimbableBlock());
}
public void setInWeb()
{
public void setInWeb() {
}
public boolean isBesideClimbableBlock()
{
public boolean isBesideClimbableBlock() {
return (!this.isPlayer() || !this.noclip) && this.dataWatcher.getWatchableObjectByte(23) != 0;
}
public void setBesideClimbableBlock(boolean climb)
{
public void setBesideClimbableBlock(boolean climb) {
this.dataWatcher.updateObject(23, (byte)(climb ? 1 : 0));
}
public Object onInitialSpawn(Object livingdata)
{
public Object onInitialSpawn(Object livingdata) {
livingdata = super.onInitialSpawn(livingdata);
// if(!this.isChild()) {
// if (this.worldObj.rand.chance(100))
// {
// EntityUndead entityskeleton = new EntityUndead(this.worldObj);
// entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotYaw, 0.0F);
// entityskeleton.onInitialSpawn(difficulty, (IEntityLivingData)null);
// this.worldObj.spawnEntityInWorld(entityskeleton);
// entityskeleton.mountEntity(this);
// }
if (livingdata == null && !this.isPlayer())
{
if(livingdata == null && !this.isPlayer()) {
livingdata = new EntityArachnoid.GroupData(this.worldObj.rand.chance(40));
if (/* this.worldObj.getDifficulty() == Difficulty.HARD && */ this.worldObj.rand.chance())
{
if(this.worldObj.rand.chance()) {
((EntityArachnoid.GroupData)livingdata).pickEffect(this.worldObj.rand);
}
}
if (livingdata instanceof EntityArachnoid.GroupData)
{
if(livingdata instanceof EntityArachnoid.GroupData) {
Potion i = ((EntityArachnoid.GroupData)livingdata).potionEffectId;
if (i != null)
{
if(i != null) {
this.addEffect(new PotionEffect(i, Integer.MAX_VALUE, 0));
}
if(((EntityArachnoid.GroupData)livingdata).isChild)
this.setGrowingAge(-24000);
}
// }
return livingdata;
}
// public float getEyeHeight()
// {
// return super.getEyeHeight() * 0.85f;
// }
public boolean isSneakingVisually() {
return false;
}
@ -138,88 +118,10 @@ public class EntityArachnoid extends EntityNPC
return 0xc63ba0;
}
static class AISpiderAttack extends EntityAIAttackOnCollide
{
public AISpiderAttack(EntityArachnoid spider, Class <? extends Entity > targetClass)
{
super(spider, targetClass, 1.0D, true);
}
public boolean continueExecuting()
{
float f = this.attacker.getBrightness(1.0F);
if (f >= 0.5F && this.attacker.getRNG().chance(100))
{
this.attacker.setAttackTarget((EntityLiving)null);
return false;
}
else
{
return super.continueExecuting();
}
}
protected double getAttackRange(EntityLiving attackTarget)
{
return (double)(4.0F + attackTarget.width);
}
}
// static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget
// {
// public AISpiderTarget(EntitySpider spider, Class<T> classTarget)
// {
// super(spider, classTarget, true);
// }
//
// public boolean shouldExecute()
// {
// float f = this.taskOwner.getBrightness(1.0F);
// return f >= 0.5F ? false : super.shouldExecute();
// }
// }
// public boolean isAggressive() {
// return this.getBrightness(1.0f) < 0.5f;
// }
//
// public boolean isPeaceful() {
// return false;
// }
// public boolean isAggressive(Class<? extends EntityNPC> clazz) {
// return false;
// }
//
// public boolean isPeaceful(Class<? extends EntityNPC> clazz) {
// return false;
// }
// public boolean canInfight(Alignment align) {
// return true;
// }
//
// public boolean canMurder(Alignment align) {
// return false;
// }
// public boolean canUseMagic() {
// return false;
// }
public int getBaseHealth(Random rand) {
return rand.range(16, 24);
}
// public int getBaseEnergy(Random rand) {
// return 0;
// }
// public float getHeightDeviation(Random rand) {
// return rand.frange(0.0f, 0.25f);
// }
public float getHeightDeviationMax() {
return 0.25f;
}
@ -228,16 +130,19 @@ public class EntityArachnoid extends EntityNPC
return rand.pick(Alignment.LAWFUL_EVIL, Alignment.EVIL, Alignment.LAWFUL, Alignment.NEUTRAL);
}
public boolean attackEntityAsMob(Entity entityIn)
{
public boolean attackEntityAsMob(Entity entityIn) {
if(super.attackEntityAsMob(entityIn)) {
if(entityIn instanceof EntityLiving && this.rand.chance(50))
if(this.isPoisonous() && entityIn instanceof EntityLiving && this.rand.chance(50))
((EntityLiving)entityIn).addEffect(new PotionEffect(Potion.POISON, this.rand.range(14, 35) * 20, 0));
return true;
}
return false;
}
public boolean isPoisonous() {
return true;
}
public boolean getCanSpawnHere() {
return this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8);
}
@ -253,19 +158,4 @@ public class EntityArachnoid extends EntityNPC
public float getSpeciesBaseSize() {
return 1.6f;
}
public static class GroupData
{
public Potion potionEffectId;
public boolean isChild;
public GroupData(boolean isChild) {
this.isChild = isChild;
}
public void pickEffect(Random rand)
{
this.potionEffectId = rand.pick(Potion.SPEED, Potion.SPEED, Potion.STRENGTH, Potion.REGENERATION);
}
}
}

View file

@ -4314,10 +4314,10 @@ public abstract class EntityNPC extends EntityLiving
}
public Object onInitialSpawn(Object livingdata) {
// if(this.isPlayer()) {
// this.setCustomNameTag(this.pickRandomName(this.rand, null));
// return livingdata;
// }
return this.initializeBase(livingdata);
}
protected Object initializeBase(Object livingdata) {
livingdata = super.onInitialSpawn(livingdata);
CharacterInfo info = (livingdata instanceof CharacterTypeData) ? ((CharacterTypeData)livingdata).character :
this.species.pickCharacter(this.worldObj.rand);

View file

@ -0,0 +1,52 @@
package common.entity.npc;
import common.entity.types.EntityLiving;
import common.rng.Random;
import common.world.World;
public class EntityTinyArachnoid extends EntityArachnoid {
public EntityTinyArachnoid(World worldIn) {
super(worldIn);
}
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.setAttackDamageBase(1);
}
public Object onInitialSpawn(Object livingdata) {
return this.initializeBase(livingdata);
}
public int getBaseHealth(Random rand) {
return rand.range(1, 3);
}
public float getHeightDeviationMax() {
return 0.05f;
}
public Alignment getNaturalAlign() {
return rand.pick(Alignment.LAWFUL_EVIL, Alignment.LAWFUL, Alignment.NEUTRAL);
}
public boolean getCanSpawnHere() {
return true;
}
public boolean canAmbush(EntityLiving entity) {
return true;
}
public boolean canUseMagic() {
return false;
}
public float getSpeciesBaseSize() {
return 0.25f;
}
public boolean isPoisonous() {
return false;
}
}

View file

@ -101,6 +101,7 @@ import common.block.tech.BlockChest;
import common.block.tech.BlockCore;
import common.block.tech.BlockDaylightDetector;
import common.block.tech.BlockDispenser;
import common.block.tech.BlockDisplay;
import common.block.tech.BlockDropper;
import common.block.tech.BlockEnchantmentTable;
import common.block.tech.BlockFurnace;
@ -461,6 +462,7 @@ public abstract class BlockRegistry {
.setTab(CheatTab.DECORATION));
register("sign", (new BlockStandingSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild"));
register("wall_sign", (new BlockWallSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild"));
register("display", (new BlockDisplay()).setHardness(1.0F).setStepSound(SoundType.STONE).setDisplay("Anzeige"));
register("banner", (new BlockBannerStanding()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));
register("wall_banner", (new BlockBannerHanging()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));

View file

@ -591,6 +591,7 @@ public abstract class Blocks {
public static final BlockStairs floor_tiles_white_stairs = get("floor_tiles_white_stairs");
public static final BlockSlab pentagram_slab = get("pentagram_slab");
public static final BlockStairs pentagram_stairs = get("pentagram_stairs");
public static final BlockDisplay display = get("display");
private static <T extends Block> T get(String id) {
T block = (T)BlockRegistry.byNameExact(id);

View file

@ -216,7 +216,7 @@ public abstract class ItemRegistry {
register("camera", (new ItemCamera()).setDisplay("Kamera").setTab(CheatTab.TOOLS));
for(Weather weather : Weather.values()) {
register("weather_token_" + weather.getName(), new ItemWeatherToken(weather).setDisplay("Wetterkristall").setTab(CheatTab.TOOLS));
register("weather_token_" + weather.getName(), new ItemWeatherToken(weather).setDisplay("Wetterkristall").setTab(CheatTab.MAGIC));
}
register("flint_and_steel", (new ItemFlintAndSteel(Blocks.fire)).setDisplay("Feuerzeug"));
@ -279,7 +279,7 @@ public abstract class ItemRegistry {
register("chicken", (new ItemFood(2, true)).setDisplay("Rohes Hühnchen"));
register("cooked_chicken", (new ItemFood(6, true)).setDisplay("Gebratenes Hühnchen"));
register("rotten_flesh", (new ItemFood(4, true)).setDisplay("Verrottetes Fleisch"));
register("orb", (new ItemFragile()).setDisplay("Kugel").setTab(CheatTab.TOOLS));
register("orb", (new ItemFragile()).setDisplay("Kugel").setTab(CheatTab.MAGIC));
register("blaze_rod", (new ItemRod()).setDisplay("Lohenrute").setTab(CheatTab.MATERIALS).setMaxAmount(256));
register("tear", (new ItemTiny()).setDisplay("Träne").setPotionEffect(PotionHelper.tearEffect).setTab(CheatTab.MATERIALS).setMaxAmount(256));
register("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(256));
@ -311,9 +311,9 @@ public abstract class ItemRegistry {
register("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute"));
register("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.MISC).setColor(TextColor.DMAGENTA));
register("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.FOOD));
register("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete").setTab(CheatTab.TOOLS));
register("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete").setTab(CheatTab.EXPLOSIVES));
register("firework_charge", (new ItemFireworkCharge()).setDisplay("Feuerwerksstern").setTab(CheatTab.MATERIALS));
register("enchanted_book", (new ItemEnchantedBook()).setMaxAmount(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.MAGIC));
register("enchanted_book", (new ItemEnchantedBook()).setMaxAmount(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.ENCHANTMENTS));
register("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS));
register("blackbrick", (new Item()).setDisplay("Schwarzer Ziegel").setTab(CheatTab.MATERIALS));
Item quartz = (new Item()).setDisplay("Quarz").setTab(CheatTab.METALS);

View file

@ -972,6 +972,7 @@ public abstract class Items {
public static final ItemBlock floor_tiles_white_stairs = get("floor_tiles_white_stairs");
public static final ItemSlab pentagram_slab = get("pentagram_slab");
public static final ItemBlock pentagram_stairs = get("pentagram_stairs");
public static final ItemBlock display = get("display");
private static <T extends Item> T get(String id) {
T item = (T)ItemRegistry.byName(id);

View file

@ -30,6 +30,7 @@ import common.entity.npc.EntitySlime;
import common.entity.npc.EntitySpaceMarine;
import common.entity.npc.EntitySpirit;
import common.entity.npc.EntityTiefling;
import common.entity.npc.EntityTinyArachnoid;
import common.entity.npc.EntityUndead;
import common.entity.npc.EntityVampire;
import common.entity.npc.EntityWoodElf;
@ -117,6 +118,7 @@ public abstract class SpeciesRegistry {
registerSpecies("Undead", EntityUndead.class, "terra", "Untoter", 0xc1c1c1, 0x494949, ":undead_1", ":undead_2", ":undead_3",
":undead_4");
registerSpecies("Arachnoid", EntityArachnoid.class, "tbd", "Arachnoidea", ModelType.ARACHNOID, 0x342d27, 0xa80e0e);
registerSpecies("TinyArachnoid", EntityTinyArachnoid.class, "tbd", "Kleiner Arachnoidea", ModelType.ARACHNOID, 0x142d27, 0x780e0e);
registerSpecies("Mage", EntityMage.class, "terra", "Magier", 0x340000, 0x51a03e, ":mage_1", ":mage_2", ":mage_3",
":mage_4", ":mage_5", ":mage_6");
registerSpecies("Gargoyle", EntityGargoyle.class, "tbd", "Gargoyle", 0x401010, 0x534437);

View file

@ -11,6 +11,7 @@ import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityComparator;
import common.tileentity.TileEntityDaylightDetector;
import common.tileentity.TileEntityDispenser;
import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntityDropper;
import common.tileentity.TileEntityEnchantmentTable;
import common.tileentity.TileEntityFurnace;
@ -41,6 +42,7 @@ public abstract class TileRegistry {
addMapping(TileEntityDispenser.class, "Trap");
addMapping(TileEntityDropper.class, "Dropper");
addMapping(TileEntitySign.class, "Sign");
addMapping(TileEntityDisplay.class, "Display");
addMapping(TileEntityPiston.class, "Piston");
addMapping(TileEntityBrewingStand.class, "Cauldron");
addMapping(TileEntityEnchantmentTable.class, "EnchantTable");

View file

@ -97,11 +97,21 @@ public enum CheatTab {
return Items.potion;
}
},
MAGIC("Verzauberungen", false) {
ENCHANTMENTS("Verzauberungen", false) {
protected Item getIconItem() {
return Items.enchanted_book;
}
},
MAGIC("Magie", false) {
protected Item getIconItem() {
return Items.charged_orb;
}
},
EXPLOSIVES("Sprengstoff", false) {
protected Item getIconItem() {
return Items.dynamite;
}
},
MATERIALS("Werkstoffe", false) {
protected Item getIconItem() {
return Items.leather;

View file

@ -2,6 +2,7 @@ package common.item.spawner;
import common.block.tech.BlockRailBase;
import common.entity.item.EntityCart;
import common.entity.item.EntityCart.EnumMinecartType;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.item.CheatTab;
@ -22,7 +23,7 @@ public class ItemMinecart extends Item
{
this.setMaxAmount(1);
this.minecartType = type;
this.setTab(CheatTab.VEHICLES);
this.setTab(type == EnumMinecartType.TNT ? CheatTab.EXPLOSIVES : CheatTab.VEHICLES);
// if(type != EntityMinecart.EnumMinecartType.COMMAND_BLOCK)
}

View file

@ -20,7 +20,7 @@ public class ItemChargedOrb extends ItemFragile
{
public ItemChargedOrb()
{
this.setTab(CheatTab.TOOLS);
this.setTab(CheatTab.MAGIC);
this.setMaxDamage(16);
this.setColor(TextColor.DMAGENTA);
}

View file

@ -25,7 +25,7 @@ public class ItemDynamite extends Item {
public ItemDynamite(int power) {
this.power = power;
this.setMaxAmount(32);
this.setTab(CheatTab.TOOLS);
this.setTab(CheatTab.EXPLOSIVES);
DYNAMITE[power] = this;
}

View file

@ -16,7 +16,7 @@ public class ItemExpBottle extends Item
{
public ItemExpBottle()
{
this.setTab(CheatTab.TOOLS);
this.setTab(CheatTab.MAGIC);
}
public boolean hasEffect(ItemStack stack)

View file

@ -61,6 +61,7 @@ import common.packet.SPacketSpawnObject;
import common.packet.SPacketSpawnPlayer;
import common.packet.SPacketTimeUpdate;
import common.packet.SPacketTrades;
import common.packet.SPacketUpdateDisplay;
import common.packet.SPacketUpdateHealth;
import common.packet.SPacketWorld;
import common.sound.Sound;
@ -115,6 +116,7 @@ public interface IClientPlayer extends NetHandler {
void handleWindowItems(SPacketWindowItems packet);
void handleSignEditorOpen(SPacketSignEditorOpen packet);
void handleUpdateSign(SPacketUpdateSign packet);
void handleUpdateDisplay(SPacketUpdateDisplay packet);
void handleUpdateTileEntity(SPacketUpdateTileEntity packet);
void handleWindowProperty(SPacketWindowProperty packet);
void handleEntityEquipment(SPacketEntityEquipment packet);

View file

@ -97,6 +97,7 @@ import common.packet.SPacketSpawnObject;
import common.packet.SPacketSpawnPlayer;
import common.packet.SPacketTimeUpdate;
import common.packet.SPacketTrades;
import common.packet.SPacketUpdateDisplay;
import common.packet.SPacketUpdateHealth;
import common.packet.SPacketWorld;
@ -167,6 +168,7 @@ public enum PacketRegistry {
this.server(SPacketWindowProperty.class);
this.server(SPacketConfirmTransaction.class);
this.server(SPacketUpdateSign.class);
this.server(SPacketUpdateDisplay.class);
this.server(SPacketUpdateTileEntity.class);
this.server(SPacketSignEditorOpen.class);
this.server(SPacketPlayerListItem.class);

View file

@ -0,0 +1,52 @@
package common.packet;
import java.io.IOException;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.util.BlockPos;
public class SPacketUpdateDisplay implements Packet<IClientPlayer> {
private BlockPos position;
private int[] pixels;
public SPacketUpdateDisplay() {
}
public SPacketUpdateDisplay(BlockPos pos, int[] pixels) {
this.position = pos;
this.pixels = pixels;
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.position = buf.readBlockPos();
this.pixels = new int[256];
for(int i = 0; i < 256; ++i) {
this.pixels[i] = 0xff000000 | buf.readUnsignedByte() << 16 | buf.readUnsignedByte() << 8 | buf.readUnsignedByte();
}
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeBlockPos(this.position);
for(int i = 0; i < 256; ++i) {
buf.writeByte((this.pixels[i] >> 16) & 255);
buf.writeByte((this.pixels[i] >> 8) & 255);
buf.writeByte(this.pixels[i] & 255);
}
}
public void processPacket(IClientPlayer handler) {
handler.handleUpdateDisplay(this);
}
public BlockPos getPos() {
return this.position;
}
public int[] getPixels() {
return this.pixels;
}
}

View file

@ -6,25 +6,20 @@ import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.util.BlockPos;
import common.world.World;
public class SPacketUpdateSign implements Packet<IClientPlayer>
{
private World world;
private BlockPos blockPos;
private String[] lines;
// private String command;
public SPacketUpdateSign()
{
}
public SPacketUpdateSign(World worldIn, BlockPos blockPosIn, String[] linesIn)
public SPacketUpdateSign(BlockPos blockPosIn, String[] linesIn)
{
this.world = worldIn;
this.blockPos = blockPosIn;
this.lines = new String[] {linesIn[0], linesIn[1], linesIn[2], linesIn[3]};
// this.command = commandIn != null && commandIn.isEmpty() ? null : commandIn;
}
/**
@ -39,9 +34,6 @@ public class SPacketUpdateSign implements Packet<IClientPlayer>
{
this.lines[i] = buf.readString(64);
}
// this.command = buf.readStringFromBuffer(1024);
// this.command = this.command.isEmpty() ? null : this.command;
}
/**
@ -55,8 +47,6 @@ public class SPacketUpdateSign implements Packet<IClientPlayer>
{
buf.writeString(this.lines[i]);
}
// buf.writeString(this.command == null ? "" : this.command);
}
/**
@ -76,9 +66,4 @@ public class SPacketUpdateSign implements Packet<IClientPlayer>
{
return this.lines;
}
// public String getCommand()
// {
// return this.command;
// }
}

View file

@ -0,0 +1,40 @@
package common.tileentity;
import java.util.Arrays;
import common.network.Packet;
import common.packet.SPacketUpdateDisplay;
import common.tags.TagObject;
public class TileEntityDisplay extends TileEntity {
public int[] data = new int[256];
public long lastUpdated;
public TileEntityDisplay() {
Arrays.fill(this.data, 0xff000000);
}
public void writeTags(TagObject compound) {
super.writeTags(compound);
compound.setIntArray("Pixels", this.data);
}
public void readTags(TagObject compound) {
super.readTags(compound);
this.data = compound.getIntArray("Pixels");
if(this.data.length != 256)
this.data = new int[256];
}
public Packet getDescriptionPacket() {
return new SPacketUpdateDisplay(this.pos, this.data);
}
public int getColor() {
return 0x00ff00;
}
public void setPixel(int x, int y, int color) {
this.data[x + y * 16] = color | 0xff000000;
}
}

View file

@ -30,7 +30,7 @@ public class TileEntitySign extends TileEntity {
String[] aichatcomponent = new String[4];
System.arraycopy(this.signText, 0, aichatcomponent, 0, 4);
// Sign sign = Server.getServer().getSigns().getEntry(new WorldPos(this).toString());
return new SPacketUpdateSign(this.worldObj, this.pos, aichatcomponent);
return new SPacketUpdateSign(this.pos, aichatcomponent);
}
public void setPlayer(EntityNPC playerIn) {

View file

@ -858,7 +858,7 @@ public final class Server implements IThreadListener, Executor {
world = world == null ? this.space : world;
}
EntityNPC nplayer = conn.createPlayer(world, EntityRegistry.getEntityString(old));
conn.clonePlayer(old);
conn.copyPlayer(old);
nplayer.setId(old.getId());
nplayer.setOrigin(origin);
if(bed != null) {

View file

@ -458,7 +458,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.lastHealth = -1.0E8F;
}
public void clonePlayer(EntityNPC oldPlayer)
public void copyPlayer(EntityNPC oldPlayer)
{
this.lastExperience = -1;
this.lastHealth = -1.0F;
@ -473,6 +473,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.entity.setHeight(oldPlayer.getHeight());
this.entity.setCustomNameTag(oldPlayer.getCustomNameTag());
this.entity.setAlignment(oldPlayer.getAlignment());
this.entity.setAttackDamageBase(oldPlayer.getAttackDamageBase());
this.entity.setSpeedBase(oldPlayer.getSpeedBase());
this.entity.setMaxHealth(oldPlayer.getMaxHealth());
this.entity.setMaxMana(oldPlayer.getMaxMana());
}
public void removeEntity(Entity p_152339_1_)