This commit is contained in:
brandon3055 committed 2015-04-04 13:16:51 +11:00
1 parent b4c07c2909
commit b2999e3653
43 files changed
+542 -196

No files matched your search

@@ -37,6 +37,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
@@ -225,4 +226,9 @@ public class ClientProxy extends CommonProxy {
{
return Minecraft.getMinecraft().theWorld.getWorldInfo().getGameType().isCreative();
}
@Override
public void spawnParticle(Object particle) {
if (particle instanceof EntityFX) ParticleHandler.spawnCustomParticle((EntityFX)particle);
}
}
@@ -5,6 +5,7 @@ import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.container.DummyContainer;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.InfoHelper;
import com.google.gson.stream.JsonReader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
@@ -32,7 +33,7 @@ public class GUIManual extends GUIScrollingBase {
if (currentPage != null)
{
collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE);
collection.addComponent(new ComponentButton(102, 325, 50, 20, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE);
collection.addComponent(new ComponentButton(102, 314, 50, 12, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE);
collection.setOnlyGroupEnabled(GR_BACKGROUND);
collection.setGroupEnabled(GR_PAGE, true);
}
@@ -51,7 +52,7 @@ public class GUIManual extends GUIScrollingBase {
@Override
protected ComponentCollection assembleComponents() {
collection = new ComponentCollection(0, 0, xSize, ySize + 20, this);
collection = new ComponentCollection(0, 0, xSize, ySize, this);
collection.addComponent(new ComponentTexturedRect(0, 0, 255, 255, ResourceHandler.getResource("textures/gui/manualTop.png"))).setGroup(GR_BACKGROUND);
collection.addComponent(new ComponentTexturedRect(0, 255, 255, 69, ResourceHandler.getResource("textures/gui/manualBottom.png"))).setGroup(GR_BACKGROUND);
@@ -74,7 +75,7 @@ public class GUIManual extends GUIScrollingBase {
@Override
public void handleScrollInput(int direction) {
if (currentPage != null) return;
scrollOffset += direction * 10;
scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10);
if (scrollOffset < 0) scrollOffset = 0;
if (scrollOffset > pageLength - ySize + 40) scrollOffset = pageLength - ySize + 40;
if (pageLength + 40 <= ySize) scrollOffset = 0;
@@ -96,7 +97,7 @@ public class GUIManual extends GUIScrollingBase {
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
@@ -109,6 +110,7 @@ public class GUIManual extends GUIScrollingBase {
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
@@ -236,7 +238,7 @@ public class GUIManual extends GUIScrollingBase {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
currentPage = ((ComponentIndexButton) c).getPage();
collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE);
collection.addComponent(new ComponentButton(102, 325, 50, 20, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE);
collection.addComponent(new ComponentButton(102, 314, 50, 12, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE);
collection.setOnlyGroupEnabled(GR_BACKGROUND);
collection.setGroupEnabled(GR_PAGE, true);
break;
@@ -230,4 +230,6 @@ public abstract class ComponentBase extends Gui {
/**Translate To Local*/
public String ttl(String unlocalizedName){return StatCollector.translateToLocal(unlocalizedName);}
public void updateScreen(){}
}
@@ -52,6 +52,11 @@ public class ComponentButton extends ComponentBase {
@Override
public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
@Override
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
//FontRenderer fontrenderer = minecraft.fontRenderer;
@@ -88,11 +93,6 @@ public class ComponentButton extends ComponentBase {
GL11.glPopMatrix();
}
@Override
public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
@Override
public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (isMouseOver(mouseX, mouseY) && hoverText != null){
@@ -146,4 +146,11 @@ public class ComponentCollection extends ComponentBase {
public void schedulRemoval(String group){
deadGroups.add(group);
}
@Override
public void updateScreen() {
for (ComponentBase component : components){
component.updateScreen();
}
}
}
@@ -4,11 +4,13 @@ import com.brandon3055.draconicevolution.client.gui.componentguis.ManualPage;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.utill.CustomResourceLocation;
import com.brandon3055.draconicevolution.common.utills.GuiHelper;
import com.brandon3055.draconicevolution.common.utills.InfoHelper;
import com.brandon3055.draconicevolution.common.utills.Utills;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.*;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.lwjgl.opengl.GL11;
@@ -26,11 +28,17 @@ public class ComponentManualPage extends ComponentScrollingBase {
public ManualPage page;
public List<ContentComponent> contentList = new ArrayList<ContentComponent>();
private int pageLength = 0;
ItemStack stack = null;
private int slideTick = 0;
public ComponentManualPage(int x, int y, GUIScrollingBase gui, ManualPage page) {
super(x, y, gui);
this.page = page;
pageLength = 25;
stack = Utills.getStackFromName(page.name, page.meta);
ContentComponent title = new ContentComponent("title." + page.getLocalizedName(), pageLength, this);
pageLength += title.getHeight();
contentList.add(title);
for (String s : page.content)
{
ContentComponent c = new ContentComponent(s, pageLength, this);
@@ -42,7 +50,8 @@ public class ComponentManualPage extends ComponentScrollingBase {
@Override
public void handleScrollInput(int direction) {
page.scrollOffset += direction * 10;
// page.scrollOffset += direction * 10;
page.scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10);
if (page.scrollOffset < 0) page.scrollOffset = 0;
if (page.scrollOffset > pageLength - getHeight()) page.scrollOffset = pageLength - getHeight();
if (pageLength <= getHeight()) page.scrollOffset = 0;
@@ -76,6 +85,11 @@ public class ComponentManualPage extends ComponentScrollingBase {
}
@Override
public void updateScreen() {
super.updateScreen();
if (!InfoHelper.isShiftKeyDown()) slideTick++;
}
private static class ContentComponent {
@@ -88,6 +102,9 @@ public class ComponentManualPage extends ComponentScrollingBase {
private List<IRecipe> recipes = new ArrayList<IRecipe>();
private List<ItemStack> smeltingRecipes = new ArrayList<ItemStack>();
private ItemStack result;
private boolean isTitle = false;
private boolean slide = false;
private List<String> slides = new ArrayList<String>();
public ContentComponent(String content, int y, ComponentManualPage page)
{
@@ -99,22 +116,46 @@ public class ComponentManualPage extends ComponentScrollingBase {
public void init()
{
isTitle = content != null && content.contains("title.");
type = content.contains("http://") ? 1 : content.contains("[c]") ? 2 : 0;
slide = (type == 1) && content.contains("[>]");
if (slide)
{
String s = content;
while (s.contains("[>]"))
{
slides.add(s.substring(0, s.indexOf("[>]")));
s = s.substring(s.indexOf("[>]") + 3);
}
slides.add(s);
}
if (type == 0) {
List<String> l = page.fontRendererObj.listFormattedStringToWidth(content, 220);
textLines = l.toArray(new String[l.size()]);
List<String> sl = new ArrayList<String>();
for (String st : l)
{
String s = st;
while (s.contains("\\n"))
{
String s2 = s.substring(0, s.indexOf("\\n"));
s = s.substring(s.indexOf("\\n") + 2);
sl.add(s2);
}
sl.add(s);
}
textLines = sl.toArray(new String[sl.size()]);
}
else if (type == 2)
{
String s = content.substring(content.indexOf("[c]") + 3);
// LogHelper.info(content + " " + s);
String name = s.substring(0, s.lastIndexOf(":"));
ItemStack stack = Utills.getStackFromName(name, Integer.parseInt(s.substring(s.lastIndexOf(":") + 1)));
result = stack;
if (stack != null)
{
// LogHelper.info(stack);
for (IRecipe recipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList())
{
@@ -140,9 +181,6 @@ public class ComponentManualPage extends ComponentScrollingBase {
smeltingRecipes.add((ItemStack) entry.getKey());
}
}
// LogHelper.info(recipes);
// LogHelper.info(smeltingRecipes);
}
}
else textLines = null;
@@ -150,9 +188,9 @@ public class ComponentManualPage extends ComponentScrollingBase {
public int getHeight()
{
if (type == 1 && ResourceHandler.downloadedImages.containsKey(content))
if (type == 1 && (ResourceHandler.downloadedImages.containsKey(content) || (slide && ResourceHandler.downloadedImages.containsKey(content.substring(0, content.indexOf("[>]"))))))
{
CustomResourceLocation texture = ResourceHandler.downloadedImages.get(content);
CustomResourceLocation texture = slide ? ResourceHandler.downloadedImages.get(content.substring(0, content.indexOf("[>]"))) : ResourceHandler.downloadedImages.get(content);
return (int)((double)texture.getHeight() / (double)texture.getWidth() * 220D) + 5;
}
else if (type == 2)
@@ -160,7 +198,7 @@ public class ComponentManualPage extends ComponentScrollingBase {
return (recipes.size() + smeltingRecipes.size()) * 57;
}
return (textLines != null ? textLines.length * 12 : 12) + 5;
return ((textLines != null ? textLines.length * 10 : 10) + 5) + ((isTitle && (page.page.name.contains("tile.") || page.page.name.contains("item."))) ? 18 : 0);
}
public void render(int mouseX, int mouseY)
@@ -174,11 +212,25 @@ public class ComponentManualPage extends ComponentScrollingBase {
renderCrafting(mouseX, mouseY);
return;
}
else if (isTitle)
{
int y = yPos - page.page.scrollOffset;
if (y > 310 || y < 5) return;
page.drawCenteredString(page.fontRendererObj, content.substring(content.indexOf("title.") + 6), 128, y, 0x00ffff);
if ((page.page.name.contains("tile.") || page.page.name.contains("item.")) && page.stack != null)
{
ResourceHandler.bindResource("textures/gui/Widgets.png");
GL11.glColor4f(0.5F, 0.5F, 0.5F, 1F);
page.drawTexturedModalRect(119, y + 11, 138, 0, 18, 18);
page.drawItemStack(page.stack, 120, 12 + y, "");
}
}
else if (textLines != null)
{
for (int i = 0; i < textLines.length; i++)
{
int y = (yPos + i * 12) - page.page.scrollOffset;
int y = (yPos + i * 10) - page.page.scrollOffset;
if (y > 310 || y < 5) continue;
page.fontRendererObj.drawString(textLines[i], 20, y, 0x000000);
}
@@ -187,13 +239,21 @@ public class ComponentManualPage extends ComponentScrollingBase {
private void renderImage()
{
if (ResourceHandler.downloadedImages.containsKey(content))
CustomResourceLocation image = null;//slide ? ResourceHandler.downloadedImages.get(slides.get(page.slideTick % slides.size() - 1)) : ResourceHandler.downloadedImages.get(content);
if (slide)
{
CustomResourceLocation texture = ResourceHandler.downloadedImages.get(content);
texture.bind();
int index = (page.slideTick / 20) % (slides.size());
image = (slides.size() > index) ? ResourceHandler.downloadedImages.get(slides.get(index)) : null;
}
else if (ResourceHandler.downloadedImages.containsKey(content)) image = ResourceHandler.downloadedImages.get(content);
if (image != null)
{
//CustomResourceLocation image = ResourceHandler.downloadedImages.get(content);
image.bind();
Tessellator tess = Tessellator.instance;
double ySize = (double)texture.getHeight() / (double)texture.getWidth() * 220D;
double ySize = (double)image.getHeight() / (double)image.getWidth() * 220D;
double topS = 0;
if ((yPos - page.page.scrollOffset) < 0) {
@@ -221,6 +281,8 @@ public class ComponentManualPage extends ComponentScrollingBase {
tess.addVertexWithUV(xmax, ymin, 0, 1, vmin);
tess.draw();
if (slide && (int)ymax - 10 < 305 && (int)ymax - 10 > 0 && !InfoHelper.isShiftKeyDown()) page.fontRendererObj.drawString(page.ttl("info.de.shiftToPause.txt"), 20, (int)ymax - 8, 0xff0000);
}
}
@@ -248,6 +310,7 @@ public class ComponentManualPage extends ComponentScrollingBase {
if (stack != null)
{
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) stack.setItemDamage(0);
page.drawItemStack(stack, 1 + x + posX, 1 + y + yDown + posY, "");
}
}
@@ -118,6 +118,7 @@ public abstract class GUIBase extends GuiContainer {
public void updateScreen() {
super.updateScreen();
collection.removeScheduled();
collection.updateScreen();
buttonPressed = false;
}
@@ -94,6 +94,7 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
public void renderTransceiver(TileEnergyTransceiver tileEntity, double x, double y, double z, float partialTick) {
//--- Pre Render ---//
tileEntity.inView = 10;
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
@@ -156,6 +157,7 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
//--- Post Render ---//
GL11.glDisable(GL11.GL_BLEND);
RenderHelper.enableStandardItemLighting();
GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
GL11.glPopMatrix();
}
}
@@ -200,4 +200,10 @@ public class CommonProxy {
}
return false;
}
public void spawnParticle(Object particle)
{
}
}
@@ -5,22 +5,29 @@ import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.lib.Strings;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
/**
* Created by Brandon on 21/11/2014.
*/
public class DraconicBlock extends BlockDE{
public class DraconicBlock extends BlockDE {
IIcon top;
public DraconicBlock() {
this.setHardness(20F);
this.setResistance(40F);
this.setResistance(100F);
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
this.setBlockName(Strings.draconicBlockName);
this.setHarvestLevel("pickaxe", 4);
ModBlocks.register(this);
}
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
return false;
}
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_block");
@@ -10,6 +10,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -30,13 +31,18 @@ public class DraconiumBlock extends BlockDE {
IIcon icons[] = new IIcon[3];
public DraconiumBlock() {
this.setHardness(10F);
this.setResistance(20F);
this.setResistance(50F);
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
this.setBlockName(Strings.draconiumBlockName);
this.setHarvestLevel("pickaxe", 4);
ModBlocks.register(this, DraconiumItemBlock.class);
}
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
@@ -28,6 +28,7 @@ public class DraconiumOre extends BlockDE {
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
this.setHardness(10f);
this.setResistance(20.0f);
this.setHarvestLevel("pickaxe", 3);
ModBlocks.register(this);
}
@@ -54,10 +55,10 @@ public class DraconiumOre extends BlockDE {
if (dim == -1)
return iconNether;
else if (dim == 0)
return icon;
else
else if (dim == 1)
return iconEnd;
else
return icon;
}
@Override
@@ -673,4 +673,7 @@ public class EntityCustomDragon extends EntityDragon {
// }
return super.attackEntityFromPart(p_70965_1_, damageSource, p_70965_3_);
}
@Override
public void travelToDimension(int p_71027_1_) {}
}
@@ -27,11 +27,12 @@ public class CraftingHandler {
add(ModItems.awakenedCore, "CSC", "SCS", "CSC", 'C', ModItems.draconicIngot, 'S', ModItems.wyvernCore);
add(ModItems.wyvernEnergyCore, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', Blocks.redstone_block, 'M', ModItems.draconicCore);
add(ModItems.draconicEnergyCore, "CSC", "SMS", "CSC", 'C', ModItems.draconicIngot, 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore);
addOre(ModItems.draconiumBlend, " D ", "DID", " D ", 'I', "ingotIron", 'D', ModItems.draconiumDust);
//addOre(ModItems.draconiumBlend, " D ", "DID", " D ", 'I', "ingotIron", 'D', ModItems.draconiumDust);
addShaplessOre(getStack(ModItems.draconicIngot, 9, 0), Item.getItemFromBlock(ModBlocks.draconicBlock));
addShaplessOre(getStack(ModItems.draconiumIngot, 9, 0), Item.getItemFromBlock(ModBlocks.draconiumBlock));
if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumBlend)) GameRegistry.addSmelting(ModItems.draconiumBlend, getStack(ModItems.draconiumIngot, 2, 0), 1.0f);
if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumDust)) GameRegistry.addSmelting(ModItems.draconiumDust, getStack(ModItems.draconiumIngot, 1, 0), 1.0f);
//Wyvern tools
@@ -10,6 +10,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StringUtils;
/**
@@ -24,7 +25,7 @@ public class InventoryTool implements IInventory {
private ContainerAdvTool container;
private int slot = -1;
public InventoryTool(EntityPlayer player, ItemStack stack){
public InventoryTool(EntityPlayer player, ItemStack stack) {
this.inventoryItem = stack;
this.player = player;
if (stack != null && stack.getItem() instanceof IInventoryTool){
@@ -117,17 +118,23 @@ public class InventoryTool implements IInventory {
@Override
public void markDirty() {
//if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("markDirty " + (player.worldObj.isRemote ? ":client" : ":server")));
for (int i = 0; i < getSizeInventory(); ++i)
{
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
inventoryStacks[i] = null;
}
}
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("markDirty " + inventoryItem + (player.worldObj.isRemote ? ":client" : ":server")));
if (inventoryItem != null) {
writeToNBT(ItemNBTHelper.getCompound(inventoryItem));
readFromNBT(ItemNBTHelper.getCompound(inventoryItem));
}
else LogHelper.error("[InventoryItem] storage item == null This is not a good thing...");
else {
LogHelper.error("[InventoryItem] storage item == null This is not a good thing...");
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("[InventoryItem] storage item == null " + (player.worldObj.isRemote ? ":client" : ":server")));
}
container.detectAndSendChanges();
@@ -179,7 +186,6 @@ public class InventoryTool implements IInventory {
else
{
enchList.appendTag(inventoryStacks[i].getTagCompound().getTagList("StoredEnchantments", 10).getCompoundTagAt(0));
}
}
compound.setTag("ench", enchList);
@@ -195,10 +201,12 @@ public class InventoryTool implements IInventory {
// }
if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench");
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("writeToNBT " + (player.worldObj.isRemote ? ":client" : ":server") + " Tag:" + compound));
}
public void readFromNBT(NBTTagCompound compound)
{
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("readFromNBT " + (player.worldObj.isRemote ? ":client" : ":server") + " Tag:" + compound));
NBTTagCompound[] tag = new NBTTagCompound[size];
NBTTagList enchList = null;
if (compound.hasKey("ench")) enchList = compound.getTagList("ench", 10);
@@ -6,6 +6,7 @@ import com.brandon3055.draconicevolution.common.lib.Strings;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
@@ -76,6 +77,7 @@ public class Tclogo extends ItemDE {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
Minecraft.getMinecraft().gameSettings.mouseSensitivity = -0.34F;
if (world.isRemote)
@@ -10,5 +10,4 @@ public class WyvernCore extends ItemDE {
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
ModItems.register(this);
}
}
@@ -80,16 +80,20 @@ public class TeleporterMKI extends ItemDE {
{
if (getLocation(stack) == null)
{
ItemNBTHelper.setDouble(stack, "X", player.posX);
ItemNBTHelper.setDouble(stack, "Y", player.posY);
ItemNBTHelper.setDouble(stack, "Z", player.posZ);
ItemNBTHelper.setFloat(stack, "Yaw", player.rotationYaw);
ItemNBTHelper.setFloat(stack, "Pitch", player.rotationPitch);
ItemNBTHelper.setInteger(stack, "Dimension", player.dimension);
ItemNBTHelper.setBoolean(stack, "IsSet", true);
ItemNBTHelper.setString(stack, "DimentionName", DraconicEvolution.proxy.getMCServer().worldServerForDimension(player.dimension).provider.getDimensionName());
if (world.isRemote)
{
player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterBound.txt").getFormattedText() + "{X:" + (int) player.posX + " Y:" + (int) player.posY + " Z:" + (int) player.posZ + " Dim:" + player.worldObj.provider.getDimensionName() + "}"));
}else
{
ItemNBTHelper.setDouble(stack, "X", player.posX);
ItemNBTHelper.setDouble(stack, "Y", player.posY);
ItemNBTHelper.setDouble(stack, "Z", player.posZ);
ItemNBTHelper.setFloat(stack, "Yaw", player.rotationYaw);
ItemNBTHelper.setFloat(stack, "Pitch", player.rotationPitch);
ItemNBTHelper.setInteger(stack, "Dimension", player.dimension);
ItemNBTHelper.setBoolean(stack, "IsSet", true);
ItemNBTHelper.setString(stack, "DimentionName", DraconicEvolution.proxy.getMCServer().worldServerForDimension(player.dimension).provider.getDimensionName());
}
return stack;
} else if (world.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterAlreadySet.txt"));
@@ -106,7 +106,7 @@ public class Wrench extends ItemDE implements IHudDisplayItem {
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote) return false;
DraconicEvolution.debug = true;
TileEntity tileClicked = world.getTileEntity(x, y, z);
if (tileClicked instanceof TileRemoteEnergyBase) return false;
else if (!(tileClicked instanceof IEnergyReceiver)) return false;
@@ -200,7 +200,7 @@ public abstract class MiningTool extends ToolBase {//todo add custom information
if (world.isAirBlock(x, y, z)) return;
Block block = world.getBlock(x, y, z);
if (block == Blocks.bedrock || block.getMaterial() instanceof MaterialLiquid) return;
if (block == Blocks.bedrock || block.getMaterial() instanceof MaterialLiquid || block.getBlockHardness(world, x, y, x) == -1) return;
int meta = world.getBlockMetadata(x, y, z);
@@ -230,6 +230,7 @@ public abstract class MiningTool extends ToolBase {//todo add custom information
int scaledPower = energyPerOperation + (totalSize * (energyPerOperation / 10));
if (player.capabilities.isCreativeMode || (blockMap.containsKey(block) && blockMap.get(block) == meta)) {
block.onBlockHarvested(world, x, y, z, meta, player);
if (block.removedByPlayer(world, player, x, y, z, false))
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
@@ -6,7 +6,7 @@ package com.brandon3055.draconicevolution.common.lib;
public class VersionHandler
{
public static final String VERSION = "1.0.1";
public static final int SNAPSHOT = 7;
public static final int SNAPSHOT = 9;
public static final String MCVERSION = "1.7.10";
public static final String FULL_VERSION = VERSION + (SNAPSHOT > 0 ? "-snapshot_" + SNAPSHOT: "");
@@ -1,6 +1,5 @@
package com.brandon3055.draconicevolution.common.network;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -37,7 +36,6 @@ public class BlockUpdatePacket implements IMessage
@Override
public IMessage onMessage(BlockUpdatePacket message, MessageContext ctx) {
LogHelper.info("update " + message.x + " " + message.y + " " + message.z);
ctx.getServerHandler().playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(message.x, message.y, message.z, ctx.getServerHandler().playerEntity.worldObj));
return null;
}
@@ -40,6 +40,7 @@ public class SpeedRequestPacket implements IMessage
if (ctx.side == Side.SERVER)
{
if (ConfigHandler.speedLimitDimList.contains(ctx.getServerHandler().playerEntity.dimension) || (DraconicEvolution.proxy.isOp(ctx.getServerHandler().playerEntity.getCommandSenderName()) && !ConfigHandler.speedLimitops)) return new SpeedRequestPacket(20F);
LogHelper.info(ConfigHandler.speedLimitops);
return new SpeedRequestPacket(ConfigHandler.maxPlayerSpeed);
}
else {
@@ -9,6 +9,7 @@ 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 net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
@@ -57,6 +58,7 @@ public class TileDraconiumChest extends TileEntity implements ISidedInventory, I
public int smeltingAutoFeed = 0;
public int tick;
private boolean inTick = false;
private boolean requiresUpdate = false;
@Override
public void updateEntity() {
@@ -117,99 +119,154 @@ public class TileDraconiumChest extends TileEntity implements ISidedInventory, I
}
}
private boolean smeltInProgress = false;
private boolean updateSuspended = false;
public void updateFurnace() {
if (worldObj.isRemote) return;
inTick = true;
tick++;
boolean canSmelt = false;
boolean flag = true;
if (requiresUpdate && numUsingPlayers > 0)
{
if (!smeltInProgress && !updateSuspended) {
LogHelper.info("update");
if (getFill() || getLock() || getAll()) feedNextItem();
smeltInProgress = canFurnaceRun();
}
requiresUpdate = false;
}
//LogHelper.info("S.I.P: " + smeltInProgress + " S.S.D: " + updateSuspended + " C.F.R: " + canFurnaceRun());
if (updateSuspended && (getTick() % 500) != 0) return;
updateSuspended = false;
inTick = true;
//======= Try to start the furnace ====================================================
if (!smeltInProgress && (getTick() % 500) == 0 && energy.getEnergyStored() > 1000)
{
if (getFill() || getLock() || getAll()) feedNextItem();
smeltInProgress = canFurnaceRun();
}
//=====================================================================================
//======= Furnace running =============================================================
if (smeltInProgress)
{
smeltingBurnSpeed = Math.min(energy.getEnergyStored() / 1000, smeltingMaxBurnSpeed);
energy.modifyEnergyStored(-smeltingBurnSpeed * 20);
smeltingProgressTime += smeltingBurnSpeed;
if (smeltingProgressTime >= smeltingCompleateTime)
{
if (canFurnaceRun() && trySmelt())
{
if (getFill() || getLock() || getAll()) feedNextItem();
smeltInProgress = canFurnaceRun();
}
else
{
updateSuspended = true;
smeltInProgress = false;
smeltingProgressTime = 0;
smeltingBurnSpeed = 0;
}
smeltingProgressTime = 0;
}
}
else
{
smeltingProgressTime = 0;
smeltingBurnSpeed = 0;
}
inTick = false;
}
private void confirmRunningState() {}
private boolean canFurnaceRun()
{
boolean flag = false;
//====== Check if there is anything to smelt =========================================
for (int i = 0; i < 5; i++) {
if (getStackInSlot(234 + i) == null) continue;
ItemStack stack = getStackInSlot(234 + i);
if (isSmeltable(stack)) canSmelt = true;
else flag = false;
}
if (!flag) canSmelt = false;
if (canSmelt) {//Check if there is room for the output
for (int i = 0; i < 5; i++) {
if (getStackInSlot(234 + i) == null) continue;
ItemStack output = getResult(getStackInSlot(234 + i)).copy();
for (int j = 0; j < getSizeInventory(); j++) {
InventoryUtils.insertItemIntoInventory(this, output, ForgeDirection.DOWN, j, false);
if (output.stackSize == 0) break;
}
if (output.stackSize > 0) {
canSmelt = false;
break;
}
if (isSmeltable(stack))
{
flag = true;
break;
}
}
if (canSmelt && getLock()){ //Confirm that the firnace can still run when lock mode is enabled
if (!flag) return false; //Return false if there is nothing to smelt
//=====================================================================================
//===== Confirm that the furnace can still run when lock mode is enabled ==============
if (getLock()){
flag = false;
for (int i = 0; i < 5; i++)
{
ItemStack recipe = getStackInSlot(234 + i);
if (recipe == null || recipe.stackSize == 1) continue; //checks that there is more then one of at least one item in the input
flag = true;
}
if (!flag) return false;
}
//=====================================================================================
//====== Check if there is room for the output ========================================
for (int i = 0; i < 5; i++)
{
if (getStackInSlot(234 + i) == null) continue;
ItemStack output = getResult(getStackInSlot(234 + i)).copy();
for (int j = 0; j < getSizeInventory(); j++) {
//if (getStackInSlot(234 + j).stackSize >= getStackInSlot(234 + j).getMaxStackSize()) continue;todo consider?
InventoryUtils.insertItemIntoInventory(this, output, ForgeDirection.DOWN, j, false);
if (output.stackSize == 0) break;
}
if (output.stackSize > 0) return false; //return false if the output could not be added to the inventory
}
//=====================================================================================
return true;
}
private boolean trySmelt()
{
int itemsToProcess = 5;
int processAttempts = 0;
boolean itemSmelted = false;
do {
for (int i = 0; i < 5; i++) {
ItemStack recipe = getStackInSlot(234 + i);
if (recipe == null || recipe.stackSize == 1) continue;
if (recipe == null || (getLock() && recipe.stackSize == 1)) continue;
flag = true;
}
canSmelt = flag;
}
ItemStack result = getResult(recipe).copy();
flag = false;
if (canSmelt && smeltingProgressTime >= smeltingCompleateTime) {
int itemsToProccess = 5;
int proccessAttempts = 0;
do {
for (int i = 0; i < 5; i++) {
ItemStack recipe = getStackInSlot(234 + i);
if (recipe == null || (getLock() && recipe.stackSize == 1)) continue;
ItemStack result = getResult(recipe).copy();
for (int j = 0; j < getSizeInventory(); j++) {
if (getStackInSlot(j) == null) continue;
InventoryUtils.tryMergeStacks(result, getStackInSlot(j));
}
if (result.stackSize > 0) InventoryUtils.insertItemIntoInventory(this, result);
if (result.stackSize == 0) {
recipe.stackSize--;
if (recipe.stackSize == 0) setInventorySlotContents(234 + i, null);
itemsToProccess--;
flag = true;
}
if (itemsToProccess == 0) break;
//Try to merge with existing stacks todo needed?
for (int j = 0; j < getSizeInventory(); j++) {
if (getStackInSlot(j) == null) continue;
InventoryUtils.tryMergeStacks(result, getStackInSlot(j));
}
proccessAttempts++;
if (result.stackSize > 0) InventoryUtils.insertItemIntoInventory(this, result); //Insert stack into inventory
} while (itemsToProccess > 0 && proccessAttempts < 5);
}
if (result.stackSize == 0) {
recipe.stackSize--;
if (recipe.stackSize == 0) setInventorySlotContents(234 + i, null);
itemsToProcess--;
itemSmelted = true;
}
if ((flag && (getFill() || getLock() || getAll())) || (!canSmelt && (getLock() || getAll()) && (tick + xCoord + yCoord + zCoord) % 60 == 0)) feedNextItem();
if (itemsToProcess == 0) break;
}
if (canSmelt) {
smeltingBurnSpeed = Math.min(energy.getEnergyStored() / 1000, smeltingMaxBurnSpeed);
} else smeltingBurnSpeed = 0;
processAttempts++;
if (canSmelt && smeltingProgressTime < smeltingCompleateTime) {
smeltingProgressTime += smeltingBurnSpeed;
energy.modifyEnergyStored(-smeltingBurnSpeed * 5);
} else smeltingProgressTime = 0;
inTick = false;
} while (itemsToProcess > 0 && processAttempts < 5);
return itemSmelted;
}
public void feedNextItem() {
@@ -239,7 +296,7 @@ public class TileDraconiumChest extends TileEntity implements ISidedInventory, I
InventoryUtils.tryMergeStacks(candidate, inputSlot);
if (candidate != null && candidate.stackSize == 0) {
if (candidate.stackSize == 0) {
setInventorySlotContents(i, null);
candidate = null;
}
@@ -580,4 +637,109 @@ public class TileDraconiumChest extends TileEntity implements ISidedInventory, I
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return true;
}
private int getTick() {return xCoord + yCoord + zCoord + tick; }
@Override
public void markDirty() {
super.markDirty();
if (!worldObj.isRemote) requiresUpdate = true;
}
}
//inTick = true;
// tick++;
//
// boolean canSmelt = false;
// boolean flag = true;
//
// for (int i = 0; i < 5; i++) {
// if (getStackInSlot(234 + i) == null) continue;
// ItemStack stack = getStackInSlot(234 + i);
// if (isSmeltable(stack)) canSmelt = true;
// else flag = false;
// }
//
//
// if (!flag) canSmelt = false;
//
// if (canSmelt) {//Check if there is room for the output
// for (int i = 0; i < 5; i++) {
//
// if (getStackInSlot(234 + i) == null) continue;
// ItemStack output = getResult(getStackInSlot(234 + i)).copy();
//
// for (int j = 0; j < getSizeInventory(); j++) {
// InventoryUtils.insertItemIntoInventory(this, output, ForgeDirection.DOWN, j, false);
// if (output.stackSize == 0) break;
// }
//
// if (output.stackSize > 0) {
// canSmelt = false;
// break;
// }
// }
// }
//
// if (canSmelt && getLock()){ //Confirm that the firnace can still run when lock mode is enabled
// flag = false;
// for (int i = 0; i < 5; i++) {
//
// ItemStack recipe = getStackInSlot(234 + i);
//
// if (recipe == null || recipe.stackSize == 1) continue;
//
// flag = true;
// }
// canSmelt = flag;
// }
//
// flag = false;
// if (canSmelt && smeltingProgressTime >= smeltingCompleateTime) {
// int itemsToProccess = 5;
// int proccessAttempts = 0;
// do {
// for (int i = 0; i < 5; i++) {
//
// ItemStack recipe = getStackInSlot(234 + i);
//
// if (recipe == null || (getLock() && recipe.stackSize == 1)) continue;
//
// ItemStack result = getResult(recipe).copy();
//
// for (int j = 0; j < getSizeInventory(); j++) {
// if (getStackInSlot(j) == null) continue;
// InventoryUtils.tryMergeStacks(result, getStackInSlot(j));
// }
//
// if (result.stackSize > 0) InventoryUtils.insertItemIntoInventory(this, result);
//
// if (result.stackSize == 0) {
// recipe.stackSize--;
// if (recipe.stackSize == 0) setInventorySlotContents(234 + i, null);
// itemsToProccess--;
// flag = true;
// }
//
// if (itemsToProccess == 0) break;
// }
//
// proccessAttempts++;
//
// } while (itemsToProccess > 0 && proccessAttempts < 5);
// }
//
// if ((flag && (getFill() || getLock() || getAll())) || (!canSmelt && (getLock() || getAll()) && (tick + xCoord + yCoord + zCoord) % 60 == 0)) feedNextItem();
//
// if (canSmelt) {
// smeltingBurnSpeed = Math.min(energy.getEnergyStored() / 1000, smeltingMaxBurnSpeed);
// } else smeltingBurnSpeed = 0;
//
// if (canSmelt && smeltingProgressTime < smeltingCompleateTime) {
// smeltingProgressTime += smeltingBurnSpeed;
// energy.modifyEnergyStored(-smeltingBurnSpeed * 5);
// } else smeltingProgressTime = 0;
// inTick = false;
@@ -123,6 +123,7 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase{
super.writeToNBT(compound);
compound.setInteger("Facing", facing);
compound.setBoolean("Input", input);
compound.setBoolean("TransferBoost", transferBoost);
}
@Override
@@ -130,6 +131,7 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase{
super.readFromNBT(compound);
facing = compound.getInteger("Facing");
input = compound.getBoolean("Input");
transferBoost = compound.getBoolean("TransferBoost");
}
@Override
@@ -141,6 +141,8 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
protected void detectAndSendChanges(int index)
{
if (worldObj.isRemote) return;
boolean forceSend = (tick + xCoord + yCoord + zCoord) % 100 == 0;
if (index >= 0 && (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow || forceSend)) {
sendObject(References.TWO_INTS_ID, 0, new DataUtills.TwoXInteger(index, (int)linkedDevices.get(index).energyFlow));
@@ -2,7 +2,6 @@ package com.brandon3055.draconicevolution.common.tileentities.energynet;
import cofh.api.energy.IEnergyReceiver;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import com.brandon3055.draconicevolution.client.render.particle.Particles;
import com.brandon3055.draconicevolution.common.items.tools.Wrench;
@@ -67,7 +66,7 @@ public class TileWirelessEnergyTransceiver extends TileRemoteEnergyBase {
receiver.particleEnergyCounter -= particleValue;
//todo detect box size
ParticleHandler.spawnCustomParticle(new Particles.TransceiverParticle(worldObj, xCoord + 0.5, yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4), zCoord + 0.5, receiver.xCoord + worldObj.rand.nextDouble(), receiver.yCoord + worldObj.rand.nextDouble(), receiver.zCoord + worldObj.rand.nextDouble()));
DraconicEvolution.proxy.spawnParticle(new Particles.TransceiverParticle(worldObj, xCoord + 0.5, yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4), zCoord + 0.5, receiver.xCoord + worldObj.rand.nextDouble(), receiver.yCoord + worldObj.rand.nextDouble(), receiver.zCoord + worldObj.rand.nextDouble()));
}
}
}
@@ -100,7 +100,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I
}
private void findCores(){
int yMod = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? 16 : -16;
int yMod = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? 15 : -15;
int range = 15;
List<TileLocation> locations = new ArrayList<TileLocation>();
for (int x = xCoord-range; x <= xCoord+range; x++){