Everything posted by danbka33
-
Custom EntityPlayerSP, EntityPlayerMP
I already did, but can you explain how did it here: https://github.com/micdoodle8/Galacticraft/tree/master/common/micdoodle8/mods/galacticraft/core/entities/player
-
Custom EntityPlayerSP, EntityPlayerMP
I want to do like this: https://github.com/micdoodle8/galacticraft https://github.com/micdoodle8/Galacticraft/tree/master/common/micdoodle8/mods/galacticraft/core/entities/player
-
Custom EntityPlayerSP, EntityPlayerMP
Sorry, I do not know what it is. Can you help?
-
Custom EntityPlayerSP, EntityPlayerMP
UP No one knows?
-
Custom EntityPlayerSP, EntityPlayerMP
UP
-
Custom EntityPlayerSP, EntityPlayerMP
I do not know how to do it. Can you help?
-
Custom EntityPlayerSP, EntityPlayerMP
No, but how to do it? Sorry for bad English.
-
Custom EntityPlayerSP, EntityPlayerMP
Add
-
Custom EntityPlayerSP, EntityPlayerMP
[spoiler=Core] public static Map<String, SCoreEntityPlayerSP> playersClient = new HashMap<String, SCoreEntityPlayerSP>(); public static Map<String, SCoreEntityPlayerMP> playersServer = new HashMap<String, SCoreEntityPlayerMP>(); [spoiler=SCoreEntityPlayerMP] package nuclear.mods.space.entity.player; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemInWorldManager; import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import nuclear.mods.space.SLog; import nuclear.mods.space.SpaceCore; public class SCoreEntityPlayerMP extends EntityPlayerMP { private long tick; public SCoreEntityPlayerMP(MinecraftServer server, World world, String username, ItemInWorldManager itemInWorldManager) { super(server, world, username, itemInWorldManager); if (!SpaceCore.playersServer.containsKey(this.username)) { SpaceCore.playersServer.put(this.username, this); SLog.info(" ADD"); } } @Override public void onDeath(DamageSource damageSource) { SpaceCore.playersServer.remove(this); SLog.info(" REMOVE"); super.onDeath(damageSource); } @Override public void onUpdate() { super.onUpdate(); if (!SpaceCore.playersServer.containsKey(this.username) || this.tick % 360 == 0) { SpaceCore.playersServer.put(this.username, this); SLog.info(" ADD"); } if (this.tick >= Long.MAX_VALUE) { this.tick = 0; } this.tick++; } } [spoiler=SCoreEntityPlayerSP] package nuclear.mods.space.entity.player; import java.util.ArrayList; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.multiplayer.NetClientHandler; import net.minecraft.util.DamageSource; import net.minecraft.util.Session; import net.minecraft.world.World; import nuclear.mods.space.SLog; import nuclear.mods.space.SpaceCore; import nuclear.mods.space.api.ISchematicPage; public class SCoreEntityPlayerSP extends EntityClientPlayerMP { public ArrayList<ISchematicPage> unlockedSchematics = new ArrayList<ISchematicPage>(); public long tick; public SCoreEntityPlayerSP(Minecraft par1Minecraft, World par2World, Session par3Session, NetClientHandler par4NetClientHandler) { super(par1Minecraft, par2World, par3Session, par4NetClientHandler); if (!SpaceCore.playersClient.containsKey(this.username)) { SpaceCore.playersClient.put(this.username, this); SLog.info(" ADD"); } } @Override public void onDeath(DamageSource var1) { SpaceCore.playersClient.remove(this); SLog.info(" REMOVE"); super.onDeath(var1); } @Override public void onUpdate() { this.tick++; if (!SpaceCore.playersClient.containsKey(this.username) || this.tick % 360 == 0) { SpaceCore.playersClient.put(this.username, this); SLog.info(" ADD"); } super.onUpdate(); } } [spoiler=PlayerUtil] package nuclear.mods.space.util; import java.util.Iterator; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import nuclear.mods.space.SLog; import nuclear.mods.space.SpaceCore; import nuclear.mods.space.entity.player.SCoreEntityPlayerMP; import nuclear.mods.space.entity.player.SCoreEntityPlayerSP; public class PlayerUtil { public static SCoreEntityPlayerMP getPlayerBaseServerFromPlayerUsername(String username) { if (SpaceCore.playersServer.isEmpty()) { // new EmptyStackException().printStackTrace(); } final Iterator<Map.Entry<String, SCoreEntityPlayerMP>> it = SpaceCore.playersServer.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, SCoreEntityPlayerMP> entry = it.next(); if (entry.getKey().equals(username)) { return entry.getValue(); } } SLog.severe("Warning: Could not find player base server instance for player " + username); return null; } public static SCoreEntityPlayerMP getPlayerBaseServerFromPlayer(EntityPlayer player) { if (player == null) { return null; } if (SpaceCore.playersServer.isEmpty()) { // new EmptyStackException().printStackTrace(); } final Iterator<Map.Entry<String, SCoreEntityPlayerMP>> it = SpaceCore.playersServer.entrySet().iterator(); while (it.hasNext()) { final Map.Entry<String, SCoreEntityPlayerMP> entry = it.next(); if (entry.getKey().equals(player.username)) { return entry.getValue(); } } SLog.severe("Warning: Could not find player base server instance for player " + player.username); return null; } public static SCoreEntityPlayerSP getPlayerBaseClientFromPlayer(EntityPlayer player) { if (player == null) { return null; } if (SpaceCore.playersClient.isEmpty()) { return null; } final Iterator<Map.Entry<String, SCoreEntityPlayerSP>> it = SpaceCore.playersClient.entrySet().iterator(); while (it.hasNext()) { final Map.Entry<String, SCoreEntityPlayerSP> entry = it.next(); if (entry.getKey() != null && entry.getKey().equals(player.username)) { return entry.getValue(); } } SLog.severe("Warning: Could not find player base client instance for player " + player.username); return null; } } If I call SCoreEntityPlayerMP,SCoreEntityPlayerSP using PlayerUtil, I get a null value
-
1.5.2 IC2 API - Energy is always 0
Problem solved.
-
1.5.2 IC2 API - Energy is always 0
I did, but that's left to do is automatically updated in the gui, but not after rejoining in gui. Sorry for bad English)
-
1.5.2 IC2 API - Energy is always 0
UP
-
1.5.2 IC2 API - Energy is always 0
but the energy in the block is not updated. What to do?
-
1.5.2 IC2 API - Energy is always 0
Thank you!!!
-
1.5.2 IC2 API - Energy is always 0
https://drive.google.com/file/d/0B9UWs5AUe9smYWQ1ZVhKWGp5WDA/edit?usp=sharing Code.
-
1.5.2 IC2 API - Energy is always 0
Nobody can help?
-
1.5.2 IC2 API - Energy is always 0
import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.FMLCommonHandler; public class SCoreEntityTileWorkbench extends TileEntity implements IEnergySink, IInventory { double energy; double maxenergy = 50000; boolean init; boolean work = true; private ItemStack[] inv; public SCoreEntityTileWorkbench() { inv = new ItemStack[9]; } @Override public void updateEntity() { super.updateEntity(); if (!init && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); init = true; } } @Override public void invalidate() { if (init) { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); init = false; } } @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); this.energy = nbttagcompound.getDouble("energy"); } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); nbttagcompound.setDouble("energy", this.energy); } @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { return true; } @Override public double demandedEnergyUnits() { return Math.max(0, this.getMaxEnergy() - this.getEnergy()); } @Override public double injectEnergyUnits(ForgeDirection directionFrom, double amount) { if(this.getEnergy() >= this.getMaxEnergy()) return amount; double openenergy = this.getMaxEnergy() - this.getEnergy(); if(openenergy >= amount) { return this.energy += amount; } else if(amount >= openenergy) { this.energy = this.maxenergy; return amount - openenergy; } return 0; } @Override public int getMaxSafeInput() { return EnergyNet.instance.getPowerFromTier(2); } public int getScaledLevel(int i) { return (int) Math.floor(this.getEnergy() * i / (this.getMaxEnergy())); } @Override public int getSizeInventory() { return inv.length; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { inv[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public ItemStack decrStackSize(int slot, int amt) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amt) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amt); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openChest() {} @Override public void closeChest() {} @Override public String getInvName() { return "Space workbench"; } @Override public ItemStack getStackInSlot(int i) { return inv[i]; } @Override public boolean isInvNameLocalized() { return false; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return false; } public double getEnergy() { return this.energy; } public double getMaxEnergy() { return this.maxenergy; } } If I click on the block, then displays the correct value. public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { SCoreEntityTileWorkbench tile = (SCoreEntityTileWorkbench) par1World.getBlockTileEntity(par2, par3, par4); if(tile == null) { par5EntityPlayer.addChatMessage("Tile is null"); return true; } if(par5EntityPlayer.isSneaking() && tile != null) { par5EntityPlayer.addChatMessage("Current energy: " + tile.getEnergy()); return true; } par5EntityPlayer.openGui(SpaceCore.instance, SCoreConfigManager.idGuiWorkbench, par1World, par2, par3, par4); return false; } But if I will put it in the Gui always displays 0. package nuclear.mods.atisot.space.client.gui; import java.util.ArrayList; import java.util.List; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import nuclear.mods.atisot.space.SLog; import nuclear.mods.atisot.space.SpaceCore; import nuclear.mods.atisot.space.inventory.SCoreWorkbenchContainer; import nuclear.mods.atisot.space.tile.SCoreEntityTileWorkbench; import org.lwjgl.opengl.GL11; public class SCoreWorkbenchGui extends SCoreGuiContainer { private static final ResourceLocation distributorTexture = new ResourceLocation(SpaceCore.ASSET_DOMAIN, "textures/gui/spaceworkbench.png"); private SCoreInfoRegion electricInfoRegion = new SCoreInfoRegion((this.width - this.xSize) / 2 + 4, (this.height - this.ySize) / 2 + 55, 4, 60, new ArrayList<String>(), this.width, this.height); SCoreEntityTileWorkbench workbench; public SCoreWorkbenchGui(InventoryPlayer inventoryPlayer, SCoreEntityTileWorkbench tileEntity){ super(new SCoreWorkbenchContainer(inventoryPlayer, tileEntity)); this.workbench = tileEntity; this.ySize = 160; } @Override public void initGui() { super.initGui(); List<String> electricityDesc = new ArrayList<String>(); electricityDesc.add("Electrical Storage"); electricityDesc.add("Energy: " + ((int) Math.floor(this.workbench.getEnergy()) + " / " + (int) Math.floor(this.workbench.getMaxEnergy()))); this.electricInfoRegion.tooltipStrings = electricityDesc; this.electricInfoRegion.xPosition = (this.width - this.xSize) / 2 + 13; this.electricInfoRegion.yPosition = (this.height - this.ySize) / 2 + 16; this.electricInfoRegion.parentWidth = this.width; this.electricInfoRegion.parentHeight = this.height; this.infoRegions.add(this.electricInfoRegion); } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { //draw text and stuff here //the parameters for drawString are: string, x, y, color fontRenderer.drawString("Space Workbench", 30, 10, 4210752); //draws "Inventory" or your regional equivalent fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 30, ySize - 90 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(distributorTexture); final int var5 = (this.width - this.xSize) / 2; final int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6 + 5, 0, 0, this.xSize, 181); if (this.workbench != null) { int scale = this.workbench.getScaledLevel(55); SLog.info("" + scale); SLog.info("" + this.workbench.getEnergy()); this.drawTexturedModalRect(var5 + 12, var6 + 20, 176, 0, Math.min(scale, 55), 7); // if (this.workbench.getEnergy() > 0) // { // this.drawTexturedModalRect(var5 + 12, var6 + 20, 176, 0, 4, 55); // } // } } } http://s24.postimg.org/9wzykqbj5/2014_03_17_19_41_08.png[/img] http://s24.postimg.org/yc86lsag1/2014_03_17_19_41_11.png[/img]
IPS spam blocked by CleanTalk.