
jamiemac262
Members-
Posts
87 -
Joined
-
Last visited
Everything posted by jamiemac262
-
[Solved] Does the client need this mod?
jamiemac262 replied to jamiemac262's topic in Modder Support
i have server commands for example /wallet pay <name> <amount> /wallet set <name> <amount> (i will have to work out how to apply permissions next haha) -
I'm at a stage where i am about ready to release my mod as a beta. dead simple mod, just adds a "wallet" to players using extended properties. what i'm wondering is if it's possible to make this a server-side only mod. or does the mod need to be on the client side if all it does is add a few commands and an IExtendedEntityProperties class. Anyone know? if it is possible, how do i make it server-side only?
-
how to get EntityPlayer from player's username?
jamiemac262 replied to jamiemac262's topic in Modder Support
I actually managed to solve this myself for anybody looking for this solution: public EntityPlayer getPlayer(String name){ ServerConfigurationManager server = MinecraftServer.getServer().getConfigurationManager(); ArrayList pl = (ArrayList) server.playerEntityList; ListIterator li = pl.listIterator(); while (li.hasNext()){ EntityPlayer p = (EntityPlayer) li.next(); if(p.getGameProfile().getName().equals(name)){ return p; } } return null; } -
i'm sure I've missed something dead simple... i need to get an instance of a player by using it's username in a command. i have had a look around the API and can't seem to find this. i vaguely remember Server.getPlayer("username") ... but that's obviously wrong because if it was right i wouldn't be here haha... does anybody know how to do this?
-
using extended player properties in command
jamiemac262 replied to jamiemac262's topic in Modder Support
oh so that's how i format code haha... i tried using the button at the top of the textbox (picture of a hash tag) but it didnt do anything lol. thanks -
using extended player properties in command
jamiemac262 replied to jamiemac262's topic in Modder Support
I added those 2 bits of code to the end of the first post -
I'm getting a null pointer exception in this function: public void processCommand(ICommandSender sender, String[] args) { if(args.length == 0){ PlayerWallet wallet = PlayerWallet.get((EntityPlayer) sender); ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("£" + wallet.getWallet())); } i know the error occurs at "wallet.getWallet()". i just can't work out what is causing the error suggestions? the Player wallet class: public class PlayerWallet implements IExtendedEntityProperties { public final static String EXT_PROP_NAME = "PlayerWallet"; private double funds; public void init(Entity entity, World world){ funds = 0; } public void loadNBTData(NBTTagCompound nbt){ NBTTagCompound properties = (NBTTagCompound) nbt.getTag(EXT_PROP_NAME); properties.getDouble("funds"); } public void saveNBTData(NBTTagCompound nbt){ NBTTagCompound properties = new NBTTagCompound(); properties.setDouble("funds", funds); nbt.setTag(EXT_PROP_NAME, properties); } public static final PlayerWallet get(EntityPlayer player) { return (PlayerWallet) player.getExtendedProperties(EXT_PROP_NAME); } public static final void register(EntityPlayer player) { player.registerExtendedProperties(PlayerWallet.EXT_PROP_NAME, new PlayerWallet()); } public double getWallet(){ return funds; } public double addFunds(double f){ funds += f; return getWallet(); } public double setFunds(double f){ funds = f; return funds; } public double removeFunds(double f){ funds -=f; return funds; } } The Event handler class: public class MconomyEventHandler { @EventHandler public void onEntityConstructing(EntityEvent.EntityConstructing event) { /* Be sure to check if the entity being constructed is the correct type for the extended properties you're about to add! The null check may not be necessary - I only use it to make sure properties are only registered once per entity */ if (event.entity instanceof EntityPlayer && PlayerWallet.get((EntityPlayer) event.entity) == null) // This is how extended properties are registered using our convenient method from earlier PlayerWallet.register((EntityPlayer) event.entity); // That will call the constructor as well as cause the init() method // to be called automatically } } the event is registered here: @EventHandler public void init(FMLInitializationEvent event) { // some example code MinecraftForge.EVENT_BUS.register(new MconomyEventHandler()); } i would really appreciate if anyone can solve this problem for me
-
So i just learned about IExtendedEntityProperties. It got me wondering. Is there some kind of IExtendedChunkProperties? lemme explain. I am currently planning a mod to protect chunks. very similar to Towny or factions, but for individual players. my plan was that each time a player claims a chunk, it is stored in a text file with their name on it. and every onBlockBreak event would check if that chunk belongs to the player causing the event. i could assign the player's UUID to the chunk, then rather than loading a list and searching an array for the chunk in question, i could just check this property. is it possible?
-
ok with regards to storing and saving, i was looking for a way to define areas, so if i want to remove a protected area i just need to remove that area rather than the individual chunks... so it might still only need to be 2d, it would look like this: Array protChunk{ area1{ "1,1", "1,2" "1,3" }, area2{ "2,1", "2,2" } } or am i still being overly complex? lol ( i have a tendency to do that)
-
okay, so i just created a TPPI server, which runs on 1.6.4, only to learn that bukkitForge and Cauldron no longer exist. this poses a problem when it comes to protecting areas of my server that need protecting. I have thought long and hard about this and i think i have worked out how to protect land in my mod. i'm just not certain this will work or how to do it. could i get your thoughts please? here's what i was thinking create a 3-d array "ProtChunk" and populate it with the protected chunks when the server starts chunks would be saved in a JSON or YML format and would look like this: area{ chunk1 chunk2 chunk3 } area2{ chunk4 chunk5 chunk6 } override, or extend (not sure) the block break event so that every time a block is broken the mod does the following check: get the chunk the block is in, check if this chunk is in an array of protected chunks (which is set from a file when the mod loads). if it is cancel the event when i want to protect an area i would use a command like /prot new <area name> and then /prot claim <area name> to claim the chunk i am in. when i do that 2nd command i would get the chunk i am currently in and save it to the array, which will be saved to the file. it's a rough idea, can anyone tell me if i'm on the right track and how i would go about doing this?
-
Yeh , your right jabelar, i'm not entirely sire how this code worked in 1.6 tho haha
-
just a heads up, i didnt write this code, the original developer did mention he doesnt do this professionally and thus alot of the code may not make sense haha.... i think i am going to re-write the class, instead of if statements, load the building's blueprint (which is an array i believe) into an array and then create 3 for loops, for x, y, z..... so that it builds the building in a logical manner all i would need is that the x y and z loops are the sizes of the building and make it look like this for y for z for x Block.setBlock(<block id of current block>) does that make sense/ would that work? thoughts?
-
so anybody else notice the semicolon at the end of the if condition? haha now my new problem, this looks like a design problem, blockId is always 0, it's never set to anything else i really would appreciate if someone could let me contact them on skype and help me out with this class
-
hmm, okay so debugged and your right, there is a problem there.... blockId = the id for air.... then 2 lines later if the blockId is grass set it to dirt..... how the hell does it get into that if statement if the Id should be 0 0.o
-
so i'm (still) updating sim-u-kraft to 1.7 and have found a pretty serious bug in the building constructor. for those of you yet to be blessed by the beauty of this mod in 1.6, the Building constructor allows Sims to build houses/shops/factories/anything really if there's a blueprint for it. it takes a txt file full of letters and uses it as a 3D plan of the building in question. a sim is hired, a building chosen and the sim will then build the building. problem is that the way it works just now, the building is just a big block of dirt. i was wondering if someone could help me either resolve the bug or find a new way to do the job? here is the code for the builder job class: package info.satscape.simukraft.common.jobs; import info.satscape.simukraft.ModSimukraft; import info.satscape.simukraft.ModSimukraft.GameMode; import info.satscape.simukraft.common.Building; import info.satscape.simukraft.common.CommonProxy.V3; import info.satscape.simukraft.common.EntityConBox; import info.satscape.simukraft.common.FolkData; import info.satscape.simukraft.common.FolkData.FolkAction; import java.io.Serializable; import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; public class JobBuilder extends Job implements Serializable { private static final long serialVersionUID = -1177665807904279141L; public Stage theStage; public FolkData theFolk = null; public Vocation vocation = null; public int runDelay = 1000; public long timeSinceLastRun = 0; private transient ArrayList<IInventory> constructorChests = new ArrayList<IInventory>(); private transient Building theBuilding = null; private transient EntityConBox theConBox = null; private transient long lastNotifiedOfMaterials = 0; /** * used to delay the sound effect so it only fires every 2 seconds * regardless of build delay */ private transient long soundLastPlayed = 0l; int l = 0, ftb = 0, ltr = 0; // 3d build loops int xo = 0, zo = 0, acount = 0; int cx, cy, cz, ex, ey, ez, bx = 0, by = 0, bz = 0; public JobBuilder() { // not used } public JobBuilder(FolkData folk) { theFolk = folk; if (theStage == null) { theStage = Stage.IDLE; } if (theFolk == null) { return; } // is null when first employing, this is for next day(s) if (theFolk.destination == null) { theFolk.gotoXYZ(theFolk.employedAt, null); } this.theBuilding = theFolk.theBuilding; } public void resetJob() { theStage = Stage.IDLE; } @Override public void onUpdate() { if (theFolk == null) { return; } super.onUpdate(); //theFolk.levelBuilder=10; //ModSimukraft.states.credits=100000; if (!ModSimukraft.isDayTime()) { theStage = Stage.IDLE; } super.onUpdateGoingToWork(theFolk); if (theStage == Stage.WAITINGFORRESOURCES) { runDelay = 3000; if (theBuilding != null) { } } if (theStage == Stage.INPROGRESS) { if (step == 1) { runDelay = (int)(2000 / theFolk.levelBuilder); } } if (System.currentTimeMillis() - timeSinceLastRun < runDelay) { return; } timeSinceLastRun = System.currentTimeMillis(); if (theFolk.theirJob != null) { if (theFolk.vocation != Vocation.BUILDER) { theFolk.selfFire(); return; } } theFolk.updateLocationFromEntity(); int dist = theFolk.location.getDistanceTo(theFolk.employedAt); if (dist <= 3 && theStage == Stage.WORKERASSIGNED) { theFolk.action = FolkAction.ATWORK; theFolk.statusText = "Arrived at work"; theStage = Stage.BLUEPRINT; } if (dist < 10 && theStage == Stage.WORKERASSIGNED && theFolk.destination == null) { theFolk.action = FolkAction.ATWORK; theFolk.statusText = "Arrived at work"; theStage = Stage.BLUEPRINT; } // ////////////////IDLE if ((theStage == Stage.IDLE || theStage == Stage.WORKERASSIGNED) && ModSimukraft.isDayTime()) { if (theFolk.action != FolkAction.ONWAYTOWORK) { theStage = Stage.WORKERASSIGNED; } } else if (theStage == Stage.WORKERASSIGNED) { } else if (theStage == Stage.BLUEPRINT) { stageBlueprint(); } else if (theStage == Stage.WAITINGFORRESOURCES) { stageWaitingForResources(); } else if (theStage == Stage.INPROGRESS) { stageInProgress(); } else if (theStage == Stage.COMPLETE) { stageComplete(); } } private void stageBlueprint() { theBuilding = theFolk.theBuilding; if (theBuilding == null) { theFolk.statusText = "Please choose which building I should build"; } else { theFolk.statusText = "Looking through blueprints..."; /* if (theBuilding.structure[theBuilding.structure.length - 1] == null) { theBuilding.loadStructure(true); } */ theFolk.updateLocationFromEntity(); double dist = theFolk.location.getDistanceTo(theFolk.employedAt); if (dist < 4) { theFolk.stayPut = true; } if (ModSimukraft.configFolkTalking) { if (theFolk.gender == 0) { jobWorld.playSound( theFolk.location.x, theFolk.location.y, theFolk.location.z, "satscapesimukraft:readym", 1f, 1f, false); } else { jobWorld.playSound( theFolk.location.x, theFolk.location.y, theFolk.location.z, "satscapesimukraft:readyf", 1f, 1f, false); } } theStage = Stage.WAITINGFORRESOURCES; step = 1; // create the conBox entity if (this.theConBox == null) { World world = MinecraftServer.getServer() .worldServerForDimension(theFolk.location.theDimension); this.theConBox = new EntityConBox(world); this.theConBox.theFolk = theFolk; //this.theConBox.theFolk.theBuilding.loadStructure(true); this.theConBox.setLocationAndAngles(theFolk.employedAt.x + 2, theFolk.employedAt.y, theFolk.employedAt.z, 0f, 0f); if (!world.isRemote) { world.spawnEntityInWorld(this.theConBox); } } } } private void stageWaitingForResources() { theFolk.isWorking = false; if (step == 1) { theFolk.statusText = "Checking building resources..."; constructorChests = inventoriesFindClosest(theFolk.employedAt, 5); if (constructorChests.size() == 0) { theFolk.statusText = "Please place at least one chest/storage block near to constructor block."; } else { try { constructorChests.get(0).openInventory(); } catch (Exception e) { ModSimukraft.log.info("JobBuilder:JobBuilder's chest was null"); } step = 2; } int dist = theFolk.location.getDistanceTo(theFolk.employedAt); if (dist < 5) { theFolk.stayPut = true; } } else if (step == 2) { constructorChests.get(0).closeInventory(); theStage = Stage.INPROGRESS; step = 1; } else if (step == 3) // this step triggers mid-build - just send them { // back in to keep checking if (theFolk.vocation == Vocation.BUILDER) { step = 2; theStage = Stage.INPROGRESS; if (theFolk.isSpawned()) { theFolk.updateLocationFromEntity(); } int dist = theFolk.location.getDistanceTo(theFolk.employedAt); if (dist < 5) { theFolk.stayPut = true; } else { theFolk.gotoXYZ(theFolk.employedAt, null); } } else { theFolk.selfFire(); return; } } } private void stageInProgress() { int blockId = Block.getIdFromBlock(Blocks.air); boolean alreadyPlaced = false; theFolk.updateLocationFromEntity(); int dist = theFolk.location.getDistanceTo(theFolk.employedAt); if (dist > 5 && theFolk.destination == null) { theFolk.gotoXYZ(theFolk.employedAt, null); return; } if (step == 1) { cx = theFolk.employedAt.x.intValue(); cy = theFolk.employedAt.y.intValue(); cz = theFolk.employedAt.z.intValue(); ex = theFolk.employedAt.x.intValue(); ey = theFolk.employedAt.y.intValue(); ez = theFolk.employedAt.z.intValue(); bx = ex; by = ey; bz = ez; if (theBuilding.buildDirection.contentEquals("-x")) { bx = cx + 1; } else if (theBuilding.buildDirection.contentEquals("+x")) { bx = cx - 1; } else if (theBuilding.buildDirection.contentEquals("-z")) { bz = cz + 1; } else if (theBuilding.buildDirection.contentEquals("+z")) { bz = cz - 1; } else { ModSimukraft.sendChat("Can't determine the direction to build in, please stand on one of the four sides of the constructor when you right-click it"); theFolk.selfFire(); return; } ModSimukraft.sendChat(theFolk.name + " has started building a " + theBuilding.displayNameWithoutPK); theFolk.statusText = "Building " + theBuilding.displayNameWithoutPK; if (theBuilding == null || theBuilding.layerCount == 0) { ModSimukraft.sendChat(theFolk.name + " has misplaced the blueprints, fire them and try someone else."); return; } theFolk.stayPut = true; if (theBuilding == null) { theFolk.selfFire(); return; } l = 0; ftb = 0; ltr = 0; acount = 0; step = 2; theBuilding.blockLocations.clear(); } else if (step == 2) // ///////////////// STEP 2 { do { theFolk.statusText = "Building " + theBuilding.displayNameWithoutPK; if (theBuilding.buildDirection.contentEquals("+z")) { xo = ltr; zo = -ftb; } else if (theBuilding.buildDirection.contentEquals("-z")) { xo = -ltr; zo = ftb; } else if (theBuilding.buildDirection.contentEquals("+x")) { xo = -ftb; zo = -ltr; } else if (theBuilding.buildDirection.contentEquals("-x")) { xo = ftb; zo = ltr; } if (theBuilding == null) { theFolk.selfFire(); return; } String[] bl = null; try { bl = theBuilding.structure[acount].split(":"); System.out.println(bl); } catch (Exception e) { ModSimukraft.log.warning("JobBuilder: NULL block in building, using Air instead"); bl = "0:0".split(":"); } blockId = Block.getIdFromBlock(Blocks.air); int subtype = Integer.parseInt(bl[1]); if (blockId == Block.getIdFromBlock(Blocks.grass)); { blockId = Block.getIdFromBlock(Blocks.dirt); } if (theBuilding.type.contentEquals("other") && acount == 0) { /*TODO: complete*/ blockId = theConBox.getEntityId(); subtype = 2; //control box other } if (blockId == theConBox.getEntityId()) { try { theBuilding.primaryXYZ = new V3((double)(bx + xo), (double)(by + l), (double)(bz + zo), theFolk.employedAt.theDimension); theBuilding.saveThisBuilding(); } catch (Exception e) { ModSimukraft.log.info("JobBuilder:build is null"); } } if (blockId == 999 && subtype == 999) { theBuilding.livingXYZ = new V3((double)(bx + xo), (double)(by + l), (double)(bz + zo), theFolk.employedAt.theDimension); blockId = Block.getIdFromBlock(Blocks.air); subtype = 0; } else if (blockId==999 && subtype>=0 && subtype <=9) { V3 v3=new V3((double)(bx + xo), (double)(by + l),(double)(bz + zo), theFolk.employedAt.theDimension); v3.meta=subtype; theBuilding.blockSpecial.add(v3); blockId = 0; subtype = 0; } int currBlockId = 0; int currBlockMeta = 0; try { currBlockId = Block.getIdFromBlock(jobWorld.getBlock(bx + xo, by + l, bz + zo)); currBlockMeta = jobWorld.getBlockMetadata(bx + xo, by + l, bz + zo); if (blockId == currBlockId || (blockId==Block.getIdFromBlock(Blocks.dirt) && currBlockId==Block.getIdFromBlock(Blocks.grass)) || (blockId==Block.getIdFromBlock(Blocks.grass) && currBlockId==Block.getIdFromBlock(Blocks.dirt))) { alreadyPlaced = true; } else { alreadyPlaced = false; } } catch (Exception e) { theFolk.selfFire(); return; } String want = ""; ItemStack wantIS = new ItemStack(Block.getBlockById(blockId), 1, 0); try { want = wantIS.getDisplayName(); if (blockId != 0) { theBuilding.blockLocations.add(new V3(bx + xo, by + l, bz + zo,theFolk.location.theDimension)); } } catch (Exception e) { want = "?"; ModSimukraft.log.info("JobBuilder:wantItemStack nulled out, wantIS was null, blockID=" + blockId); } if (!alreadyPlaced) // air block it first to clear dirt { // away if (currBlockId != 0) { V3 blockToRemove = new V3(bx + xo, by + l, bz + zo); constructorChests = inventoriesFindClosest(theFolk.employedAt, 5); mineBlockIntoChests(constructorChests, blockToRemove); jobWorld.setBlock(bx + xo, by + l, bz + zo, Blocks.air, 0, 0x03); theFolk.isWorking = true; } } if (!alreadyPlaced) { boolean gotBlock = false; boolean requiredBlocks = blockId == Block.getIdFromBlock(Blocks.planks) || blockId == Block.getIdFromBlock(Blocks.cobblestone) || blockId == Block.getIdFromBlock(Blocks.glass) || blockId == Block.getIdFromBlock(Blocks.wool) || blockId == Block.getIdFromBlock(Blocks.brick_block) || blockId == Block.getIdFromBlock(Blocks.dirt) || blockId == Block.getIdFromBlock(Blocks.stonebrick) || blockId == Block.getIdFromBlock(Blocks.fence) || blockId == Block.getIdFromBlock(Blocks.stone) || blockId == Block.getIdFromBlock(Blocks.log); if (ModSimukraft.gameMode == GameMode.NORMAL) { if (requiredBlocks) { constructorChests = inventoriesFindClosest(theFolk.employedAt, 5); ItemStack got = inventoriesGet(constructorChests, new ItemStack(Block.getBlockById(blockId), 1, 0), false,false,-1); if (got != null) { gotBlock = true; } else { gotBlock = false; } } else { gotBlock = true; } } else if (ModSimukraft.gameMode == GameMode.CREATIVE) { gotBlock = true; } else if (ModSimukraft.gameMode == GameMode.HARDCORE) { if (blockId != 0) { // provided blocks in hardcore mode 68=sign if (blockId == Block.getIdFromBlock(Blocks.grass) || blockId == Block.getIdFromBlock(Blocks.water) || blockId == Block.getIdFromBlock(Blocks.lava) || blockId == Block.getIdFromBlock(Blocks.wall_sign) || blockId == Block.getIdFromBlock(Blocks.cake) || blockId == Block.getIdFromBlock(Blocks.stone_slab) || blockId == Block.getIdFromBlock(Blocks.wooden_slab) || blockId == Block.getIdFromBlock(Blocks.double_wooden_slab) || blockId == Block.getIdFromBlock(Blocks.double_stone_slab) || blockId == Block.getIdFromBlock(Blocks.farmland) || blockId == Block.getIdFromBlock(Blocks.wooden_door) || blockId ==Block.getIdFromBlock(Blocks.iron_door) || blockId == Block.getIdFromBlock(Blocks.bed)) //// TODO: WHEN I RE-WRITE - problem here is it needs to translate blocks to items { gotBlock = true; } else { constructorChests = inventoriesFindClosest(theFolk.employedAt, 5); ItemStack got = inventoriesGet(constructorChests, new ItemStack(Block.getBlockById(blockId), 1, 0), false,false,-1); if (got != null) { gotBlock = true; } else { gotBlock = false; } if (blockId == theConBox.getEntityId()) { gotBlock = true; } } } else { gotBlock = true; } } if (!gotBlock) { theStage = Stage.WAITINGFORRESOURCES; if (want.toLowerCase().contentEquals("oak wood planks")) { want = "Planks"; } if (want.toLowerCase().contentEquals("oak wood")) { want = "Logs"; } theFolk.statusText = "Waiting for " + want; if (System.currentTimeMillis() - lastNotifiedOfMaterials > (ModSimukraft.configMaterialReminderInterval * 60 * 1000)) { lastNotifiedOfMaterials = System.currentTimeMillis(); ModSimukraft.sendChat(theFolk.name + " (who's building a " + theFolk.theBuilding.displayNameWithoutPK + ") needs more " + want); } step = 3; return; } try { if (!alreadyPlaced) { try { if (blockId ==212 || blockId == 3211) { blockId = theConBox.getEntityId(); } // bank control boxes if (blockId == theConBox.getEntityId() && theBuilding.displayNameWithoutPK.toLowerCase().contentEquals("sim-u-bank")) { subtype = 1; } //########### PLACE THE BLOCK theFolk.stayPut = true; jobWorld.setBlock(bx + xo, by + l, bz + zo, Block.getBlockById(blockId), subtype, 0x03); jobWorld.markBlockForUpdate(bx + xo, by + l, bz + zo); int b4 = (int)Math.floor(theFolk.levelBuilder); //theFolk.levelBuilder=10.0f; if (theFolk.levelBuilder < 10.0f) { theFolk.levelBuilder += (0.001 / b4); } int aft = (int)Math.floor(theFolk.levelBuilder); if (b4 != aft) { ModSimukraft.sendChat(theFolk.name + " has just levelled up to Builder Level " + aft); } // PLAY SOUND EFFECT every 2 seconds if (System.currentTimeMillis() - soundLastPlayed >= 2000) { mc.worldServers[0].playSound(bx + xo, by + l, bz + zo, "satscapesimukraft:construction", 1f, 1f, false); soundLastPlayed = System.currentTimeMillis(); } // spawn particles on client side if (mc.worldServers[0].isRemote) { mc.worldServers[0].spawnParticle("explode", bx + xo, by + l, bz + zo, 0, 0.3f, 0); mc.worldServers[0].spawnParticle("explode", bx + xo, by + l, bz + zo, 0, 0.2f, 0); mc.worldServers[0].spawnParticle("explode", bx + xo, by + l, bz + zo, 0, 0.1f, 0); } if (blockId != 0 && ModSimukraft.gameMode != GameMode.CREATIVE) { ModSimukraft.states.credits -= (0.02f); } } catch (Exception e) { ModSimukraft.log.warning("JobBuilder: Possible non-existant block (from other mod) ID=" + blockId); try { jobWorld.setBlock(bx + xo, by + l, bz + zo, Blocks.air, 0, 0x03); } catch (Exception e2) { e2.printStackTrace(); } } // this exceptions when another mod's block is placed down } } catch (Exception e) { e.printStackTrace(); } } //remove from requirements /* if (!want.contentEquals("")) { try { Iterator it = theFolk.theBuilding.requirements.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); ItemStack is=(ItemStack) pairs.getKey(); if (is.itemID >0) { if (is.itemID==wantIS.itemID) { int left=theFolk.theBuilding.requirements.get(wantIS); left--; if (left>0) { theFolk.theBuilding.requirements.put(wantIS, left); } else { theFolk.theBuilding.requirements.remove(wantIS); } } } } } catch(Exception e) { ModSimukraft.log.info("JobBuilder:Builder requirement was null - no biggie"); } } */ acount++; ltr++; if (ltr == theBuilding.ltrCount) { ltr = 0; ftb++; if (ftb == theBuilding.ftbCount) { ftb = 0; l++; if (l == theBuilding.layerCount) { theStage = Stage.COMPLETE; stageComplete(); return; } } } if (blockId == 0 || alreadyPlaced) { runDelay = 0; } else { if (ModSimukraft.gameMode == GameMode.CREATIVE) { runDelay = 0; } else { runDelay = (int)(2000 / theFolk.levelBuilder); } } if (theFolk.theEntity != null) { theFolk.theEntity.swingItem(); } } while (blockId == 0 || alreadyPlaced); } // end step 2 } private void stageComplete() { theFolk.isWorking = false; if (theBuilding != null) { if (theBuilding.buildingComplete) { // return; } if (theBuilding != null) { theBuilding.buildingComplete = true; ModSimukraft.sendChat(theFolk.name + " has completed building a " + theBuilding.displayNameWithoutPK); /*TODO: Re-Implement*/ //ModSimukraft.proxy.getClientWorld().playSound( // mc.thePlayer.posX, mc.thePlayer.posY, // mc.thePlayer.posZ, "satscapesimukraft:cash", 1f, 1f, false); theBuilding.saveThisBuilding(); theFolk.theBuilding=null; } else { ModSimukraft .sendChat("Error: could not set the building that " + theFolk.name + " was building " + "to 'complete', try rebuilding right away (no cost) to try again"); } } if (theFolk.theEntity != null) { theFolk.theEntity.setSneaking(false); } theFolk.stayPut = false; theFolk.selfFire(); theStage = Stage.IDLE; //bodgy fix to make sure buildings are complete - probably no longer needed, original bug caused by V3 class bug boolean activeBuilders = false; for (int f = 0; f < ModSimukraft.theFolks.size(); f++) { FolkData fd = ModSimukraft.theFolks.get(f); if (fd.vocation == Vocation.BUILDER) { activeBuilders = true; } } if (!activeBuilders) { for (int b = 0; b < ModSimukraft.theBuildings.size(); b++) { Building building = ModSimukraft.theBuildings.get(b); building.buildingComplete = true; } } } @Override public void onArrivedAtWork() { int dist = 0; dist = theFolk.location.getDistanceTo(theFolk.employedAt); if (dist <= 1) { theFolk.action = FolkAction.ATWORK; theFolk.stayPut = true; theFolk.statusText = "Arrived at the building site"; theStage = Stage.BLUEPRINT; } else { theFolk.gotoXYZ(theFolk.employedAt, null); } } public enum Stage { IDLE, WORKERASSIGNED, BLUEPRINT, WAITINGFORRESOURCES, INPROGRESS, COMPLETE; @Override public String toString() { String ret = ""; if (this == IDLE) { ret = "Idle"; } else if (this == WORKERASSIGNED) { ret = "Builder has been hired and on their way"; } else if (this == BLUEPRINT) { ret = "Builder is looking though blueprints"; } else if (this == WAITINGFORRESOURCES) { ret = "Builder is checking the resources for the building"; } else if (this == INPROGRESS) { ret = "Builder is busy building"; } else if (this == COMPLETE) { ret = "Building work is complete"; } return ret; } } } as far as i can tell, the bug is inside the onUpdate() method but beyond that i'm, lost
-
it's not just you m8, i frequently go without answers aswell what's even worse is when you dont know how to ask your question haha
-
oh.... turns out what i thought was the entity doing it's job, was actually a completley different block :L... i know the problem now
-
i'm attempting to update Sim-U-Kraft to 1.7 just now and have hit a bit of a bug i cannot solve, the NPC's wont render 0.o i cannot work out how to resolve this error this is the class to render the NPC package info.satscape.simukraft.client; import info.satscape.simukraft.ModSimukraft; import info.satscape.simukraft.common.EntityFolk; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; public class RenderFolk extends RenderBiped { //constructor public RenderFolk(ModelBiped modelbase) { super(modelbase, 1f); this.mainModel=modelbase; renderPassModel=modelbase; System.out.println("RenderFolk() called"); } @Override // new in 1.6.2 protected ResourceLocation getEntityTexture(Entity entity) { if (entity instanceof EntityFolk) { EntityFolk theFolk = (EntityFolk)entity; ResourceLocation myTexture = new ResourceLocation("satscapesimukraft", "skins/" + theFolk.getTexture()); return myTexture; } else { return null; } } @Override public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { System.out.println("doRender() called"); super.doRender(par1Entity, par2, par4, par6, par8, par9); doRenderFolk((EntityFolk)par1Entity, par2, par4, par6, par8, par9); //doRenderLiving((EntityLiving) entity, d, d1, d2, f, f1); } @Override public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1) { double d3 = d1 - (double) entityliving.yOffset; super.doRender(entityliving, d, d3, d2, f, f1); System.out.println("doRender() called"); doRenderFolk((EntityFolk) entityliving, d, d3, d2, f, f1); System.out.println("doRender() called"); } private void doRenderFolk(EntityFolk entityFolk, double d, double d1, double d2, float f, float f1) { System.out.println("doRender() called"); float f2 = 1.6F; float f3 = 0.01666667F * f2; float f6 = 0.2F; if (entityFolk.theData != null) { if (entityFolk != null) { double dist = entityFolk.getDistanceToEntity(Minecraft.getMinecraft().thePlayer); if (dist < 40) { if (entityFolk.theData.age < 18) { displayText(entityFolk.theData.name + " (" + entityFolk.theData.age + ")", 0.03F, 0xFFFFFFFF, (float) d, (float) d1 + f3 + f6 - 0.4f, (float) d2, entityFolk); displayText(entityFolk.theData.statusText, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 - 0.7f, (float) d2, entityFolk); displayText(entityFolk.theData.status4, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 - 1.0f, (float) d2, entityFolk); } else { if (dist >= 4) { displayText(entityFolk.theData.name + " (" + entityFolk.theData.age + ")", 0.03F, 0xFFFFFFFF, (float) d, (float) d1 + f3 + f6, (float) d2, entityFolk); displayText(entityFolk.theData.statusText, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 - 0.3f, (float) d2, entityFolk); } else { displayText(entityFolk.theData.name + " (" + entityFolk.theData.age + ")", 0.03F, 0xFFFFFFFF, (float) d, (float) d1 + f3 + f6 + 1.5f, (float) d2, entityFolk); displayText(entityFolk.theData.statusText, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 + 1.2f, (float) d2, entityFolk); displayText(entityFolk.theData.status1, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 + 0.9f, (float) d2, entityFolk); displayText(entityFolk.theData.status2, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 + 0.6f, (float) d2, entityFolk); displayText(entityFolk.theData.status3, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 + 0.3f, (float) d2, entityFolk); displayText(entityFolk.theData.status4, 0.02F, 0xFFFFFF00, (float) d, (float) d1 + f3 + f6 + 0.0f, (float) d2, entityFolk); } } } } } System.out.println("doRender() called"); } private void displayText(String s, float f, int i, float f1, float f2, float f3, EntityFolk entitybuilder) { FontRenderer fontrenderer = getFontRendererFromRenderManager(); GL11.glPushMatrix(); GL11.glTranslatef(f1, f2 + 2.3F, f3); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-f, -f, f); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int j = fontrenderer.getStringWidth(s) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex(-j - 1, -1D, 0.0D); tessellator.addVertex(-j - 1, 8D, 0.0D); tessellator.addVertex(j + 1, 8D, 0.0D); tessellator.addVertex(j + 1, -1D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, i); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, i); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); } } if you need another class to look at please ask. i have spent several days on this and cannot find the solution on my own
-
i'm not sure if i'm in the right forum for this so sorry if i'm not... i have spent the last week and a bit updating Sim-U-Kraft to 1.7.10 and plan to make it SMP when i have the original mod working again. but i have hit a dead end, i am a little out of my depth here and really need some help to resolve the bugs that i have. i was wondering if there is anyone out there who would be willing to get in touch with me, add me on Skype and help on a regular basis with updating this mod. credit would be given where due. please, i really want to update this mod but i have hit a brick wall now. any help would be appreciated thanks, jamie
-
okay, so after a week's work i am finally down to my last 10 errors on the Sim-U-Kraft Mod. i cannot find a single tutorial or helpful topic on the internet to explain to me how to update this "CommonTickHandler" class to 1.7. here is the section of the class that is fill of errors: @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { if (type.equals(EnumSet.of(TickType.SERVER))) { onTickInGame(); } if (type.equals(EnumSet.of(TickType.WORLDLOAD))) { System.out.println("WorldLoad event tick"); } } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.SERVER, TickType.WORLDLOAD); //add more types? } public String getLabel() { return "CommonTickHandler"; } } could anybody help me out here? it looks like the "TickType" class doesn't exist anymore i also have errors with "tickStart(....)" and "tickEnd(....)"
-
thanks, will do
-
okay so i've been updating the Sim-U-Kraft mod from 1.6 and intend to make it SMP later aswell, omong the 1,088 errors i have left i found this bit of code: for (World w : MinecraftServer.getServer().worldServers) { if (w.loadedEntityList.size() > 0) { serverWorld = w; currentWorld = ModSimukraft.getSavesDataFolder(); ModSimukraft.log.info("CommTH: Startup - set serverWorld/currentWorld"); ModSimukraft.resetAndLoadNewWorld(); PacketDispatcher.sendPacketToAllPlayers(PacketHandler.makePacket("", "gamereset", "")); break; } } } catch (Exception e) { serverWorld = null; //will exception until first player has spawned! } i am quite new with forge and frankly i havent the foggiest what this does or where to begin to go about fixing the errors here: and could anybody tell me what i need to change to fix the errors? sorry if this comes across as a vague question, if you need any more information ask for it and i will provide it
-
hi, I'm currently trying to update the SIM-U-KRAFT to 1.7 and then plan to make it SMP i find throughout the code a 'Modloader' class being used. I'm having a little difficulty finding the appropriate code i need to replace it. could someone tell me, or point me in the direction of the code i need? double dist = entity.getDistanceToEntity(ModLoader.getMinecraftInstance().thePlayer); ################ //this isnt Modloader class but i still need some help resolving this error ItemStack is = (ItemStack) pairs.getKey(); if (is.itemID > 0) { String itemName = is.getDisplayName(); I'm not sure if any of the code needs context so if it does i will be happy to provide the surrounding code
-
vectors to define the length between blocks? could you explain that a bit more please? i'm using a method i was taught in college for searching arrays haha.... treating the map as a very big array for int i /// x for int j /// y for int k /// z at the moment it doesn't check for energy, it just spreads the block when it finds a provider or booster block. there's an if statement if the block at par1 + i, par2 + j, par3 + k is a generator or booster then spread the block
-
i'm calling the method from another block when the block updates (although i need to reconsider this as the block spreads and ends up 20*20*20 blocks which is very CPU intensive ) and at the moment the method is actually in the block itself, i will look for a tile entity tutorial now..... a "getBlock(world,x,y,z)" would have been much easier for those occasions where you only need to call a single method haha..... i wonder if i can implement that by creating an API...... hmmmm