This commit is contained in:
brandon3055 committed 2015-05-01 10:08:50 +10:00
1 parent 9fb359d4b8
commit 0bfb00b274
24 files changed
+193 -92

No files matched your search

@@ -18,7 +18,7 @@ import net.minecraft.enchantment.Enchantment;
import java.util.Arrays;
@Mod(modid = References.MODID, name = References.MODNAME, version = References.VERSION, canBeDeactivated = false, guiFactory = References.GUIFACTORY, dependencies = "after:NotEnoughItems;after:NotEnoughItems;after:ThermalExpansion;after:ThermalFoundation;")
public class DraconicEvolution { // TODO Update Licence and add change log to github
public class DraconicEvolution {
@Mod.Instance(References.MODID)
public static DraconicEvolution instance;
@@ -241,4 +241,9 @@ public class ClientProxy extends CommonProxy {
public boolean isShiftDown() {
return Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed();
}
@Override
public boolean isCtrlDown() {
return Minecraft.getMinecraft().gameSettings.keyBindSprint.getIsKeyPressed();
}
}
@@ -40,7 +40,7 @@ public class GUITeleporter extends GuiScreen
protected List<TeleportLocation> locations = new ArrayList<TeleportLocation>(0);
private int selected = 0;
private int selrctionOffset = 0;
private int selectionOffset = 0;
private int maxOffset = 0;
private int fuel = 0;
private boolean editingExisting = false;
@@ -106,7 +106,7 @@ public class GUITeleporter extends GuiScreen
drawTexturedModalRect(posX+19, posY+5+i*11, 0, 188, 80, 10);
}
if (locations.get(i+selrctionOffset).getWriteProtected()){
if (getLocationSafely(i + selectionOffset).getWriteProtected()){
if (GuiHelper.isInRect(102, 7+i*11, 6, 6, x, y)) drawTexturedModalRect(posX+102, posY+7+i*11, 26, 149, 6, 6);
else drawTexturedModalRect(posX+102, posY+7+i*11, 26, 143, 6, 6);
}else{
@@ -118,8 +118,8 @@ public class GUITeleporter extends GuiScreen
drawTexturedModalRect(posX+19, posY+5+selected*11, 0, 188, 80, 10);
int yl = 0;
for (int i = selrctionOffset; i < locations.size() && i < selrctionOffset + 12; i++){
String s = locations.get(i).getName();
for (int i = selectionOffset; i < locations.size() && i < selectionOffset + 12; i++){
String s = getLocationSafely(i).getName();
if (fontRendererObj.getStringWidth(s) > 80) {
int safety = 0;
while (fontRendererObj.getStringWidth(s) > 70){
@@ -138,12 +138,12 @@ public class GUITeleporter extends GuiScreen
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
if (selrctionOffset > 0){
if (selectionOffset > 0){
boolean highLighted = GuiHelper.isInRect(4, 4, 13, 15, x, y);
if (highLighted) drawTexturedModalRect(posX+4, posY+4, 0, 158, 13, 15);
else drawTexturedModalRect(posX+4, posY+4, 0, 143, 13, 15);
}else drawTexturedModalRect(posX+4, posY+4, 0, 173, 13, 15);
if (selrctionOffset < maxOffset){
if (selectionOffset < maxOffset){
boolean highLighted = GuiHelper.isInRect(4, 122, 13, 15, x, y);
if (highLighted) drawTexturedModalRect(posX+4, posY+122, 13, 158, 13, 15);
else drawTexturedModalRect(posX+4, posY+122, 13, 143, 13, 15);
@@ -152,7 +152,7 @@ public class GUITeleporter extends GuiScreen
float percent = locations.size() <= 12 ? 1f : 12F / (float)locations.size();
int drawSize = (int)(percent * 99F);
int space = 99 - drawSize;
float location = (float)selrctionOffset / (float)(locations.size()-12);
float location = (float) selectionOffset / (float)(locations.size()-12);
int yOffset = (int) (location * (float)space);
drawTexturedModalRect(posX+5, posY+21+yOffset, 182, 0, 11, drawSize);
drawTexturedModalRect(posX+5, posY+21+drawSize-1+yOffset, 182, 98, 11, 1);
@@ -162,10 +162,10 @@ public class GUITeleporter extends GuiScreen
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
if (locations.size() <= 0) return;
fontRendererObj.drawString(EnumChatFormatting.GOLD+"X: "+(int)locations.get(selected+selrctionOffset).getXCoord(), posX+114, posY+7, 0x000000);
fontRendererObj.drawString(EnumChatFormatting.GOLD + "Y: " + (int) locations.get(selected + selrctionOffset).getYCoord(), posX + 114, posY + 16, 0x000000);
fontRendererObj.drawString(EnumChatFormatting.GOLD + "Z: " + (int) locations.get(selected + selrctionOffset).getZCoord(), posX + 114, posY + 25, 0x000000);
fontRendererObj.drawString(EnumChatFormatting.GOLD+""+ locations.get(selected + selrctionOffset).getDimensionName(), posX+114, posY+34, 0x000000);
fontRendererObj.drawString(EnumChatFormatting.GOLD+"X: "+(int)getLocationSafely(selected + selectionOffset).getXCoord(), posX+114, posY+7, 0x000000);
fontRendererObj.drawString(EnumChatFormatting.GOLD + "Y: " + (int) getLocationSafely(selected + selectionOffset).getYCoord(), posX + 114, posY + 16, 0x000000);
fontRendererObj.drawString(EnumChatFormatting.GOLD + "Z: " + (int) getLocationSafely(selected + selectionOffset).getZCoord(), posX + 114, posY + 25, 0x000000);
fontRendererObj.drawString(EnumChatFormatting.GOLD+""+ getLocationSafely(selected + selectionOffset).getDimensionName(), posX+114, posY+34, 0x000000);
}
@Override
@@ -179,16 +179,16 @@ public class GUITeleporter extends GuiScreen
if (textBeingEdited.getVisible()) textBeingEdited.mouseClicked(x, y, button);
//Check for arrow click
if (selrctionOffset > 0 && GuiHelper.isInRect(3, 5, 13, 15, x-posX, y-posY)){
selrctionOffset--;
if (selectionOffset > 0 && GuiHelper.isInRect(3, 5, 13, 15, x-posX, y-posY)){
selectionOffset--;
offsetChanged = true;
if (selected < 11) {
selected++;
selectionChanged = true;
}
}
if (selrctionOffset < maxOffset && GuiHelper.isInRect(3, 123, 13, 15, x-posX, y-posY)){
selrctionOffset++;
if (selectionOffset < maxOffset && GuiHelper.isInRect(3, 123, 13, 15, x-posX, y-posY)){
selectionOffset++;
offsetChanged = true;
if (selected > 0) {
selected--;
@@ -199,12 +199,12 @@ public class GUITeleporter extends GuiScreen
//Check for location or lock clicked
for (int i = 0; i < Math.min(12, locations.size()); i++){
if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x-posX, y-posY)) {
if (!(locations.get(i+selrctionOffset).getWriteProtected() && editingExisting) && button == 0)
if (!(getLocationSafely(i + selectionOffset).getWriteProtected() && editingExisting) && button == 0)
{
selected = i;
selectionChanged = true;
}
if (!(locations.get(i+selrctionOffset).getWriteProtected() && editingExisting) && button == 1)
if (!(getLocationSafely(i + selectionOffset).getWriteProtected() && editingExisting) && button == 1)
{
if (locations.isEmpty()) return;
@@ -215,20 +215,20 @@ public class GUITeleporter extends GuiScreen
if (player.capabilities.isCreativeMode || fuel > 0) {
if (!player.capabilities.isCreativeMode) fuel--;
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.TELEPORT, i+selrctionOffset, false));
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.TELEPORT, i+ selectionOffset, false));
}
}
}
if (GuiHelper.isInRect(99, 8+i*11, 8, 7, x-posX, y-posY)) {
locations.get(i+selrctionOffset).setWriteProtected(!locations.get(i+selrctionOffset).getWriteProtected());
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATELOCK, i+selrctionOffset, locations.get(i+selrctionOffset).getWriteProtected()));
getLocationSafely(i + selectionOffset).setWriteProtected(!getLocationSafely(i + selectionOffset).getWriteProtected());
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATELOCK, i+ selectionOffset, getLocationSafely(i + selectionOffset).getWriteProtected()));
}
}
if (selectionChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false));
if (offsetChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selrctionOffset, false));
if (offsetChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false));
updateButtons();
super.mouseClicked(x, y, button);
@@ -244,8 +244,8 @@ public class GUITeleporter extends GuiScreen
int i = org.lwjgl.input.Mouse.getEventDWheel();
boolean offsetChanged = false;
boolean selectionChanged = false;
if (i < 0 && selrctionOffset < maxOffset) {
selrctionOffset++;
if (i < 0 && selectionOffset < maxOffset) {
selectionOffset++;
offsetChanged = true;
if (selected > 0) {
selected--;
@@ -253,8 +253,8 @@ public class GUITeleporter extends GuiScreen
}
updateButtons();
}
if (i > 0 && selrctionOffset > 0) {
selrctionOffset--;
if (i > 0 && selectionOffset > 0) {
selectionOffset--;
offsetChanged = true;
if (selected < 11) {
selected++;
@@ -264,7 +264,7 @@ public class GUITeleporter extends GuiScreen
}
if (selectionChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false));
if (offsetChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selrctionOffset, false));
if (offsetChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false));
super.handleMouseInput();
}
@@ -272,15 +272,15 @@ public class GUITeleporter extends GuiScreen
private void updateButtons(){
if (locations.size() > 12) maxOffset = locations.size() - 12;
else maxOffset = 0;
if (selrctionOffset > maxOffset) selrctionOffset = maxOffset;
if (selectionOffset > maxOffset) selectionOffset = maxOffset;
if (selected > locations.size() || selected < 0) selected = Math.max(locations.size() - 1, 0);
if ((selected + selrctionOffset)+1 > locations.size()){
if ((selected + selectionOffset)+1 > locations.size()){
selected = 0;
selrctionOffset = 0;
selectionOffset = 0;
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false));
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selrctionOffset, false));
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false));
}
if (locations.size() == 0 || locations.get(selected + selrctionOffset).getWriteProtected()) {
if (locations.size() == 0 || getLocationSafely(selected + selectionOffset).getWriteProtected()) {
((GuiButton) buttonList.get(0)).enabled = false;
((GuiButton) buttonList.get(1)).enabled = false;
((GuiButton) buttonList.get(2)).enabled = false;
@@ -347,16 +347,16 @@ public class GUITeleporter extends GuiScreen
if (!editingExisting){
editingExisting = true;
textBeingEdited.setVisible(true);
textBeingEdited.setText(locations.get(selected+selrctionOffset).getName());
textBeingEdited.setText(getLocationSafely(selected + selectionOffset).getName());
textBeingEdited.setSelectionPos(0);
textBeingEdited.setFocused(true);
((GuiButton) buttonList.get(6)).visible = true;
}else{
if (!textBeingEdited.getText().isEmpty()){
locations.get(selected+selrctionOffset).setName(textBeingEdited.getText());
getLocationSafely(selected + selectionOffset).setName(textBeingEdited.getText());
TeleportLocation location = new TeleportLocation();
location.setName(textBeingEdited.getText());
DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATENAME, selected+selrctionOffset));
DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATENAME, selected+ selectionOffset));
((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.rename.txt");
editingExisting = false;
textBeingEdited.setVisible(false);
@@ -366,15 +366,15 @@ public class GUITeleporter extends GuiScreen
}
if (button.id == 1){
TeleportLocation location = new TeleportLocation(player.posX, player.posY-1.62, player.posZ, player.dimension, player.rotationPitch, player.rotationYaw, locations.get(selected+selrctionOffset).getName());
DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATEDESTINATION, selected+selrctionOffset));
locations.set(selected + selrctionOffset, location);
TeleportLocation location = new TeleportLocation(player.posX, player.posY-1.62, player.posZ, player.dimension, player.rotationPitch, player.rotationYaw, getLocationSafely(selected + selectionOffset).getName());
DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATEDESTINATION, selected+ selectionOffset));
locations.set(selected + selectionOffset, location);
}
if (button.id == 2) {
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.REMOVEDESTINATION, selected+selrctionOffset, false));
locations.remove(selected+selrctionOffset);
if (selrctionOffset > 0) selrctionOffset--;
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.REMOVEDESTINATION, selected+ selectionOffset, false));
locations.remove(selected+ selectionOffset);
if (selectionOffset > 0) selectionOffset--;
if (selected >= locations.size()) selected--;
}
@@ -384,9 +384,9 @@ public class GUITeleporter extends GuiScreen
{
if (selected > 0)
{
TeleportLocation temp = locations.get(selected + selrctionOffset);
locations.set(selected + selrctionOffset, locations.get(selected + selrctionOffset - 1));
locations.set(selected + selrctionOffset - 1, temp);
TeleportLocation temp = getLocationSafely(selected + selectionOffset);
locations.set(selected + selectionOffset, getLocationSafely(selected + selectionOffset - 1));
locations.set(selected + selectionOffset - 1, temp);
selected--;
}
}
@@ -394,14 +394,14 @@ public class GUITeleporter extends GuiScreen
{
if (selected < Math.min(11, locations.size()-1))
{
TeleportLocation temp = locations.get(selected + selrctionOffset);
locations.set(selected + selrctionOffset, locations.get(selected + selrctionOffset + 1));
locations.set(selected + selrctionOffset + 1, temp);
TeleportLocation temp = getLocationSafely(selected + selectionOffset);
locations.set(selected + selectionOffset, getLocationSafely(selected + selectionOffset + 1));
locations.set(selected + selectionOffset + 1, temp);
selected++;
}
}
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.MOVELOCATION, selected+selrctionOffset, button.id == 3));
DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.MOVELOCATION, selected+ selectionOffset, button.id == 3));
}
if (button.id == 4 || button.id == 6 && !editingExisting){
@@ -499,7 +499,7 @@ public class GUITeleporter extends GuiScreen
this.mc.setIngameFocus();
}
if (tick % 5 == 0 && locations.size() > 0 && locations.get(selected + selrctionOffset).getDimensionName().equals("") && player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.teleporterMKII) readDataFromItem(player.getHeldItem());
if (tick % 5 == 0 && locations.size() > 0 && getLocationSafely(selected + selectionOffset).getDimensionName().equals("") && player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.teleporterMKII) readDataFromItem(player.getHeldItem());
tick++;
if (tick >= 10){
@@ -516,7 +516,7 @@ public class GUITeleporter extends GuiScreen
private void readDataFromItem(ItemStack teleporter){
this.selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0);
this.selrctionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0);
this.selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0);
this.fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0);
locations.clear();
@@ -542,4 +542,9 @@ public class GUITeleporter extends GuiScreen
locations.add(currentLocation);
}
private TeleportLocation getLocationSafely(int index)
{
if (index < locations.size() && index >= 0) return locations.get(index);
return new TeleportLocation(0, 0, 0, 0, 0, 0, EnumChatFormatting.DARK_RED + "[Index Error]");
}
}
@@ -211,6 +211,11 @@ public class CommonProxy {
return false;
}
public boolean isCtrlDown()
{
return false;
}
public boolean isShiftDown()
{
return false;
@@ -103,8 +103,7 @@ public class ContainerDraconiumChest extends Container {
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
public boolean canInteractWith(EntityPlayer player) {
return tile.isUseableByPlayer(player);
}
@@ -86,18 +86,6 @@ public class FMLEventHandler {
player.moveFlying(0F, 1F, player.capabilities.isFlying ? (percentIncrease / 2.0f) : percentIncrease);
}
if ((!player.onGround && player.capabilities.isFlying) && player.motionY != 0)
{
if (DraconicEvolution.proxy.isSpaceDown() && !DraconicEvolution.proxy.isShiftDown())
{
player.motionY = 0.124D + (double)(percentIncrease * 3F);
}
if (DraconicEvolution.proxy.isShiftDown() && !DraconicEvolution.proxy.isSpaceDown())
{
player.motionY = -0.124D - (double)(percentIncrease * 3F);
}
}
player.jumpMovementFactor = 0.02F + (percentIncrease * 0.2F);
}
@@ -108,6 +96,21 @@ public class FMLEventHandler {
player.capabilities.allowFlying = true;
if (ArmorEffectHandler.getFlightLock(player)) player.capabilities.isFlying = true;
if ((!player.onGround && player.capabilities.isFlying) && player.motionY != 0 && ((ArmorEffectHandler.getVAccSprint(player) && DraconicEvolution.proxy.isCtrlDown()) || (!ArmorEffectHandler.getVAccSprint(player))))
{
float percentIncrease = ArmorEffectHandler.getVAccel(player);
if (DraconicEvolution.proxy.isSpaceDown() && !DraconicEvolution.proxy.isShiftDown())
{
player.motionY =(double)(percentIncrease * 2F);
}
if (DraconicEvolution.proxy.isShiftDown() && !DraconicEvolution.proxy.isSpaceDown())
{
player.motionY = -(double)(percentIncrease * 2F);
}
}
} else {
if (!playersWithFlight.containsKey(player)) {
@@ -20,6 +20,14 @@ public class ArmorEffectHandler {
return isDraconicArmor(player, 3);// && ((IEnergyContainerItem)player.getEquipmentInSlot(3).getItem()).extractEnergy(player.getEquipmentInSlot(3), 80, !player.capabilities.isFlying) == 80;
}
public static float getVAccel(EntityPlayer player){
return ItemNBTHelper.getFloat(player.getEquipmentInSlot(3), "VerticalAcceleration", 0.3F);
}
public static boolean getVAccSprint(EntityPlayer player){
return ItemNBTHelper.getBoolean(player.getEquipmentInSlot(3), "EffectiveOnSprint", false);
}
public static boolean getFlightLock(EntityPlayer player){
return ItemNBTHelper.getBoolean(player.getEquipmentInSlot(3), "ArmorFlightLock", false);
}
@@ -179,7 +179,7 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IEnergyCo
{
player.addPotionEffect(new PotionEffect(16, 419, 0, true));
}
else if ( ItemNBTHelper.getBoolean(stack, "ArmorNVActive", false) && ItemNBTHelper.getBoolean(stack, "ArmorNVLock", false)) player.addPotionEffect(new PotionEffect(16, 419, 0, true));
else if ( ItemNBTHelper.getBoolean(stack, "ArmorNVActive", false) && ItemNBTHelper.getBoolean(stack, "ArmorNVLock", true)) player.addPotionEffect(new PotionEffect(16, 419, 0, true));
else if (player.isPotionActive(16)) player.removePotionEffect(16);
}
@@ -276,10 +276,12 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IEnergyCo
if (armorType == 0)
{
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorNVActive").readFromItem(stack, false));
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorNVLock").readFromItem(stack, false));
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorNVLock").readFromItem(stack, true));
}
else if (armorType == 1)
{
list.add(new ItemConfigField(References.FLOAT_ID, slot, "VerticalAcceleration").setMinMaxAndIncromente(0f, 1f, 0.01f).readFromItem(stack, 0.3F));
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "EffectiveOnSprint").readFromItem(stack, false));
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorFlightLock").readFromItem(stack, false));
}
else if (armorType == 2)
@@ -34,7 +34,7 @@ public final class References {
public static final byte BOOLEAN_ID = 6;
public static final byte CHAR_ID = 7;
public static final byte STRING_ID = 8;
public static final byte TWO_INTS_ID = 9;
public static final byte INT_PAIR_ID = 9;
//======================Tags========================//
@@ -6,8 +6,8 @@ package com.brandon3055.draconicevolution.common.lib;
public class VersionHandler
{
public static final String VERSION = "1.0.1";
public static final int SNAPSHOT = 10;
public static final int SNAPSHOT = 0;
public static final String MCVERSION = "1.7.10";
public static final String FULL_VERSION = VERSION + (SNAPSHOT > 0 ? "-snapshot_" + SNAPSHOT: "");
public static final String FULL_VERSION = VERSION + (SNAPSHOT > 0 ? "-snapshot_" + SNAPSHOT : "");
}
@@ -205,7 +205,16 @@ public class TileDissEnchanter extends TileEntity implements ISidedInventory {
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
public boolean isUseableByPlayer(EntityPlayer player)
{
if (worldObj == null)
{
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64;
}
@@ -451,6 +451,14 @@ public class TileDraconiumChest extends TileEntity implements ISidedInventory, I
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
if (worldObj == null)
{
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64;
}
@@ -247,6 +247,14 @@ public class TileEnergyInfuser extends TileObjectSync implements IEnergyReceiver
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
if (worldObj == null)
{
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64;
}
@@ -176,7 +176,16 @@ public class TileGenerator extends TileObjectSync implements ISidedInventory, IE
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
public boolean isUseableByPlayer(EntityPlayer player)
{
if (worldObj == null)
{
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64;
}
@@ -302,6 +302,14 @@ public class TileGrinder extends TileObjectSync implements ISidedInventory, IEne
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
if (worldObj == null)
{
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64;
}
@@ -213,6 +213,14 @@ public class TilePlayerDetectorAdvanced extends TileEntity implements IInventory
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
if (worldObj == null)
{
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64;
}
@@ -236,6 +236,14 @@ public class TileWeatherController extends TileEntity implements IInventory {
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
if (worldObj == null)
{
return true;
}
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}
@@ -144,20 +144,25 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
if (worldObj.isRemote) return;
boolean forceSend = (tick + xCoord + yCoord + zCoord) % 100 == 0;
if (index >= 0 && (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow || forceSend)) {
sendObject(References.TWO_INTS_ID, 0, new DataUtills.TwoXInteger(index, (int)linkedDevices.get(index).energyFlow));
linkedDevices.get(index).lastTickEnergyFlow = linkedDevices.get(index).energyFlow;
}
if (storage.getEnergyStored() != lastTickEnergy || forceSend) sendObject(References.INT_ID, 1, storage.getEnergyStored());
if ((tick + xCoord + yCoord + zCoord) % 20 == 0 || forceSend)
{
if (index >= 0 && (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow || forceSend))
{
sendObject(References.INT_PAIR_ID, 0, new DataUtills.IntPair(index, (int) linkedDevices.get(index).energyFlow));
linkedDevices.get(index).lastTickEnergyFlow = linkedDevices.get(index).energyFlow;
}
if (storage.getEnergyStored() != lastTickEnergy || forceSend) sendObject(References.INT_ID, 1, storage.getEnergyStored());
}
}
@SideOnly(Side.CLIENT)
@Override
public void receiveObject(int index, Object object) {
if (index == 0 && object instanceof DataUtills.TwoXInteger && linkedDevices.size() > ((DataUtills.TwoXInteger) object).i1)
if (index == 0 && object instanceof DataUtills.IntPair && linkedDevices.size() > ((DataUtills.IntPair) object).i1)
{
linkedDevices.get(((DataUtills.TwoXInteger) object).i1).energyFlow = ((DataUtills.TwoXInteger) object).i2;
linkedDevices.get(((DataUtills.IntPair) object).i1).energyFlow = ((DataUtills.IntPair) object).i2;
}
else if (index == 1) storage.setEnergyStored((Integer)object);
}
@@ -41,9 +41,9 @@ public class DataUtills {
case References.BOOLEAN_ID:
bytes.writeBoolean((Boolean) object);
break;
case References.TWO_INTS_ID:
bytes.writeInt(((TwoXInteger)object).i1);
bytes.writeInt(((TwoXInteger)object).i2);
case References.INT_PAIR_ID:
bytes.writeInt(((IntPair)object).i1);
bytes.writeInt(((IntPair)object).i2);
break;
}
}
@@ -68,8 +68,8 @@ public class DataUtills {
return ByteBufUtils.readUTF8String(bytes);
case References.BOOLEAN_ID:
return bytes.readBoolean();
case References.TWO_INTS_ID:
TwoXInteger tx = new TwoXInteger(0, 0);
case References.INT_PAIR_ID:
IntPair tx = new IntPair(0, 0);
tx.i1 = bytes.readInt();
tx.i2 = bytes.readInt();
return tx;
@@ -155,12 +155,12 @@ public class DataUtills {
return null;
}
public static class TwoXInteger
public static class IntPair
{
public int i1;
public int i2;
public TwoXInteger(int i1, int i2)
public IntPair(int i1, int i2)
{
this.i1 = i1;
this.i2 = i2;