@Override public void onPlacedBy( EntityPlayer player, ItemStack is, EnumFacing side, float hitX, float hitY, float hitZ) { super.onPlacedBy(player, is, side, hitX, hitY, hitZ); NBTTagCompound tag = null; if (is.hasTagCompound()) { tag = is.getTagCompound(); try { putData(new DataInNBT(tag)); } catch (IOException e) { e.printStackTrace(); } } else { addLump(); } EnumFacing placement = SpaceUtil.determineFlatOrientation(player); if (tag == null || !tag.hasKey("front")) { front = placement; setRotation((byte) 0); } else if (placement.getDirectionVec().getY() == 0 && placement != null) { front = SpaceUtil.getOrientation(tag.getByte("front")); if (front == null || front.getDirectionVec().getY() != 0) { setRotation((byte) 0); front = placement; } else { EnumFacing f = placement; byte r = 0; for (byte i = 0; i < 4; i++) { if (f == front) { r = i; break; } f = SpaceUtil.rotate(f, EnumFacing.UP); } setRotation(r); } } }
@Override public boolean handleMessageFromServer(Enum messageType, ByteBuf input) throws IOException { if (super.handleMessageFromServer(messageType, input)) { return true; } if (messageType.equals(factorization.net.StandardMessageType.Description)) { readStateChange(input); front = SpaceUtil.getOrientation(input.readByte()); setRotation(input.readByte()); parts.clear(); ArrayList<Object> args = new ArrayList(); while (true) { try { parts.add(new ClayLump().read(input)); } catch (IOException e) { break; } } shouldRenderTesr = getState() == ClayState.WET; } else if (messageType.equals(GreenwareMessage.SculptMove)) { updateLump(input.readInt(), new ClayLump().read(input)); } else if (messageType.equals(GreenwareMessage.SculptNew)) { addLump(); } else if (messageType.equals(GreenwareMessage.SculptRemove)) { removeLump(input.readInt()); } else if (messageType.equals(GreenwareMessage.SculptState)) { readStateChange(input); } else { return false; } cache_dirty = true; if (renderEfficient()) { getCoord().redraw(); } return true; }