mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-20 20:22:10 +00:00
17/01/2015
This commit is contained in:
1 parent
c67b7c1cd0
commit
a65aeedcab
42 files changed
+1124
-608
No files matched your search
@@ -21,7 +21,7 @@ public class DraconicEvolution { // TODO Update Licence and add change log to gi
|
||||
@Mod.Instance(References.MODID)
|
||||
public static DraconicEvolution instance;
|
||||
|
||||
@SidedProxy(clientSide = References.CLIENTPROXYLOCATION, serverSide = References.COMMONPROXYLOCATION)
|
||||
@SidedProxy(clientSide = References.CLIENTPROXYLOCATION, serverSide = References.SERVERPROXYLOCATION)
|
||||
public static CommonProxy proxy;
|
||||
|
||||
public static CreativeTabs tabToolsWeapons = new DETab(CreativeTabs.getNextID(), References.MODID, "toolsAndWeapons", 0);
|
||||
@@ -30,7 +30,7 @@ public class DraconicEvolution { // TODO Update Licence and add change log to gi
|
||||
public static final String networkChannelName = "DraconicEvolution";
|
||||
public static SimpleNetworkWrapper network;
|
||||
|
||||
public static boolean debug = false;//todo
|
||||
public static boolean debug = true;//todo
|
||||
|
||||
public static Enchantment reaperEnchant;
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientSide() { return true; }
|
||||
|
||||
public boolean isDedicatedServer() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.componentguis.GUIToolConfig;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.manual.GuiManual;
|
||||
import com.brandon3055.draconicevolution.common.container.*;
|
||||
import com.brandon3055.draconicevolution.common.inventory.InventoryTool;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.*;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
@@ -83,7 +84,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
}
|
||||
break;
|
||||
case GUIID_TOOL_CONFIG:
|
||||
return new DummyContainer();
|
||||
return new ContainerAdvTool(player.inventory, new InventoryTool(player, null));
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +158,8 @@ public class GuiHandler implements IGuiHandler {
|
||||
}
|
||||
break;
|
||||
case GUIID_TOOL_CONFIG:
|
||||
return new GUIToolConfig(player);
|
||||
return new GUIToolConfig(player, new ContainerAdvTool(player.inventory, new InventoryTool(player, null)));
|
||||
|
||||
|
||||
// case GUIID_CONTAINER_TEMPLATE:
|
||||
// TileEntity containerTemp = world.getTileEntity(x, y, z);
|
||||
|
||||
+27
-6
@@ -1,10 +1,12 @@
|
||||
package com.brandon3055.draconicevolution.client.interfaces.componentguis;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.interfaces.guicomponents.*;
|
||||
import com.brandon3055.draconicevolution.common.container.DummyContainer;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerAdvTool;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utills.IConfigurableItem;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,11 +19,13 @@ public class GUIToolConfig extends GUIBase {
|
||||
|
||||
public EntityPlayer player;
|
||||
private static final ResourceLocation inventoryTexture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/ToolConfig.png");
|
||||
|
||||
private int screenLevel = 0;
|
||||
private ItemStack editingItem;
|
||||
private ContainerAdvTool container;
|
||||
|
||||
public GUIToolConfig(EntityPlayer player) {
|
||||
super(new DummyContainer(), 198, 89);
|
||||
public GUIToolConfig(EntityPlayer player, ContainerAdvTool container) {
|
||||
super(container, 198, 89);
|
||||
this.container = container;
|
||||
this.player = player;
|
||||
addDependentComponents();
|
||||
}
|
||||
@@ -40,8 +44,9 @@ public class GUIToolConfig extends GUIBase {
|
||||
@Override
|
||||
protected ComponentCollection assembleComponents() {
|
||||
ComponentCollection c = new ComponentCollection(0, 0, xSize, ySize, this);
|
||||
c.addComponent(new ComponentBackground(0, 0, 198, 89, inventoryTexture)).setGroup("BACKGROUND");
|
||||
c.addComponent(new ComponentTexturedRect(0, 0, 198, 89, inventoryTexture)).setGroup("BACKGROUND");
|
||||
c.addComponent(new ComponentButton(3, 26, 20, 12, 0, this, "<=", "Back")).setGroup("BUTTONS").setName("BACK_BUTTON");
|
||||
c.addComponent(new ComponentButton(3, 39, 20, 12, 1, this, "Inv", "Item Inventory")).setGroup("BUTTONS").setName("INVENTORY_BUTTON");
|
||||
c.addComponent(new ComponentFieldAdjuster(4, 34, null, this)).setGroup("FIELD_BUTTONS").setName("FIELD_CONFIG_BUTTON_ARRAY");
|
||||
return c;
|
||||
}
|
||||
@@ -80,6 +85,7 @@ public class GUIToolConfig extends GUIBase {
|
||||
buttonPressed = true;
|
||||
IConfigurableItem item = (IConfigurableItem)stack.getItem();
|
||||
|
||||
setEditingItem(stack, ((ComponentConfigItemButton) component).slot);
|
||||
setLevel(1);
|
||||
for (ItemConfigField field : item.getFields(stack, ((ComponentConfigItemButton) component).slot)){
|
||||
collection.addComponent(new ComponentFieldButton(fieldOffsetX, fieldOffsetY, player, field, this)).setGroup("LIST_SCREEN");
|
||||
@@ -99,6 +105,12 @@ public class GUIToolConfig extends GUIBase {
|
||||
if (id == 0 && screenLevel > 0){//button back
|
||||
setLevel(screenLevel - 1);
|
||||
}
|
||||
else if (id == 1 && editingItem != null){//inventory button
|
||||
setLevel(3);
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GUIToolInventory(player, container));
|
||||
// LogHelper.info("Pre send container " + Minecraft.getMinecraft().thePlayer.openContainer);
|
||||
// DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLINVENTORY, false));
|
||||
}
|
||||
}
|
||||
|
||||
public void setLevel(int level){
|
||||
@@ -114,6 +126,7 @@ public class GUIToolConfig extends GUIBase {
|
||||
collection.setOnlyGroupEnabled("LIST_SCREEN");
|
||||
collection.setGroupEnabled("BACKGROUND", true);
|
||||
collection.setComponentEnabled("BACK_BUTTON", true);
|
||||
if (editingItem != null && editingItem.getItem() instanceof MiningTool) collection.setComponentEnabled("INVENTORY_BUTTON", true);
|
||||
if (collection.getComponent("BACK_BUTTON") != null) collection.getComponent("BACK_BUTTON").setY(26);
|
||||
}
|
||||
else if (level == 2){//field screen
|
||||
@@ -122,10 +135,18 @@ public class GUIToolConfig extends GUIBase {
|
||||
collection.setComponentEnabled("BACK_BUTTON", true);
|
||||
if (collection.getComponent("BACK_BUTTON") != null) collection.getComponent("BACK_BUTTON").setY(3);
|
||||
}
|
||||
else if (level == 3){//inventory screen
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void editField(ItemConfigField field){
|
||||
public void setFieldBeingEdited(ItemConfigField field){
|
||||
((ComponentFieldAdjuster) collection.getComponent("FIELD_CONFIG_BUTTON_ARRAY")).field = field;
|
||||
setLevel(2);
|
||||
}
|
||||
|
||||
public void setEditingItem(ItemStack stack, int slot) {
|
||||
this.editingItem = stack;
|
||||
container.updateInventoryStack(slot);
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.brandon3055.draconicevolution.client.interfaces.componentguis;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.interfaces.guicomponents.ComponentTexturedRect;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.guicomponents.ComponentCollection;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.guicomponents.ComponentSlotBackground;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.guicomponents.GUIBase;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerAdvTool;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 13/01/2015.
|
||||
*/
|
||||
public class GUIToolInventory extends GUIBase {
|
||||
|
||||
private static final ResourceLocation inventoryTexture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/ToolConfig.png");
|
||||
|
||||
private ContainerAdvTool container;
|
||||
private String inventoryName;
|
||||
|
||||
public GUIToolInventory(EntityPlayer player, ContainerAdvTool container) {
|
||||
super(container, 198, 130);
|
||||
this.container = container;
|
||||
this.container.setSlotsActive(true);
|
||||
this.inventoryName = container.inventoryTool.getInventoryName();
|
||||
addDependentComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComponentCollection assembleComponents() {
|
||||
ComponentCollection c = new ComponentCollection(0, 0, xSize, ySize, this);
|
||||
c.addComponent(new ComponentTexturedRect(0, 130 - 89, 198, 89, inventoryTexture)).setGroup("BACKGROUND");
|
||||
c.addComponent(new ComponentTexturedRect(0, 0, 198, 80, inventoryTexture)).setGroup("BACKGROUND");
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
c.addComponent(new ComponentSlotBackground(172, 18 + i * 21)).setGroup("INVENTORY");
|
||||
c.addComponent(new ComponentTexturedRect(173, 20 + i * 21, 0, 89, 16, 14, inventoryTexture, true)).setGroup("INVENTORY");
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addDependentComponents() {
|
||||
for (int x = 0; x < container.inventoryTool.size; x++) collection.addComponent(new ComponentSlotBackground(7 + x * 18, 18)).setGroup("INVENTORY");
|
||||
ComponentSlotBackground.addInventorySlots(collection, 7, 44, container.inventoryItemSlot);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
GL11.glColor3f(1f, 1f, 1f);
|
||||
fontRendererObj.drawString(inventoryName, guiLeft + 5, guiTop + 5, 0x555555);
|
||||
}
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
package com.brandon3055.draconicevolution.client.interfaces.guicomponents;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 29/12/2014.
|
||||
*/
|
||||
public class ComponentBackground extends ComponentBase {
|
||||
protected int width;
|
||||
protected int height;
|
||||
private final ResourceLocation texture;
|
||||
|
||||
public ComponentBackground(int x, int y, int width, int height, ResourceLocation texture) {
|
||||
super(x, y);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
drawTexturedModalRect(x, y, 0, 0, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -61,7 +61,10 @@ public class ComponentConfigItemButton extends ComponentBase {
|
||||
if (isMouseOver(mouseX, mouseY) && hasValidItem){
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<ItemConfigField> fields = ((IConfigurableItem)inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot);
|
||||
for (ItemConfigField field : fields) list.add(field.getLocalizedName() + ": " + field.value);
|
||||
for (ItemConfigField field : fields) {
|
||||
list.add(field.getLocalizedName() + ": " + field.getFormatedValue());
|
||||
|
||||
}
|
||||
drawHoveringText(list, mouseX + offsetX, mouseY + offsetY + 10, fontRendererObj);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-7
@@ -10,7 +10,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 1/01/2015.
|
||||
@@ -62,7 +61,7 @@ public class ComponentFieldAdjuster extends ComponentBase {
|
||||
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
if (field == null) return;
|
||||
String fieldName = field.getLocalizedName();
|
||||
String fieldValue = String.valueOf(field.value);
|
||||
String fieldValue = field.getFormatedValue();
|
||||
if (field.datatype == References.DOUBLE_ID) {
|
||||
double d = (Double)field.value;
|
||||
fieldValue = String.valueOf((double)Math.round(d*100f) / 100D);
|
||||
@@ -71,11 +70,6 @@ public class ComponentFieldAdjuster extends ComponentBase {
|
||||
float d = (Float)field.value;
|
||||
fieldValue = String.valueOf((double)Math.round((double)(d*100f)) / 100D);
|
||||
}
|
||||
if (field.datatype == References.INT_ID && !StringUtils.isNullOrEmpty(field.modifier) && field.modifier.equals("AOE")){
|
||||
int i = (Integer) field.value;
|
||||
i *= 2;
|
||||
fieldValue = String.valueOf((i+1) + "x" + (i+1));
|
||||
}
|
||||
|
||||
int centre = fontRendererObj.getStringWidth(fieldName) / 2;
|
||||
int centre2 = fontRendererObj.getStringWidth(fieldValue) / 2;
|
||||
|
||||
+2
-9
@@ -10,7 +10,6 @@ import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -79,13 +78,7 @@ public class ComponentFieldButton extends ComponentBase {
|
||||
public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
if (isMouseOver(mouseX, mouseY)) {
|
||||
List list = new ArrayList();
|
||||
list.add(String.valueOf(field.value));
|
||||
if (field.datatype == References.INT_ID && !StringUtils.isNullOrEmpty(field.modifier) && field.modifier.equals("AOE")){
|
||||
list.clear();
|
||||
int i = (Integer) field.value;
|
||||
i *= 2;
|
||||
list.add(String.valueOf((i+1) + "x" + (i+1)));
|
||||
}
|
||||
list.add(field.getFormatedValue());
|
||||
drawHoveringText(list, mouseX + offsetX, mouseY + offsetY + 10, fontRendererObj);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +95,6 @@ public class ComponentFieldButton extends ComponentBase {
|
||||
}
|
||||
return;
|
||||
}
|
||||
gui.editField(field);
|
||||
gui.setFieldBeingEdited(field);
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.brandon3055.draconicevolution.client.interfaces.guicomponents;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 13/01/2015.
|
||||
*/
|
||||
public class ComponentSlotBackground extends ComponentBase{
|
||||
|
||||
private static final ResourceLocation widgets = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/Widgets.png");
|
||||
|
||||
public ComponentSlotBackground(int x, int y) {
|
||||
super(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
minecraft.renderEngine.bindTexture(widgets);
|
||||
drawTexturedModalRect(x, y, 119, 1, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
public static ComponentCollection addInventorySlots(ComponentCollection c, int xOffset, int yOffset, int lockedSlot)
|
||||
{
|
||||
for (int x = 0; x < 9; x++) if (x != lockedSlot) c.addComponent(new ComponentSlotBackground(xOffset + x * 18, yOffset + 58)).setGroup("INVENTORY");
|
||||
|
||||
for (int y = 0; y < 3; y++){
|
||||
for (int x = 0; x < 9; x++) if (x + y * 9 + 9 != lockedSlot) c.addComponent(new ComponentSlotBackground(xOffset + x * 18, yOffset + y * 18)).setGroup("INVENTORY");
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.brandon3055.draconicevolution.client.interfaces.guicomponents;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 29/12/2014.
|
||||
*/
|
||||
public class ComponentTexturedRect extends ComponentBase {
|
||||
private int width;
|
||||
private int height;
|
||||
private int texX = 0;
|
||||
private int texY = 0;
|
||||
private final ResourceLocation texture;
|
||||
private boolean transparent = false;
|
||||
|
||||
public ComponentTexturedRect(int x, int y, int width, int height, ResourceLocation texture) {
|
||||
super(x, y);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.texture = texture;
|
||||
}
|
||||
public ComponentTexturedRect(int x, int y, int texX, int texY, int width, int height, ResourceLocation texture, boolean transparent) {
|
||||
super(x, y);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.texture = texture;
|
||||
this.texX = texX;
|
||||
this.texY = texY;
|
||||
this.transparent = transparent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
if (transparent)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
}
|
||||
GL11.glColor4f(1f, 1f, 1f, 1f);
|
||||
drawTexturedModalRect(x, y, texX, texY, width, height);
|
||||
if (transparent)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.GuiHandler;
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.ToolHandler;
|
||||
import com.brandon3055.draconicevolution.common.network.ButtonPacket;
|
||||
import com.brandon3055.draconicevolution.common.network.PlacedItemPacket;
|
||||
import com.brandon3055.draconicevolution.common.network.TeleporterPacket;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -28,6 +29,7 @@ public class KeyInputHandler {
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
if(KeyBindings.placeItem.isPressed()) handlePlaceItemKey();
|
||||
if(KeyBindings.toolConfig.isPressed()) {
|
||||
DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLCONFIG, false));
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
player.openGui(DraconicEvolution.instance, GuiHandler.GUIID_TOOL_CONFIG, Minecraft.getMinecraft().theWorld, (int)player.posX, (int)player.posY, (int)player.posZ);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class CommonProxy {
|
||||
public abstract class CommonProxy {
|
||||
//private final static boolean debug = DraconicEvolution.debug;
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
@@ -106,6 +106,7 @@ public class CommonProxy {
|
||||
DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 7, Side.CLIENT);
|
||||
DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 8, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(ItemConfigPacket.Handler.class, ItemConfigPacket.class, 9, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 10, Side.SERVER);
|
||||
}
|
||||
|
||||
public void registerTileEntities() {
|
||||
@@ -158,7 +159,7 @@ public class CommonProxy {
|
||||
EntityRegistry.registerModEntity(EntityDragonHeart.class, "Dragon Heart Item", 5, DraconicEvolution.instance, 32, 5, true);
|
||||
}
|
||||
|
||||
public boolean isClientSide(){return false;}
|
||||
public abstract boolean isDedicatedServer();
|
||||
|
||||
public MinecraftServer getMCServer(){
|
||||
return FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.brandon3055.draconicevolution.common;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 16/01/2015.
|
||||
*/
|
||||
public class ServerProxy extends CommonProxy {
|
||||
@Override
|
||||
public boolean isDedicatedServer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class SafetyFlame extends BlockFire{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {
|
||||
super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_);
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
}
|
||||
}
|
||||
+12
@@ -15,7 +15,9 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,4 +84,14 @@ public class EnergyInfuser extends BlockCustomDrop {
|
||||
protected void getCustomTileEntityDrops(TileEntity te, List<ItemStack> droppes) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
package com.brandon3055.draconicevolution.common.container;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.inventory.InventoryTool;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 13/01/2015.
|
||||
*/
|
||||
public class ContainerAdvTool extends ContainerDataSync {
|
||||
|
||||
public InventoryTool inventoryTool;
|
||||
private EntityPlayer player;
|
||||
public int inventoryItemSlot = -1;
|
||||
private boolean slotsActive = false;
|
||||
|
||||
public ContainerAdvTool(InventoryPlayer invPlayer, InventoryTool inventory) {
|
||||
this.inventoryTool = inventory;
|
||||
this.inventoryTool.setContainer(this);
|
||||
this.player = invPlayer.player;
|
||||
}
|
||||
|
||||
public void setSlotsActive(boolean active) {
|
||||
slotsActive = active;
|
||||
inventoryItemStacks = new ArrayList();
|
||||
inventorySlots = new ArrayList();
|
||||
|
||||
if (slotsActive)
|
||||
{
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new SlotPlayerInv(player.inventory, x, 8 + 18 * x, 103, inventoryItemSlot));
|
||||
}
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new SlotPlayerInv(player.inventory, x + y * 9 + 9, 8 + 18 * x, 45 + y * 18, inventoryItemSlot));
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < inventoryTool.size; x++) {
|
||||
addSlotToContainer(new SlotOblitFilter(inventoryTool, x, 8 + 18 * x, 19));
|
||||
}
|
||||
|
||||
for (int y = 0; y < 5; y++) {
|
||||
addSlotToContainer(new Slot(inventoryTool, inventoryTool.size + y, 173, 19 + y * 21));
|
||||
}
|
||||
}
|
||||
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
sendObjectToServer(null, 1, active ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInventory(InventoryTool inventory) {
|
||||
this.inventoryTool = inventory;
|
||||
}
|
||||
|
||||
public void setPlayer(EntityPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int i)
|
||||
{
|
||||
// Slot slot = getSlot(i);
|
||||
//
|
||||
// if (slot != null && slot.getHasStack())
|
||||
// {
|
||||
// ItemStack stack = slot.getStack();
|
||||
// ItemStack result = stack.copy();
|
||||
//
|
||||
// if (i >= 36){ //To player
|
||||
// if (!mergeItemStack(stack, 0, 36, false)){
|
||||
// return null;
|
||||
// }
|
||||
// }else if (stack.stackSize != 1 || !(stack.getItem() instanceof IEnergyContainerItem) || !mergeItemStack(stack, 36, 37, false)){
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (stack.stackSize == 0) {
|
||||
// slot.putStack(null);
|
||||
// }else{
|
||||
// slot.onSlotChanged();
|
||||
// }
|
||||
//
|
||||
// slot.onPickupFromSlot(player, stack);
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSyncData(int index, int value) {
|
||||
if (index == 0)
|
||||
{
|
||||
updateInventoryStack(value);
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
setSlotsActive(value == 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateInventoryStack(int slot){
|
||||
this.inventoryItemSlot = slot;
|
||||
if (player.worldObj.isRemote){
|
||||
sendObjectToServer(null, 0, slot);
|
||||
}
|
||||
|
||||
if (player.inventory.getStackInSlot(slot) != null && player.inventory.getStackInSlot(slot).getItem() instanceof MiningTool){
|
||||
this.inventoryTool.setAndReadFromStack(player.inventory.getStackInSlot(slot), slot);
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotPlayerInv extends Slot
|
||||
{
|
||||
public int inventoryItemSlot = -1;
|
||||
public SlotPlayerInv(IInventory iInventory, int slot, int x, int y, int inventoryItemSlot) {
|
||||
super(iInventory, slot, x, y);
|
||||
this.inventoryItemSlot = inventoryItemSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player) {
|
||||
return this.inventoryItemSlot != this.slotNumber && super.canTakeStack(player);
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotOblitFilter extends Slot
|
||||
{
|
||||
public SlotOblitFilter(IInventory iInventory, int slot, int x, int y) {
|
||||
super(iInventory, slot, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack != null && stack.getItem() instanceof ItemBlock && super.isItemValid(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-3
@@ -20,14 +20,24 @@ public abstract class ContainerDataSync extends Container {
|
||||
* value.
|
||||
* if tile != null the packet will be sent to the tile client tile instead of the client container.
|
||||
*/
|
||||
public Object sendObject(TileObjectSync tile, short dataType, int index, Object object){
|
||||
public Object sendObjectToClient(TileObjectSync tile, int index, Object object){
|
||||
for (Object p : crafters){
|
||||
DraconicEvolution.network.sendTo(new TileObjectPacket(tile, References.INT_ID, index, object), (EntityPlayerMP)p);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
/**Called when the client receives a sync packet from the server*/
|
||||
/**
|
||||
* Sends two ints to the server-side Container. Normally the first int identifies which variable to update, and the second contains the new
|
||||
* value.
|
||||
* if tile != null the packet will be sent to the tile client tile instead of the client container.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void receiveSyncData(int index, Object value);
|
||||
public Object sendObjectToServer(TileObjectSync tile, int index, Object object){
|
||||
DraconicEvolution.network.sendToServer(new TileObjectPacket(tile, References.INT_ID, index, object));
|
||||
return object;
|
||||
}
|
||||
|
||||
/**Called when a packet is received from ether the client or the server*/
|
||||
public abstract void receiveSyncData(int index, int value);
|
||||
}
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
package com.brandon3055.draconicevolution.common.container;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.inventory.SlotChargable;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -77,14 +76,14 @@ public class ContainerEnergyInfuser extends ContainerDataSync {
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (tile.energy.getEnergyStored() != lastTickEnergyStorage){
|
||||
sendObject(null, References.INT_ID, 0, tile.energy.getEnergyStored());
|
||||
sendObjectToClient(null, 0, tile.energy.getEnergyStored());
|
||||
lastTickEnergyStorage = tile.energy.getEnergyStored();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveSyncData(int index, Object value) {
|
||||
tile.energy.setEnergyStored((Integer)value);
|
||||
public void receiveSyncData(int index, int value) {
|
||||
tile.energy.setEnergyStored(value);
|
||||
}
|
||||
}
|
||||
+7
-8
@@ -1,6 +1,5 @@
|
||||
package com.brandon3055.draconicevolution.common.container;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.inventory.SlotItemValid;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGenerator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -75,16 +74,16 @@ public class ContainerGenerator extends ContainerDataSync {
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (energyCach != tile.getEnergyStored(ForgeDirection.UP)) energyCach = (Integer) sendObject(null, References.INT_ID, 0, tile.getEnergyStored(ForgeDirection.UP));
|
||||
if (burnCach != tile.burnTime) burnCach = (Integer) sendObject(null, References.INT_ID, 1, tile.burnTime);
|
||||
if (burnRemainingCach != tile.burnTimeRemaining) burnRemainingCach = (Integer) sendObject(null, References.INT_ID, 2, tile.burnTimeRemaining);
|
||||
if (energyCach != tile.getEnergyStored(ForgeDirection.UP)) energyCach = (Integer) sendObjectToClient(null, 0, tile.getEnergyStored(ForgeDirection.UP));
|
||||
if (burnCach != tile.burnTime) burnCach = (Integer) sendObjectToClient(null, 1, tile.burnTime);
|
||||
if (burnRemainingCach != tile.burnTimeRemaining) burnRemainingCach = (Integer) sendObjectToClient(null, 2, tile.burnTimeRemaining);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveSyncData(int index, Object object) {
|
||||
if (index == 0)tile.storage.setEnergyStored((Integer)object);
|
||||
else if (index == 1) tile.burnTime = (Integer)object;
|
||||
else if (index == 2) tile.burnTimeRemaining = (Integer)object;
|
||||
public void receiveSyncData(int index, int i) {
|
||||
if (index == 0)tile.storage.setEnergyStored(i);
|
||||
else if (index == 1) tile.burnTime = i;
|
||||
else if (index == 2) tile.burnTimeRemaining = i;
|
||||
}
|
||||
}
|
||||
+9
-10
@@ -1,6 +1,5 @@
|
||||
package com.brandon3055.draconicevolution.common.container;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.inventory.SlotItemValid;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGrinder;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -79,19 +78,19 @@ public class ContainerGrinder extends ContainerDataSync {
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (energyCach != tile.externalInputBuffer.getEnergyStored()) energyCach = (Integer) sendObject(null, References.INT_ID, 0, tile.externalInputBuffer.getEnergyStored());
|
||||
if (energy2Cach != tile.internalGenBuffer.getEnergyStored()) energy2Cach = (Integer) sendObject(null, References.INT_ID, 1, tile.internalGenBuffer.getEnergyStored());
|
||||
if (burnCach != tile.burnTime) burnCach = (Integer) sendObject(null, References.INT_ID, 2, tile.burnTime);
|
||||
if (burnRemainingCach != tile.burnTimeRemaining) burnRemainingCach = (Integer) sendObject(null, References.INT_ID, 3, tile.burnTimeRemaining);
|
||||
if (energyCach != tile.externalInputBuffer.getEnergyStored()) energyCach = (Integer) sendObjectToClient(null, 0, tile.externalInputBuffer.getEnergyStored());
|
||||
if (energy2Cach != tile.internalGenBuffer.getEnergyStored()) energy2Cach = (Integer) sendObjectToClient(null, 1, tile.internalGenBuffer.getEnergyStored());
|
||||
if (burnCach != tile.burnTime) burnCach = (Integer) sendObjectToClient(null, 2, tile.burnTime);
|
||||
if (burnRemainingCach != tile.burnTimeRemaining) burnRemainingCach = (Integer) sendObjectToClient(null, 3, tile.burnTimeRemaining);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveSyncData(int index, Object object) {
|
||||
if (index == 0) tile.externalInputBuffer.setEnergyStored((Integer)object);
|
||||
else if (index == 1) tile.internalGenBuffer.setEnergyStored((Integer)object);
|
||||
else if (index == 2) tile.burnTime = (Integer)object;
|
||||
else if (index == 3) tile.burnTimeRemaining = (Integer)object;
|
||||
public void receiveSyncData(int index, int i) {
|
||||
if (index == 0) tile.externalInputBuffer.setEnergyStored(i);
|
||||
else if (index == 1) tile.internalGenBuffer.setEnergyStored(i);
|
||||
else if (index == 2) tile.burnTime = i;
|
||||
else if (index == 3) tile.burnTimeRemaining = i;
|
||||
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.brandon3055.draconicevolution.common.container;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 15/01/2015.
|
||||
*/
|
||||
public class ContainerToolConfig extends ContainerDataSync {//todo delete
|
||||
public int slot = -1;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSyncData(int index, int value) {
|
||||
if (index == 0) slot = value;
|
||||
}
|
||||
|
||||
public void setSlot(int slot){
|
||||
if (DraconicEvolution.proxy.isDedicatedServer()){
|
||||
sendObjectToServer(null, 0, slot);
|
||||
}
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -40,6 +40,7 @@ import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
@@ -47,6 +48,7 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
@@ -326,4 +328,20 @@ public class MinecraftForgeEventHandler {
|
||||
public void worldUnload(WorldEvent.Unload e) {
|
||||
TileGrinder.fakePlayer = null;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerInteract(PlayerInteractEvent event){
|
||||
if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK){
|
||||
|
||||
ForgeDirection face = ForgeDirection.getOrientation(event.face);
|
||||
int x = event.x + face.offsetX;
|
||||
int y = event.y + face.offsetY;
|
||||
int z = event.z + face.offsetZ;
|
||||
if (event.world.getBlock(x, y, z) == ModBlocks.safetyFlame){
|
||||
event.world.setBlockToAir(x, y, z);
|
||||
event.world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.fizz", 1F, event.world.rand.nextFloat() * 0.1F + 2F);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package com.brandon3055.draconicevolution.common.inventory;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerAdvTool;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 13/01/2015.
|
||||
*/
|
||||
public class InventoryTool implements IInventory {
|
||||
|
||||
public int size;
|
||||
ItemStack inventoryItem;
|
||||
private ItemStack[] inventoryStacks;
|
||||
private EntityPlayer player;
|
||||
private ContainerAdvTool container;
|
||||
private int slot = -1;
|
||||
|
||||
public InventoryTool(EntityPlayer player, ItemStack stack){
|
||||
this.inventoryItem = stack;
|
||||
this.player = player;
|
||||
if (stack != null && stack.getItem() instanceof MiningTool){
|
||||
this.size = ((MiningTool) stack.getItem()).getInventorySlots();
|
||||
readFromNBT(ItemNBTHelper.getCompound(inventoryItem));
|
||||
}
|
||||
this.inventoryStacks = new ItemStack[size + 5];
|
||||
}
|
||||
|
||||
public void setAndReadFromStack(ItemStack stack, int slot){
|
||||
this.slot = slot;
|
||||
this.inventoryItem = stack;
|
||||
this.size = ((MiningTool) stack.getItem()).getInventorySlots();
|
||||
this.inventoryStacks = new ItemStack[size + 5];
|
||||
readFromNBT(ItemNBTHelper.getCompound(inventoryItem));
|
||||
}
|
||||
|
||||
public void setContainer(ContainerAdvTool container) { this.container = container; }
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return inventoryStacks.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
return inventoryStacks[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int count)
|
||||
{
|
||||
ItemStack itemstack = getStackInSlot(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack.stackSize <= count)
|
||||
{
|
||||
setInventorySlotContents(i, null);
|
||||
} else
|
||||
{
|
||||
itemstack = itemstack.splitStack(count);
|
||||
if (itemstack.stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
ItemStack item = getStackInSlot(i);
|
||||
if (item != null)
|
||||
setInventorySlotContents(i, null);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
inventoryStacks[i] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return inventoryItem != null && inventoryItem.getItem() instanceof MiningTool ? !StringUtils.isNullOrEmpty(((MiningTool) inventoryItem.getItem()).getInventoryName()) ? ((MiningTool) inventoryItem.getItem()).getInventoryName() : "" : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
for (int i = 0; i < getSizeInventory(); ++i)
|
||||
{
|
||||
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
|
||||
inventoryStacks[i] = null;
|
||||
}
|
||||
}
|
||||
if (inventoryItem != null) {
|
||||
writeToNBT(ItemNBTHelper.getCompound(inventoryItem));
|
||||
readFromNBT(ItemNBTHelper.getCompound(inventoryItem));
|
||||
}
|
||||
else LogHelper.error("[InventoryItem] storage item == null This is not a good thing...");
|
||||
|
||||
|
||||
container.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return itemstack.isItemEqual(new ItemStack(Items.emerald));
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
NBTTagCompound[] tag = new NBTTagCompound[size];
|
||||
NBTTagList enchList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < getSizeInventory(); i++)
|
||||
{
|
||||
if (i < size)
|
||||
{
|
||||
tag[i] = new NBTTagCompound();
|
||||
|
||||
if (inventoryStacks[i] != null)
|
||||
{
|
||||
tag[i] = inventoryStacks[i].writeToNBT(tag[i]);
|
||||
}
|
||||
|
||||
compound.setTag("Item" + i, tag[i]);
|
||||
}
|
||||
else if (inventoryStacks[i] != null)
|
||||
{
|
||||
if (inventoryStacks[i].getTagCompound() == null) inventoryStacks[i] = null;
|
||||
else
|
||||
{
|
||||
enchList.appendTag(inventoryStacks[i].getTagCompound().getTagList("StoredEnchantments", 10).getCompoundTagAt(0));
|
||||
|
||||
}
|
||||
}
|
||||
compound.setTag("ench", enchList);
|
||||
}
|
||||
|
||||
// for (int i = size; i < getSizeInventory(); i++)
|
||||
// {
|
||||
// if (inventoryStacks[i] != null && inventoryStacks[i].getItem() == Items.enchanted_book && inventoryStacks[i].hasTagCompound() && inventoryStacks[i].getTagCompound().hasKey("StoredEnchantments"))
|
||||
// {
|
||||
// NBTTagList enchants = inventoryStacks[i].getTagCompound().getTagList("StoredEnchantments", 10);
|
||||
// compound.setTag("ench", enchants);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench");
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
NBTTagCompound[] tag = new NBTTagCompound[size];
|
||||
NBTTagList enchList = null;
|
||||
if (compound.hasKey("ench")) enchList = compound.getTagList("ench", 10);
|
||||
|
||||
for (int i = 0; i < getSizeInventory(); i++)
|
||||
{
|
||||
if (i < size)
|
||||
{
|
||||
tag[i] = compound.getCompoundTag("Item" + i);
|
||||
inventoryStacks[i] = ItemStack.loadItemStackFromNBT(tag[i]);
|
||||
}
|
||||
else if (enchList != null && enchList.tagCount() > i-size)
|
||||
{
|
||||
inventoryStacks[i] = new ItemStack(Items.enchanted_book);
|
||||
inventoryStacks[i].setTagCompound(new NBTTagCompound());
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(enchList.getCompoundTagAt(i - size));
|
||||
inventoryStacks[i].getTagCompound().setTag("StoredEnchantments", list);
|
||||
}
|
||||
}
|
||||
|
||||
// if (compound.hasKey("ench"))
|
||||
// {
|
||||
// NBTTagList enchants = compound.getTagList("ench", 10);
|
||||
// for (int i = size; i < getSizeInventory(); i++)
|
||||
// {
|
||||
// if (!enchants.getCompoundTagAt(i - size).hasNoTags())
|
||||
// {
|
||||
// inventoryStacks[i] = new ItemStack(Items.enchanted_book);
|
||||
// NBTTagCompound compound1 = new NBTTagCompound();
|
||||
// NBTTagList list = new NBTTagList();
|
||||
// list.appendTag(enchants.getCompoundTagAt(i - size));
|
||||
// compound1.setTag("StoredEnchantments", list);
|
||||
// inventoryStacks[i].setTagCompound(compound1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+24
-7
@@ -4,6 +4,11 @@ import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DraconicAxe extends MiningTool {
|
||||
|
||||
@@ -18,16 +23,28 @@ public class DraconicAxe extends MiningTool {
|
||||
ModItems.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemConfigField> getFields(ItemStack stack, int slot) {
|
||||
List<ItemConfigField> list = super.getFields(stack, slot);
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, 3, 1).readFromItem(stack, 0).setModifier("AOE"));
|
||||
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.TREE_MODE).readFromItem(stack, true));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlots() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnchantValid(Enchantment enchant) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
+18
-205
@@ -6,36 +6,14 @@ import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DraconicDistructionStaff extends MiningTool {
|
||||
// public IIcon itemIcon0;
|
||||
// public IIcon itemIcon1;
|
||||
// public IIcon itemIcon2;
|
||||
// protected int capacity = References.DRACONICCAPACITY * 3;
|
||||
// protected int maxReceive = References.DRACONICTRANSFER;
|
||||
// protected int maxExtract = References.DRACONICTRANSFER * 50;
|
||||
|
||||
// private static Set<Block> minableBlocks = Sets.newHashSet();
|
||||
/* private static final Set<Block> field_150915_c = Sets.newHashSet(new Block[]{Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail});
|
||||
private static final Set<Block> field_150916_c = Sets.newHashSet(new Block[]{Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium});
|
||||
private static final Set<Block> field_150917_c = Sets.newHashSet(new Block[]{Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin});
|
||||
|
||||
static {
|
||||
for (Block block : field_150915_c) {
|
||||
minableBlocks.add(block);
|
||||
}
|
||||
for (Block block : field_150916_c) {
|
||||
|
||||
minableBlocks.add(block);
|
||||
}
|
||||
for (Block block : field_150917_c) {
|
||||
|
||||
minableBlocks.add(block);
|
||||
}
|
||||
}*/
|
||||
|
||||
public DraconicDistructionStaff() {
|
||||
super(ModItems.DRACONIUM_T3);
|
||||
@@ -50,7 +28,6 @@ public class DraconicDistructionStaff extends MiningTool {
|
||||
ModItems.register(this);
|
||||
}
|
||||
|
||||
//Mines all materials at full speed
|
||||
@Override
|
||||
public float func_150893_a(ItemStack stack, Block block) {
|
||||
return this.efficiencyOnProperMaterial;
|
||||
@@ -62,118 +39,27 @@ public class DraconicDistructionStaff extends MiningTool {
|
||||
List<ItemConfigField> list = super.getFields(stack, slot);
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, 4, 1).readFromItem(stack, 0).setModifier("AOE"));
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, 9, 1).readFromItem(stack, 1));
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.ATTACK_AOE).setMinMaxAndIncromente(0, 12, 1).readFromItem(stack, 1).setModifier("AOE"));
|
||||
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StatCollector.translateToLocal("info.de.toolInventory.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlots() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnchantValid(Enchantment enchant) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// public boolean isItemTool(ItemStack p_77616_1_) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// @SuppressWarnings("unchecked")
|
||||
// @Override
|
||||
// public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
// list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0));
|
||||
// list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUnlocalizedName(){
|
||||
//
|
||||
// return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUnlocalizedName(final ItemStack itemStack){
|
||||
// return getUnlocalizedName();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean func_150897_b(Block block) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public float func_150893_a(ItemStack stack, Block block) {
|
||||
// return this.efficiencyOnProperMaterial;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerIcons(IIconRegister iconRegister) {
|
||||
// this.itemIcon0 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_staff");
|
||||
// this.itemIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_staff_active");
|
||||
// this.itemIcon2 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_staff_obliterate");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
|
||||
// if (ItemNBTHelper.getShort(stack, "size", (short) 0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
|
||||
// return itemIcon2;
|
||||
// else if (ItemNBTHelper.getShort(stack, "size", (short) 0) > 0) return itemIcon1;
|
||||
// else return itemIcon0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIconIndex(ItemStack stack) {
|
||||
// if (ItemNBTHelper.getShort(stack, "size", (short) 0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
|
||||
// return itemIcon2;
|
||||
// else if (ItemNBTHelper.getShort(stack, "size", (short) 0) > 0) return itemIcon1;
|
||||
// else return itemIcon0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
// World world = player.worldObj;
|
||||
// Block block = world.getBlock(x, y, z);
|
||||
// Material mat = block.getMaterial();
|
||||
// if (!ToolHandler.isRightMaterial(mat, ToolHandler.materialsDStaff)) {
|
||||
// return false;
|
||||
// }
|
||||
// int fortune = EnchantmentHelper.getFortuneModifier(player);
|
||||
// boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
|
||||
// ToolHandler.disSquare(x, y, z, player, world, silk, fortune, ToolHandler.materialsDStaff, stack);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
// return ToolHandler.changeMode(stack, player, true, 4);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
// ToolHandler.AOEAttack(player, entity, stack, 25, ItemNBTHelper.getShort(stack, "size", (short) 0) * 2);
|
||||
// ToolHandler.damageEntityBasedOnHealth(entity, player, 0.5F);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings({"unchecked"})
|
||||
// @Override
|
||||
// public Multimap getItemAttributeModifiers() {
|
||||
// Multimap multimap = super.getItemAttributeModifiers();
|
||||
// multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double) 4.0F + ModItems.DRACONIUM_T2.getDamageVsEntity(), 0));
|
||||
// return multimap;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings({"unchecked"})
|
||||
// @Override
|
||||
// public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) {
|
||||
@@ -196,77 +82,4 @@ public class DraconicDistructionStaff extends MiningTool {
|
||||
// public EnumRarity getRarity(ItemStack stack) {
|
||||
// return EnumRarity.epic;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
//
|
||||
// if (container.stackTagCompound == null) {
|
||||
// container.stackTagCompound = new NBTTagCompound();
|
||||
// }
|
||||
// int energy = container.stackTagCompound.getInteger("Energy");
|
||||
// int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
//
|
||||
// if (!simulate) {
|
||||
// energy += energyReceived;
|
||||
// container.stackTagCompound.setInteger("Energy", energy);
|
||||
// }
|
||||
// return energyReceived;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
//
|
||||
// if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
// return 0;
|
||||
// }
|
||||
// int energy = container.stackTagCompound.getInteger("Energy");
|
||||
// int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
//
|
||||
// if (!simulate) {
|
||||
// energy -= energyExtracted;
|
||||
// container.stackTagCompound.setInteger("Energy", energy);
|
||||
// }
|
||||
// return energyExtracted;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getEnergyStored(ItemStack container) {
|
||||
// if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
// return 0;
|
||||
// }
|
||||
// return container.stackTagCompound.getInteger("Energy");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getMaxEnergyStored(ItemStack container) {
|
||||
// return capacity;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean showDurabilityBar(ItemStack stack) {
|
||||
// return !(getEnergyStored(stack) == getMaxEnergyStored(stack));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double getDurabilityForDisplay(ItemStack stack) {
|
||||
// return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
||||
// if ((stack.getItem() instanceof IEnergyContainerItem) && ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) >= References.ENERGYPERBLOCK)
|
||||
// return super.getDigSpeed(stack, block, meta);
|
||||
// else
|
||||
// return 1F;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean hasCustomEntity(ItemStack stack) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Entity createEntity(World world, Entity location, ItemStack itemstack) {
|
||||
// return new EntityPersistentItem(world, location, itemstack);
|
||||
// }
|
||||
}
|
||||
+25
-14
@@ -4,6 +4,12 @@ import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DraconicPickaxe extends MiningTool {
|
||||
|
||||
@@ -20,23 +26,28 @@ public class DraconicPickaxe extends MiningTool {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemConfigField> getFields(ItemStack stack, int slot) {
|
||||
List<ItemConfigField> list = super.getFields(stack, slot);
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, 3, 1).readFromItem(stack, 0).setModifier("AOE"));
|
||||
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StatCollector.translateToLocal("info.de.toolInventory.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlots() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnchantValid(Enchantment enchant) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
|
||||
+25
-10
@@ -4,6 +4,12 @@ import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DraconicShovel extends MiningTool {
|
||||
// public IIcon itemIcon0;
|
||||
@@ -24,19 +30,28 @@ public class DraconicShovel extends MiningTool {
|
||||
ModItems.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemConfigField> getFields(ItemStack stack, int slot) {
|
||||
List<ItemConfigField> list = super.getFields(stack, slot);
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, 3, 1).readFromItem(stack, 0).setModifier("AOE"));
|
||||
list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StatCollector.translateToLocal("info.de.toolInventory.txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlots() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnchantValid(Enchantment enchant) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.brandon3055.draconicevolution.common.items.ItemDE;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.Teleporter.TeleportLocation;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -107,7 +106,6 @@ public class TeleporterMKI extends ItemDE {
|
||||
if (player.getHealth() > 2 || player.capabilities.isCreativeMode)
|
||||
{
|
||||
getLocation(stack).sendEntityToCoords(player);
|
||||
LogHelper.info(getLocation(stack).getYCoord());
|
||||
stack.damageItem(1, player);
|
||||
if (!player.capabilities.isCreativeMode) player.setHealth(player.getHealth() - 2);
|
||||
} else if (world.isRemote)
|
||||
|
||||
+23
-19
@@ -4,13 +4,13 @@ import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WyvernPickaxe extends MiningTool {
|
||||
// public IIcon itemIcon0;
|
||||
// public IIcon itemIcon1;
|
||||
// protected int capacity = References.WYVERNCAPACITY;
|
||||
// protected int maxReceive = References.WYVERNTRANSFER;
|
||||
// protected int maxExtract = References.WYVERNTRANSFER;
|
||||
|
||||
public WyvernPickaxe() {
|
||||
super(ModItems.DRACONIUM_T1);
|
||||
@@ -23,23 +23,27 @@ public class WyvernPickaxe extends MiningTool {
|
||||
ModItems.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemConfigField> getFields(ItemStack stack, int slot) {
|
||||
List<ItemConfigField> list = super.getFields(stack, slot);
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, 1, 1).readFromItem(stack, 0).setModifier("AOE"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlots() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnchantValid(Enchantment enchant) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
|
||||
+23
-19
@@ -4,6 +4,11 @@ import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WyvernShovel extends MiningTool {
|
||||
|
||||
@@ -19,28 +24,27 @@ public class WyvernShovel extends MiningTool {
|
||||
ModItems.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemConfigField> getFields(ItemStack stack, int slot) {
|
||||
List<ItemConfigField> list = super.getFields(stack, slot);
|
||||
list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, 1, 1).readFromItem(stack, 0).setModifier("AOE"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlots() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnchantValid(Enchantment enchant) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
|
||||
+179
-167
@@ -1,198 +1,210 @@
|
||||
package com.brandon3055.draconicevolution.common.items.tools.baseclasses;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.C07PacketPlayerDigging;
|
||||
import net.minecraft.network.play.server.S18PacketEntityTeleport;
|
||||
import net.minecraft.network.play.server.S23PacketBlockChange;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 2/01/2015.
|
||||
*/
|
||||
public class MiningTool extends ToolBase {
|
||||
public abstract class MiningTool extends ToolBase {//todo add custom information to sub classes,
|
||||
|
||||
|
||||
public MiningTool(ToolMaterial material) {
|
||||
super(0, material, null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Set<Block> getObliterationList(ItemStack stack){
|
||||
return new HashSet<Block>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
int radius = ItemNBTHelper.getInteger(stack, References.DIG_AOE, 0);
|
||||
int depth = ItemNBTHelper.getInteger(stack, References.DIG_DEPTH, 1) - 1;
|
||||
|
||||
|
||||
return getEnergyStored(stack) >= energyPerOperation && (radius > 0 || depth > 0) ? breakAOEBlocks(stack, x, y, z, radius, depth, player) : super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
ToolHandler.updateGhostBlocks(player, world);
|
||||
LogHelper.info(DraconicEvolution.proxy.isDedicatedServer());
|
||||
return super.onItemRightClick(stack, world, player);
|
||||
}
|
||||
|
||||
//todo power, oblit, optimization, collection, Hud, Hud Config, shift right click, attack
|
||||
//This method is basses on tinkerers construct
|
||||
public boolean breakAOEBlocks(ItemStack stack, int x, int y, int z, int breakRadius, int breakDepth, EntityPlayer player) {
|
||||
|
||||
// only effective materials matter. We don't want to aoe when beraking dirt with a hammer.
|
||||
Block block = player.worldObj.getBlock(x,y,z);
|
||||
int meta = player.worldObj.getBlockMetadata(x,y,z);
|
||||
boolean effective = false;
|
||||
if(block != null)
|
||||
{
|
||||
for (String s : getToolClasses(stack))
|
||||
{
|
||||
if (block.isToolEffective(s, meta) || func_150893_a(stack, block) > 1F) effective = true;
|
||||
}
|
||||
}
|
||||
if (!effective) return true;
|
||||
|
||||
float refStrength = ForgeHooks.blockStrength(block, player, player.worldObj, x, y, z);
|
||||
|
||||
|
||||
MovingObjectPosition mop = ToolHandler.raytraceFromEntity(player.worldObj, player, 4.5d);
|
||||
if(mop == null)
|
||||
{
|
||||
ToolHandler.updateGhostBlocks(player, player.worldObj);
|
||||
return true;
|
||||
}
|
||||
int sideHit = mop.sideHit;
|
||||
|
||||
// we successfully destroyed a block. time to do AOE!
|
||||
int xRange = breakRadius;
|
||||
int yRange = breakRadius;
|
||||
int zRange = breakDepth;
|
||||
int yOffset = 0;
|
||||
switch (sideHit) {
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = breakDepth;
|
||||
zRange = breakRadius;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
xRange = breakRadius;
|
||||
zRange = breakDepth;
|
||||
yOffset = breakRadius - 1;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = breakDepth;
|
||||
zRange = breakRadius;
|
||||
yOffset = breakRadius - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
//
|
||||
// return super.onBlockStartBreak(stack, x, y, z, player);//breakAOEBlocks(stack, x, y, z, player);
|
||||
// }
|
||||
//
|
||||
// /* Harvest */
|
||||
//
|
||||
// /**Can Harvest Block*/
|
||||
// public boolean func_150897_b(Block block)
|
||||
// {
|
||||
// boolean flag = false;
|
||||
// Set<String> s = getToolClasses(null);
|
||||
// if (s.contains("shovel") && block == Blocks.snow_layer || block == Blocks.snow) flag = true;
|
||||
// if (s.contains("pickaxe")) flag = true;
|
||||
//
|
||||
// return flag;
|
||||
// }
|
||||
//
|
||||
// /**Get Strength vs block*/
|
||||
// public float func_150893_a(ItemStack stack, Block block)
|
||||
// {
|
||||
// boolean flag = false;
|
||||
// Set<String> s = getToolClasses(stack);
|
||||
// Material m = block.getMaterial();
|
||||
//
|
||||
// if (s.contains("shovel") && m == Material.clay || m == Material.craftedSnow || m == Material.sand || m == Material.grass || m == Material.snow || m == Material.ground) flag = true;
|
||||
// if (s.contains("pickaxe") && m == Material.) flag = true;
|
||||
//
|
||||
// LogHelper.info(flag);
|
||||
//
|
||||
// return flag ? this.efficiencyOnProperMaterial : super.func_150893_a(stack, block);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public boolean breakAOEBlocks(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
// int breakRadius = 2;
|
||||
// int breakDepth = 5;
|
||||
// // only effective materials matter. We don't want to aoe when beraking dirt with a hammer.
|
||||
// Block block = player.worldObj.getBlock(x,y,z);
|
||||
// int meta = player.worldObj.getBlockMetadata(x,y,z);
|
||||
//// if(block == null || (block.isToolEffective(toolClasses[0], meta) && block.isToolEffective(toolClasses[1], meta) && block.isToolEffective(toolClasses[2], meta)))//!isEffective(block, meta))
|
||||
//// return super.onBlockStartBreak(stack, x,y,z, player);
|
||||
//
|
||||
// MovingObjectPosition mop = ToolHandler.raytraceFromEntity(player.worldObj, player, 4.5d);
|
||||
// if(mop == null)
|
||||
// return super.onBlockStartBreak(stack, x,y,z, player);
|
||||
// int sideHit = mop.sideHit;
|
||||
// //int sideHit = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
||||
//
|
||||
// // we successfully destroyed a block. time to do AOE!
|
||||
// int xRange = breakRadius;
|
||||
// int yRange = breakRadius;
|
||||
// int zRange = breakDepth;
|
||||
// switch (sideHit) {
|
||||
// case 0:
|
||||
// case 1:
|
||||
// yRange = breakDepth;
|
||||
// zRange = breakRadius;
|
||||
// break;
|
||||
// case 2:
|
||||
// case 3:
|
||||
// xRange = breakRadius;
|
||||
// zRange = breakDepth;
|
||||
// break;
|
||||
// case 4:
|
||||
// case 5:
|
||||
// xRange = breakDepth;
|
||||
// zRange = breakRadius;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
// for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
// for (int zPos = z - zRange; zPos <= z + zRange; zPos++) {
|
||||
// // don't break the originally already broken block, duh
|
||||
// if (xPos == x && yPos == y && zPos == z)
|
||||
// continue;
|
||||
//
|
||||
// if(!super.onBlockStartBreak(stack, xPos, yPos, zPos, player))
|
||||
// breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x,y,z);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
// }
|
||||
//
|
||||
// protected void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer player, int refX, int refY, int refZ) {
|
||||
// // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events
|
||||
// if (world.isAirBlock(x, y, z))
|
||||
// return;
|
||||
//
|
||||
// // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian
|
||||
// // or precious ores you can't harvest while mining stone
|
||||
// Block block = world.getBlock(x, y, z);
|
||||
// int meta = world.getBlockMetadata(x, y, z);
|
||||
//
|
||||
//// if(block == null || (block.isToolEffective(toolClasses[0], meta) && block.isToolEffective(toolClasses[1], meta) && block.isToolEffective(toolClasses[2], meta)))//!isEffective(block, meta))
|
||||
//// return;
|
||||
// // only effective materials
|
||||
//// if (!isEffective(block, meta))
|
||||
//// return;
|
||||
//
|
||||
// Block refBlock = world.getBlock(refX, refY, refZ);
|
||||
// float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ);
|
||||
// float strength = ForgeHooks.blockStrength(block, player, world, x,y,z);
|
||||
//
|
||||
// // only harvestable blocks that aren't impossibly slow to harvest
|
||||
// if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f)
|
||||
// return;
|
||||
//
|
||||
// if (player.capabilities.isCreativeMode) {
|
||||
// block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
// if (block.removedByPlayer(world, player, x, y, z, false))
|
||||
// block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
//
|
||||
// // send update to client
|
||||
// if (!world.isRemote) {
|
||||
// ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // callback to the tool the player uses. Called on both sides. This damages the tool n stuff.
|
||||
// player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player);
|
||||
//
|
||||
// // server sided handling
|
||||
// if (!world.isRemote) {
|
||||
// // serverside we reproduce ItemInWorldManager.tryHarvestBlock
|
||||
//
|
||||
// // ItemInWorldManager.removeBlock
|
||||
// block.onBlockHarvested(world, x,y,z, meta, player);
|
||||
//
|
||||
// if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above
|
||||
// {
|
||||
// block.onBlockDestroyedByPlayer( world, x,y,z, meta);
|
||||
// block.harvestBlock(world, player, x,y,z, meta);
|
||||
// }
|
||||
//
|
||||
// // always send block update to client
|
||||
// EntityPlayerMP mpPlayer = (EntityPlayerMP) player;
|
||||
// mpPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||
// }
|
||||
// // client sided handling
|
||||
// else {
|
||||
// PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController;
|
||||
// // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets
|
||||
// // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy.
|
||||
//
|
||||
// // following code can be found in PlayerControllerMP.onPlayerDestroyBlock
|
||||
// world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
// if(block.removedByPlayer(world, player, x,y,z))
|
||||
// {
|
||||
// block.onBlockDestroyedByPlayer(world, x,y,z, meta);
|
||||
// }
|
||||
// pcmp.onPlayerDestroyBlock(x, y, z, sidehit);
|
||||
//
|
||||
// // send an update to the server, so we get an update back
|
||||
//// if(PHConstruct.extraBlockUpdates)
|
||||
//// Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
// }
|
||||
// }
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
{
|
||||
for (int yPos = y + yOffset - yRange; yPos <= y + yOffset + yRange; yPos++)
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
{
|
||||
breakExtraBlock(stack, player.worldObj, xPos, yPos, zPos, sideHit, player, refStrength, Math.abs(x - xPos) <= 1 && Math.abs(y - yPos) <= 1 && Math.abs(z - zPos) <= 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - xRange, y + yOffset - yRange, z - zRange, x + xRange + 1, y + yOffset + yRange + 1, z + zRange + 1));
|
||||
for (EntityItem item : items){
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
item.setLocationAndAngles(player.posX, player.posY, player.posZ, 0, 0);
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S18PacketEntityTeleport(item));
|
||||
item.delayBeforeCanPickup = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//This method is basses on tinkerers construct
|
||||
protected void breakExtraBlock(ItemStack stack, World world, int x, int y, int z, int sidehit, EntityPlayer player, float refStrength, boolean breakSound) {
|
||||
// prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events
|
||||
if (world.isAirBlock(x, y, z))
|
||||
return;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
boolean effective = false;
|
||||
if(block != null)
|
||||
{
|
||||
for (String s : getToolClasses(stack))
|
||||
{
|
||||
if (block.isToolEffective(s, meta) || func_150893_a(stack, block) > 1F) effective = true;
|
||||
}
|
||||
}
|
||||
if (!effective) return;
|
||||
|
||||
float strength = ForgeHooks.blockStrength(block, player, world, x,y,z);
|
||||
|
||||
// only harvestable blocks that aren't impossibly slow to harvest
|
||||
if (!player.canHarvestBlock(block) || !ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f)
|
||||
return;
|
||||
|
||||
if (player.capabilities.isCreativeMode || getObliterationList(stack).contains(block)) {
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
if (block.removedByPlayer(world, player, x, y, z, false))
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
|
||||
// send update to client
|
||||
if (!world.isRemote) {
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
extractEnergy(stack, energyPerOperation, false);
|
||||
|
||||
// server sided handling
|
||||
if (!world.isRemote) {
|
||||
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
|
||||
if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above
|
||||
{
|
||||
block.onBlockDestroyedByPlayer( world, x,y,z, meta);
|
||||
block.harvestBlock(world, player, x,y,z, meta);
|
||||
player.addExhaustion(-0.025F);
|
||||
}
|
||||
|
||||
// always send block update to client
|
||||
EntityPlayerMP mpPlayer = (EntityPlayerMP) player;
|
||||
mpPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||
}
|
||||
// client sided handlinge
|
||||
else {
|
||||
|
||||
if (breakSound) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
if(block.removedByPlayer(world, player, x,y,z, true))
|
||||
{
|
||||
block.onBlockDestroyedByPlayer(world, x,y,z, meta);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getInventoryName();
|
||||
|
||||
public abstract int getInventorySlots();
|
||||
|
||||
public abstract boolean isEnchantValid(Enchantment enchant);
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -2,6 +2,7 @@ package com.brandon3055.draconicevolution.common.items.tools.baseclasses;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utills.InfoHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -9,6 +10,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -122,4 +124,17 @@ public class ToolBase extends RFItemBase {
|
||||
if (!getToolClasses(stack).isEmpty()) list.add(new ItemConfigField(References.FLOAT_ID, slot, References.DIG_SPEED_MULTIPLIER).setMinMaxAndIncromente(0f, 1f, 0.01f).readFromItem(stack, 1f));
|
||||
return list;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) {
|
||||
boolean show = InfoHelper.holdShiftForDetails(list);
|
||||
if (show) InfoHelper.addEnergyInfo(stack, list);
|
||||
addAditionalInformation(stack, player, list, extended);
|
||||
if (show) InfoHelper.addLore(stack, list, true);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addAditionalInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) {
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -25,10 +25,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ToolHandler {
|
||||
public static Material[] materialsPick = {Material.anvil, Material.circuits, Material.coral, Material.glass, Material.ice, Material.iron, Material.rock};
|
||||
public static Material[] materialsShovel = {Material.clay, Material.ground, Material.grass, Material.sand, Material.snow, Material.craftedSnow};
|
||||
public static Material[] materialsAxe = {Material.cactus, Material.leaves, Material.wood, Material.plants};
|
||||
public static Material[] materialsDStaff = {Material.anvil, Material.circuits, Material.coral, Material.glass, Material.ice, Material.iron, Material.rock, Material.clay, Material.ground, Material.grass, Material.sand, Material.snow, Material.craftedSnow, Material.cactus, Material.leaves, Material.wood, Material.plants, Material.cloth};
|
||||
public static Block[] destroyList = {Blocks.cobblestone, Blocks.stone, Blocks.dirt, Blocks.gravel, Blocks.sand, Blocks.grass, Blocks.netherrack};
|
||||
|
||||
public static boolean isRightMaterial(final Material material, final Material[] materialsListing) {
|
||||
@@ -53,7 +49,7 @@ public class ToolHandler {
|
||||
int size = stack.getItem().equals(ModItems.draconicAxe) ? 2 : ItemNBTHelper.getShort(stack, "size", (short) 0);
|
||||
MovingObjectPosition mop = raytraceFromEntity(world, player, 4.5D);
|
||||
if (mop == null) {
|
||||
if (player instanceof EntityPlayer) updateGhostBlocks(player, world);
|
||||
updateGhostBlocks(player, world);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -297,7 +293,7 @@ public class ToolHandler {
|
||||
return world.rayTraceBlocks(vec3, vec31);
|
||||
}
|
||||
|
||||
private static void updateGhostBlocks(EntityPlayer player, World world) {
|
||||
public static void updateGhostBlocks(EntityPlayer player, World world) {
|
||||
int xPos = (int) player.posX;
|
||||
int yPos = (int) player.posY;
|
||||
int zPos = (int) player.posZ;
|
||||
|
||||
@@ -6,7 +6,7 @@ public final class References {
|
||||
public static final String VERSION = "1.0.1-snapshot_0";
|
||||
public static final String MCVERSION = "1.7.10";
|
||||
public static final String CLIENTPROXYLOCATION = "com.brandon3055.draconicevolution.client.ClientProxy";
|
||||
public static final String COMMONPROXYLOCATION = "com.brandon3055.draconicevolution.common.CommonProxy";
|
||||
public static final String SERVERPROXYLOCATION = "com.brandon3055.draconicevolution.common.ServerProxy";
|
||||
public static final String GUIFACTORY = "com.brandon3055.draconicevolution.client.interfaces.DEGUIFactory";
|
||||
public static final String RESOURCESPREFIX = MODID.toLowerCase() + ":";
|
||||
|
||||
@@ -41,4 +41,6 @@ public final class References {
|
||||
public static final String DIG_AOE = "ToolDigAOE";
|
||||
public static final String DIG_DEPTH = "ToolDigDepth";
|
||||
public static final String ATTACK_AOE = "WeaponAttackAOE";
|
||||
public static final String OBLITERATE = "ToolVoidJunk";
|
||||
public static final String TREE_MODE = "AxeTreeMode";
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.brandon3055.draconicevolution.common.network;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.GuiHandler;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerDissEnchanter;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerDraconiumChest;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerWeatherController;
|
||||
@@ -20,6 +22,8 @@ public class ButtonPacket implements IMessage
|
||||
public static final byte ID_DRACONIUMCHEST1 = 3;
|
||||
public static final byte ID_DRACONIUMCHEST2 = 4;
|
||||
public static final byte ID_DRACONIUMCHEST3 = 5;
|
||||
public static final byte ID_TOOLINVENTORY = 6;
|
||||
public static final byte ID_TOOLCONFIG = 7;
|
||||
byte buttonId = 0;
|
||||
boolean state = false;
|
||||
|
||||
@@ -101,6 +105,10 @@ public class ButtonPacket implements IMessage
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_TOOLCONFIG:
|
||||
{
|
||||
ctx.getServerHandler().playerEntity.openGui(DraconicEvolution.instance, GuiHandler.GUIID_TOOL_CONFIG, ctx.getServerHandler().playerEntity.worldObj, (int)ctx.getServerHandler().playerEntity.posX, (int)ctx.getServerHandler().playerEntity.posY, (int)ctx.getServerHandler().playerEntity.posZ);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
+28
-7
@@ -6,6 +6,7 @@ import com.brandon3055.draconicevolution.common.utills.DataUtills;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -74,13 +75,33 @@ public class TileObjectPacket implements IMessage{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(TileObjectPacket message, MessageContext ctx) {
|
||||
if (message.isContainerPacket){
|
||||
ContainerDataSync container = Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerDataSync ? (ContainerDataSync)Minecraft.getMinecraft().thePlayer.openContainer : null;
|
||||
if (container == null) return null;
|
||||
container.receiveSyncData(message.index, message.object);
|
||||
}else {
|
||||
if (!(Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z) instanceof TileObjectSync)) return null;
|
||||
((TileObjectSync) Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z)).receiveObject(message.index, message.object);
|
||||
if (ctx.side == Side.CLIENT)
|
||||
{
|
||||
if (message.isContainerPacket)
|
||||
{
|
||||
ContainerDataSync container = Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerDataSync ? (ContainerDataSync) Minecraft.getMinecraft().thePlayer.openContainer : null;
|
||||
if (container == null) return null;
|
||||
container.receiveSyncData(message.index, (Integer) message.object);
|
||||
} else
|
||||
{
|
||||
if (!(Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z) instanceof TileObjectSync))
|
||||
return null;
|
||||
((TileObjectSync) Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z)).receiveObject(message.index, message.object);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message.isContainerPacket)
|
||||
{
|
||||
ContainerDataSync container = ctx.getServerHandler().playerEntity.openContainer instanceof ContainerDataSync ? (ContainerDataSync) ctx.getServerHandler().playerEntity.openContainer : null;
|
||||
if (container == null) return null;
|
||||
container.receiveSyncData(message.index, (Integer) message.object);
|
||||
} else
|
||||
{
|
||||
if (!(ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z) instanceof TileObjectSync))
|
||||
return null;
|
||||
((TileObjectSync) ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z)).receiveObject(message.index, message.object);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-4
@@ -4,11 +4,10 @@ import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerDraconiumChest;
|
||||
import com.brandon3055.draconicevolution.common.lib.OreDoublingRegistry;
|
||||
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
|
||||
import com.brandon3055.draconicevolution.common.utills.ICustomItemData;
|
||||
import com.brandon3055.draconicevolution.common.utills.InventoryUtils;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.common.lib.OreDoublingRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -286,7 +285,6 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
|
||||
public void rotateAround(ForgeDirection axis) {
|
||||
setFacing((byte) ForgeDirection.getOrientation(facing).getRotation(axis).ordinal());
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7));
|
||||
LogHelper.info(facing);
|
||||
}
|
||||
|
||||
public int getFacing() {
|
||||
@@ -495,7 +493,6 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
|
||||
compound.setBoolean("Edit", editMode);
|
||||
compound.setByte("AutoFeed", (byte) smeltingAutoFeed);
|
||||
if (hasCustomInventoryName()) stack.setStackDisplayName(customName);
|
||||
LogHelper.info(stack.getDisplayName());
|
||||
energy.writeToNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.network.ItemConfigPacket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 29/12/2014.
|
||||
@@ -58,6 +59,18 @@ public class ItemConfigField {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFormatedValue(){
|
||||
if (datatype == References.INT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("AOE")){
|
||||
int i = (Integer) value;
|
||||
i *= 2;
|
||||
return String.valueOf((i + 1) + "x" + (i + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendChanges(){
|
||||
DraconicEvolution.network.sendToServer(new ItemConfigPacket(this));
|
||||
}
|
||||
|
||||
@@ -16,53 +16,6 @@ import net.minecraft.world.WorldServer;
|
||||
|
||||
public class Teleporter
|
||||
{
|
||||
// public static void teleport(EntityLivingBase entity, double x, double y, double z, float yaw, float pitch, int dim)
|
||||
// {
|
||||
// //if (entity.worldObj.isRemote) return;
|
||||
// if (entity instanceof EntityPlayerMP)
|
||||
// {
|
||||
// EntityPlayerMP thePlayer = (EntityPlayerMP) entity;
|
||||
// LogHelper.info(dim +" "+thePlayer.dimension);
|
||||
//
|
||||
// if (thePlayer.dimension == dim)
|
||||
// {
|
||||
// entity.setLocationAndAngles(x, y, z, yaw, pitch);
|
||||
// entity.setPositionAndUpdate(x, y, z);
|
||||
// } else
|
||||
// {
|
||||
// if (thePlayer.isRiding())
|
||||
// thePlayer.dismountEntity(thePlayer.ridingEntity);
|
||||
// // if (thePlayer.dimension == 1) thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z, yaw, pitch));
|
||||
// thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z, yaw, pitch));
|
||||
//
|
||||
// }
|
||||
// } else if (dim == entity.dimension)
|
||||
// {
|
||||
// entity.setLocationAndAngles(x, y, z, yaw, pitch);
|
||||
// entity.setPositionAndUpdate(x, y, z);
|
||||
// }
|
||||
// LogHelper.info(entity.dimension);
|
||||
// }
|
||||
//
|
||||
// public static void teleport(EntityPlayer player, double x, double y, double z)
|
||||
// {
|
||||
// if (player instanceof EntityPlayerMP)
|
||||
// {
|
||||
// EntityPlayerMP thePlayer = (EntityPlayerMP) player;
|
||||
//
|
||||
// if (thePlayer.dimension == 1)
|
||||
// {
|
||||
// if (thePlayer.isRiding())
|
||||
// thePlayer.dismountEntity(thePlayer.ridingEntity);
|
||||
// thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, thePlayer.dimension, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(thePlayer.dimension), x, y, z, 0, 0));
|
||||
// } else
|
||||
// {
|
||||
// if (thePlayer.isRiding())
|
||||
// thePlayer.dismountEntity(thePlayer.ridingEntity);
|
||||
// thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, thePlayer.dimension, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(thePlayer.dimension), x, y, z, 0, 0));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public static class TeleportLocation {
|
||||
protected double xCoord;
|
||||
@@ -220,7 +173,7 @@ public class Teleporter
|
||||
if (entity == null || entity.worldObj.isRemote) return entity;
|
||||
|
||||
World startWorld = entity.worldObj;
|
||||
World destinationWorld =DraconicEvolution.proxy.getMCServer().worldServerForDimension(destination.dimension);
|
||||
World destinationWorld = DraconicEvolution.proxy.getMCServer().worldServerForDimension(destination.dimension);
|
||||
|
||||
if (destinationWorld == null){
|
||||
LogHelper.error("Destination world dose not exist!");
|
||||
|
||||
Reference in new issue
Block a user