Everything posted by Brickfix
-
[1.8] Totem Mod - keeping nasty monsters out of your base!
Thanks for the feedback I'm not sure what you mean with the attract ... Should it act like a kind of mobspawner? That would be fairly easy for me to implement. But if it should make mobs go to the location I have no clue on how to do this, as this would mean modifying the AI of the mobs and I got no clue on how to do this. I will look into adding a type of Totem that will summon mobs, so basically an inverted version of what I already have. I will have to look for a way on how to make it balanced, though ...
-
[1.8] Totem Mod - keeping nasty monsters out of your base!
Update! I reworked the whole system as well as the textures
-
[1.8] Totem Mod - keeping nasty monsters out of your base!
After having some trouble while building a large crypt, being close to ragequit, I began to ask myself: How can I stop these monsters from walking through my gate without blocking it of with some dirt blocks which are looking so ugly next to my quartz and obsidian? Are you having simiular problems? Are you blown up all the time by creepers while you are looking into your chest during your mining adventure? Are zombies waiting everywhere in your garden? Than this mod is for you: I present to you the Totem Mod! This mod adds 8 new blocks, making your home a safer place! Screenshot: The way you set up your protective totem is, as you can see in the picture, rather easy: First, you need a pedestal. On top of the pedestal, you place an offering to the gods. An offering can be a small offering or a great one, and the offering determines the effective range of your totem. On top of this, you place up to four totem blocks referring to a monster. ATM, you can set spiders, skeletons, zombies and creepers as a target for the totem. To cap it all of, place a totem top block on your totem. A lightning will strike if you set it up correctly. Keep in mind that a totem may not be more than 7 blocks high! Crafting: Something special for rpg servers or creative players / mapmakers: Corrupted totems! They basically work like normal mob spawners, but are set up a bit differently: Every totem block has a corrupted counterpart, which are currently not craftlable. They way to set up the totem is the same, just that you can leave out the difficulty lvl block (the counterpart to the range determining offering block). No difficulty block will make regular mobs spawn, but with the difficulty set the mobs will carry better armor and swords. At the moment, when using the difficulty blocks, skeletons will have swords instead of bows, but this will change in the next update though. This is the only feature added in the 3.0 update, if you don't need it you can stick with the 2.0 update. Download If you discover any bugs, feel free to inform me! Do you have any suggestions? Do you consider the crafting repecies to easy or to expensive? Go ahead and tell me what you think
-
[SOLVED]TileEntity implementing IUpdatePlayerListBox only working clientside
Its like my classes are bewitched or something. I even compiled it all and tested it with my actual minecraft game and the problems still occured exactly as described above. I will update my forge version, maybe this is causing it ... EDIT: I recompiled forge and suddenly all problems have disappeared. Thanks a lot anyway, I have learned a lot of other things about tile entities during the process
-
[SOLVED]TileEntity implementing IUpdatePlayerListBox only working clientside
Yes I commented them out for a later test, but I ran it with both not commented out: After I set the block, poth printed out. After exiting minecraft and reloading the world only the client part printed.
-
[1.7.10] Custom structures not generating
Your method setBlock, the one at the very bottom of your structure class, is doing nothing. Every time you want to generate a block your are actually not doing anything, this is why you don't find your house as it is not generating anywhere. BTW, there seems to be nothing with distance in it (distance to the spawn I guess), basically your code will try to generate it in EVERY chunk.
-
[SOLVED]TileEntity implementing IUpdatePlayerListBox only working clientside
Ok so here are all my classes: Main mod class: http://pastebin.com/CUzCNWF0 Common Proxy: http://pastebin.com/ncaUgkpx The Block class: http://pastebin.com/Q2EFxbX5 The TileEntity: http://pastebin.com/cgGQXdxT And the Logic class: http://pastebin.com/bmW1yBnW I left out the client proxy as it is doing nothing ATM as well as my constants class as it is pretty obvious what it is doing. Thanks again for taking the time and looking over my problem
-
[1.7.10] Custom structures not generating
jep you registered it but you registered it at the wrong method, you should register it at your init method not at your preInit. Secondly, your structure does not need to implement IWorldGenerate, to extend the WorldGenerator is enough. And at last, my expirience with minecraft is that the terrain is never flat. So I would highly doubt that this will ever be a true argument: if(!locationIsValidSpawn(world, i, j, k) || !locationIsValidSpawn(world, i + 18, j, k) || !locationIsValidSpawn(world, i + 18, j, k + 27) || !locationIsValidSpawn(world, i, j, k + 27)) I would recommend you disable the check and just generate it in a superflat world. Also I would recommend do add this small line of code into your generator to make sure that it is actually called: System.out.println("generating at: " + xCoord + ";" + zCoord); I hope this helps a little
-
[SOLVED]TileEntity implementing IUpdatePlayerListBox only working clientside
Did it, didn't change a thing
-
[1.7.10] Custom structures not generating
As far as I know the GameRegistry.registerWorldGenerator(//BLA); goes here: @EventHandler public void Init(FMLInitializationEvent event){ } You put it in PreInit
-
[SOLVED]TileEntity implementing IUpdatePlayerListBox only working clientside
So it seems that I have not implemented the onDataPacket() and getDescriptionPacket() methods, I added these in and the problem persists. I am really sure that it runs the update() only client side, I added if (this.worldObj.isRemot) { System.out.println("Updated ClientSide"); return; } else { System.out.println("Updated ServerSide"); //Here comes the rest of my code } Turns out that when I place the block, both messages pop up in the console. Closing and reloading the world still keeps both messages showing up. Ending the minecraft game and restarting it only leads to the display of the "Updated ClientSide" message. I copied over the onDataPacket() and getDescriptionPacket() methods into my code, and the problem is still there. Maybe I set them up incorrectly? @Override public Packet getDescriptionPacket() { NBTTagCompound nbtTagCompound = new NBTTagCompound(); writeToNBT(nbtTagCompound); int metadata = getBlockMetadata(); return new S35PacketUpdateTileEntity(this.pos, metadata, nbtTagCompound); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.getNbtCompound()); } I have basically read through everything in you blog, it is explaining really good and already helped me out several times. Thanks for taking the time
-
[SOLVED]TileEntity implementing IUpdatePlayerListBox only working clientside
I have created a block that shall serve as a kind of totem pole that keeps bad monsters away. It basically works flawlessly, killing all skeletons around it as it is supposed to be and so on. But there is one weird thing happening every time I end minecraft and open the world again after relaunching minecraft: Basically nothing happens. The tileentity also summons lightning, and for a time I had a weird semilightning appearing everytime I reloaded the world. I got rid of it checking if the world was remote, as summoning entities and so forth are only working it the world is not remote. So, as I said, when reloading the world after closing minecraft and relaunching it, the tile entity stops to work. Or at least whatever it does, it does not seem to have an effect anymore. I tested it in a various amount of ways, printing out a lot of different things in the console. Additionally please note that when placing the block, it all works, and when quitting the world to the title and than opening it again it works as well without a problem. It only does not work when restarting the game itself. Here is my code of the Block class package com.brickfix.totemmod.blocks; import java.util.Random; import com.brickfix.totemmod.TotemBlockLogic; import com.brickfix.totemmod.lib.Constants; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.command.ICommandSender; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; public class TotemBlockTest extends BlockContainer { public static final String name = "totem_block"; public boolean isCharged; public TotemBlockTest() { super(Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); this.setHardness(5.0F); //this.setTickRandomly(true); GameRegistry.registerBlock(this, name); setUnlocalizedName(Constants.MODID + "_" + name); } public String getName() { return this.name; } public int getRenderType() { return 3; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityTotemBlock(); } } Here is the TileEntity package com.brickfix.totemmod.blocks; import java.util.Random; import net.minecraft.command.CommandBase; import net.minecraft.command.NumberInvalidException; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.server.gui.IUpdatePlayerListBox; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.brickfix.totemmod.TotemBlockLogic; import com.brickfix.totemmod.TotemMod; import com.sun.org.apache.xalan.internal.xsltc.util.IntegerArray; public class TileEntityTotemBlock extends TileEntity implements IUpdatePlayerListBox { public int cooldown; public boolean isCharged; private final TotemBlockLogic totemLogic = new TotemBlockLogic() { @Override public String getCommand() { return "/kill @e[type=Skeleton,r=5]"; } @Override public BlockPos getPosition() { return TileEntityTotemBlock.this.pos; } @Override public Vec3 getPositionVector() { return new Vec3((double)TileEntityTotemBlock.this.pos.getX() + 0.5D, (double)TileEntityTotemBlock.this.pos.getY() + 0.5D, (double)TileEntityTotemBlock.this.pos.getZ() + 0.5D); } @Override public World getEntityWorld() { return TileEntityTotemBlock.this.worldObj; } }; public int getCooldown() { return 100; } public TotemBlockLogic getTotemLogic() { return this.totemLogic; } public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("Cooldown", this.cooldown); compound.setBoolean("Charged", this.isCharged); } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.cooldown = compound.getInteger("Cooldown"); this.isCharged = compound.getBoolean("Charged"); } static { addMapping(TileEntityTotemBlock.class, "TotemBlock"); } public void update() { if (this.worldObj.isRemote) return; this.isCharged = isCharged(); if (this.cooldown==0) { int i=0; if (this.isCharged) { i = totemLogic.trigger(this.worldObj); } if (i!=0) { this.cooldown = this.getCooldown(); Item rm = Items.fireworks; NBTTagCompound tag0 = new NBTTagCompound(); NBTTagList explosions = new NBTTagList(); NBTTagCompound tag1 = new NBTTagCompound(); NBTTagCompound tag2 = new NBTTagCompound(); int[] array = new int[1]; array[0] = 65536*230; tag2.setIntArray("Colors", array); tag2.setBoolean("Flicker", true); explosions.appendTag(tag2); tag1.setTag("Explosions", explosions); tag1.setByte("Flight", (byte) 0); tag0.setTag("Fireworks", tag1); ItemStack modifier = new ItemStack(rm); modifier.setTagCompound(tag0); Entity effect = new EntityFireworkRocket(this.worldObj, pos.getX()+0.5D, pos.getY()+0.5D, pos.getZ()+0.5D, modifier); this.worldObj.spawnEntityInWorld(effect); } } else if (this.cooldown > 0) { this.cooldown--; } } public boolean isCharged() { boolean flag = this.isCharged; boolean flag2 = false; BlockPos pos = this.pos; if ((this.worldObj.getBlockState(pos.up()) == Blocks.obsidian.getDefaultState()) && (this.worldObj.getBlockState(pos.down()) == Blocks.obsidian.getDefaultState())) { flag2 = true; } if (flag==false && flag2==true) { this.lightningStrikes(worldObj, pos); } return flag2; } protected void lightningStrikes(World world, BlockPos pos) { double dx = (double)pos.getX(); double dy = (double)pos.getY(); double dz = (double)pos.getZ(); String sx = String.valueOf(pos.getX()); String sy = String.valueOf(pos.getY()); String sz = String.valueOf(pos.getZ()); try { dx = CommandBase.func_175761_b(dx, sx, true); dy = CommandBase.func_175761_b(dy, sy, false); dz = CommandBase.func_175761_b(dz, sz, true); } catch (NumberInvalidException e) { e.printStackTrace(); return; } world.addWeatherEffect(new EntityLightningBolt(world, dx, dy, dz)); } } And here is my TotemLogic class package com.brickfix.totemmod; import net.minecraft.command.ICommandSender; import net.minecraft.command.CommandResultStats.Type; import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; import net.minecraft.util.BlockPos; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; public abstract class TotemBlockLogic implements ICommandSender { public int trigger(World worldIn) { MinecraftServer minecraftserver = MinecraftServer.getServer(); int i = 0; if (minecraftserver != null && minecraftserver.func_175578_N()) { try { i = minecraftserver.getCommandManager().executeCommand(this, getCommand()); //System.out.println(getCommand()); return i; } catch(Throwable t) { System.out.println("could not execute command"); return 0; } } return i; } public abstract String getCommand(); @Override public void addChatMessage(IChatComponent message) { //We do not want to see a chat message } @Override public String getName() { // TODO Auto-generated method stub return "totem"; } @Override public Entity getCommandSenderEntity() { // This is no entity and not important return null; } @Override public boolean sendCommandFeedback() { //We do not need this return false; } @Override public void setCommandStat(Type type, int amount) { // We do not need this } @Override public IChatComponent getDisplayName() { return null; } @Override public boolean canUseCommand(int permLevel, String commandName) { return true; } } It would be awesome if you could help me out with this
-
Creating a 'commandblock' that only runs one predetermined command
Yes I know that, but for some reason, every time I load this world the block is in, including the blocks placed after I added the TileEntity, the fired command does not work. As you can see in my TotemLogic, I have the integer i printed out after each attempt. The funny thing is that i is always 0 nevermind how many skeletons are walking around, but when I replace the block again it prints out the amount of monsters killed. Really weird EDIT: And to add on to the weirdness: If I only quit the world, and than enter it again without restarting minecraft it works without a problem!
-
Creating a 'commandblock' that only runs one predetermined command
Thanks, my TileEntity is now updating every tick. But now I ran into the next problem: Without changing the trigger method in my TotemLogic, the command is simply not executed. I know that the command works as it worked just fine using the block update methods. Here is the code of the tile entity public class TileEntityTotemBlock extends TileEntity implements IUpdatePlayerListBox { public int cooldown; private final TotemBlockLogic totemLogic = new TotemBlockLogic() { @Override public String getName() { // TODO Auto-generated method stub return "totem"; } @Override public IChatComponent getDisplayName() { return null; } @Override public void addChatMessage(IChatComponent message) { //We do not want to see a chat message } @Override public boolean canUseCommand(int permLevel, String commandName) { return true; } @Override public BlockPos getPosition() { return TileEntityTotemBlock.this.pos; } @Override public Vec3 getPositionVector() { return new Vec3((double)TileEntityTotemBlock.this.pos.getX() + 0.5D, (double)TileEntityTotemBlock.this.pos.getY() + 0.5D, (double)TileEntityTotemBlock.this.pos.getZ() + 0.5D); } @Override public World getEntityWorld() { return TileEntityTotemBlock.this.worldObj; } @Override public Entity getCommandSenderEntity() { // This is no entity and not important return null; } @Override public boolean sendCommandFeedback() { //We do not need this return false; } @Override public void setCommandStat(Type type, int amount) { // We do not need this } }; public int getCooldown() { return 20; } public TotemBlockLogic getTotemLogic() { return this.totemLogic; } public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("cooldown", this.cooldown); } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.cooldown = compound.getInteger("cooldown"); } static { addMapping(TileEntityTotemBlock.class, "TotemBlock"); } public void update() { if (this.cooldown==0) { this.getTotemLogic().trigger(this.worldObj); this.cooldown = getCooldown(); } else { this.cooldown--; } } } And here of my TotemLogic: public abstract class TotemBlockLogic implements ICommandSender { public void trigger(World worldIn) { try { int i = MinecraftServer.getServer().getCommandManager().executeCommand(this, "/kill @e[type=Skeleton,r=5]"); System.out.println(i); } catch(Throwable t) { System.out.println("could not execute command"); } } } But thanks again for the help EDIT: Ok this is getting really weird: Apparently my code works 100% correctly. The only problem is that on loading a world where the block is already placed, nothing happens. If I set a new block, it works without any problem. Really strange.
-
Creating a 'commandblock' that only runs one predetermined command
Thanks for the help, I tried to set it up and it works, I just had to add a TileEntity and a kind of CommandBlockLogic like class to make it work. Only problem is that the random tick is to rare IMO, is there a chance to increase it without changing gamerules? EDIT: So I have found two things that look promissing, but both do not seem to work out that well: The is the function TickSpeed, but I got no clue what it does, and changing it doesn't seem to make a difference, and in the TileEntity I could use the update function to have it happen every tick, but I do not know if the update function is fired every tick Again thanks for any help given
-
Creating a 'commandblock' that only runs one predetermined command
Hi, I want to have a block that basically triggers the following command every 10 or 20 ticks: /kill @e[type=Skeleton, c=1, r=5] I think the most efficient way would be to use the server commands but I don't find a way how to trigger the commands. I looked through the TileEntity of the commandBlock as well as the commandBlockLogic and couln't find a clue on how to do this. I know this sounds rather simple but I seem to be overlooking something
-
[1.8] Problem concerning custom Tree
ok, I solved it has some minor flaws but I justed copied and modified some things and it worked. Thanks for the help anyway
-
[1.8] Problem concerning custom Tree
First of all, thanks for the fast reply. So I'm not really sure if I got this correctly, but on the Decorate event I can filter out what is actually decorating. So I can say that I only want a custom tree to generate when the eventtype is TREE. And when looking through the code, the BiomeDecorator.class calls the decorate funtion in the TerrainGen.class, which posts the Decorate event. So the Pre and Post event of the DecorateBiomeEvent doesn't help me at all (besides, I get the exact same problems) and I would not able to to generate a tree exactly where the game normally would generate trees anyway. And when browsing through an older mod (1.7.10) that does basically the same, I found out that it used the Decorate event as well to start its own tree generation. I think the actual problem seems to be some kind of loop: the game starts to decorate a chunk, than it 'sees' my event and after doing something with my event, it calls (for some reason unknown to me) the decoration again, which throughs the exception. I neither understand why and have to say that this is really strange ...
-
[1.8] Problem concerning custom Tree
I am trying to generate a custom tree instead of a normal tree during worldgeneration, using an eventhandler. I encountered the problem that very often the game crashes when generating my tree, throughing a RuntimeException "Already decorating!" I used a try{} catch{} block to evade the crash, and now I am getting a lot of missing chunks (basicall giant wholes in the ground), close to a tree that failed to generate. Here is my EventHandler: public class BrickfixEventHandler { @SubscribeEvent public void BiomeDecorate(Decorate event) { if (event.type == event.type.TREE) { Random rnd = event.rand; if (rnd.nextInt(5) == 0) { GenTreeTest tree = new GenTreeTest(); try { tree.growTree(event.world, event.rand, event.pos); } catch(RuntimeException e) { System.out.println("Failed to generate custom tree at " + event.pos.getX() + ":" + event.pos.getZ()); } event.setResult(Result.DENY); } } } } on thing I notice is that in the beginning, every custom tree successfully generates, while when starting to move around, the amount of Exceptions I catch in my code drastically increase. Not every tree failes, but a high amount. Thanks for any help in advance!
-
[Forge 1.8] How to Render Blocks in Inventory?
this is quite simple: For each block, there is a corresponding item which you can get as following: Item itemYourBlock = GameRegistry.findItem(mod.MODID, "yourBlock"); After this, you can simply render you block with the function you already have ~Brickfix
-
[1.8] Brickfix WorldGen - Adding new Structures to the game :)
Alpha7 is ready for download! This time I am adding my first custom blocks as well as two new structures. I hope you enjoy ~Brickfix
-
[1.8] [SOLVED] Block emitting light
Thanks, the setLightLevel method worked. ~Brickfix
-
[1.8] [SOLVED] Block emitting light
And again another problem - this time concerning a different Block: I want to create a block that emitts light. I looked around in the sourcecode on how this is achieved, but I found no clue whatsoever on how to create a block that emitts light. >.< Any help would be much appreciated, ~Brickfix
-
[1.8] [SOlVED] LighningBlock again - now not rendering in the inventory
Wow - it is so embarrasing! I just left out the "Pre" in the preInit(FMLPreInitialisationEvent event) Now it works without a problem - such a headache for just three tiny letters
-
[1.8] [SOlVED] LighningBlock again - now not rendering in the inventory
Hi Guys, I already had problems with this block, and they where problems with rendering things - now I have the problem of rendering it in the inventory. I followed wuppy29's tutorial for a custom block step by step, and even looked it up in TheGreyGhost's GitHub Repository MinecraftByExample, and I just don't find any mistake I could have made. This is the code of the Block: public class WGBlockLightning extends Block { private final String name = "lightningBlock"; public WGBlockLightning() { super(Material.rock); GameRegistry.registerBlock(this, name); setUnlocalizedName(WorldGenMod.MODID + "_" + name); setCreativeTab(CreativeTabs.tabBlock); this.setTickRandomly(true); } public String getName() { return name; } public int quantityDropped(Random random) { return 0; } protected boolean canSilkHarvest() { return true; } public void updateTick(World world, BlockPos pos, IBlockState state, Random random) { double dx = (double)pos.getX(); double dy = (double)pos.getY(); double dz = (double) pos.getZ(); String sx = String.valueOf(pos.getX()); String sy = String.valueOf(pos.getY()); String sz = String.valueOf(pos.getZ()); try { dx = CommandBase.func_175761_b(dx, sx, true); dy = CommandBase.func_175761_b(dy, sy, false); dz = CommandBase.func_175761_b(dz, sz, true); } catch (NumberInvalidException e) { // TODO Auto-generated catch block e.printStackTrace(); } world.addWeatherEffect(new EntityLightningBolt(world, dx, dy, dz)); } } This is the code of my load function in the modclass public static Block lightningBlock; public static Item itemLightningBlock; @EventHandler public void preInit(FMLInitializationEvent event) { lightningBlock = new WGBlockLightning(); //itemLightningBlock = GameRegistry.findItem(MODID, "lightningBlock"); } @EventHandler public void load(FMLInitializationEvent event) { GameRegistry.registerWorldGenerator(new StructureGenerator(), 0); if(event.getSide() == Side.CLIENT) { Item itemLightningBlock = GameRegistry.findItem(MODID, "lightningBlock"); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); ModelResourceLocation itemLightningLoc = new ModelResourceLocation(MODID + ":" + "lightningBlock", "inventory"); renderItem.getItemModelMesher().register(itemLightningBlock, 0, itemLightningLoc); } } } I know that I could use ((WGBlockLightning)lightningBlock).getName instead of "lightningBlock", but this crashes the game! All json. files have the same name: lightningBlock.json This is my json. file in the assets.worldgenmod.models.items { "parent": "worldgenmod:block/lightningBlock", "display": { "thirdperson": { "rotation": [ 10, -45, 170 ], "translation": [ 0, 1.5, -2.75 ], "scale": [ 0.375, 0.375, 0.375 ] } } } This is my json. file in the assets.worldgenmod.models.blocks { "parent": "block/cube_all", "textures": { "all": "worldgenmod:blocks/lightningBlock" } } And finally this is the json. file int the assets.worldgenmod.blockstates { "variants": { "normal": { "model": "worldgenmod:lightningBlock" } } } Note, that the problem is that the block does not render in the inventory or when throughn on the ground as an item, but not when set as a block in the world. Than the texture renders just like it is supposed to render. Thanks again for any help in advance, Brickfix
IPS spam blocked by CleanTalk.