Everything posted by CBUltimate
-
[1.11] How to cancel bucket use event?
I would assume placing lava with bucket can be canceled in BlockEvent.PlaceEvent, but it doesn't, so how can cancel players placing down lava? Thanks in advance.
-
[1.11] Save server sided list?
I'm sorry if this may sound stupid but If I remove static, my ModEventHandler class can't access it. From there on I'm not sure what to do. I've renamed my mod to mod.cbultimate. Thanks for the tip, my unlocalized names includes ModID now. Thanks for that too.
-
[1.11] Save server sided list?
Sorry, but I got it working. I just had to markDirty(). It works perfectly now. I'm just making this for my learning so com.cbultimate is just my name and .com. Domain name's not taken. Thanks for your help. package com.cbultimate.stranded; import net.minecraft.world.World; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; //Created by CBU on 14/1/2017. public class ModEventHandler { @SubscribeEvent public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event){ System.out.println(event.player.getDisplayName() + " has logged in the server."); } private final static String cupboard_dataIdentifier = "ToolCupboards"; @SubscribeEvent public void blockPlacedEvent(BlockEvent.PlaceEvent event){ System.out.println("(" + event.getPlacedBlock().getBlock().getUnlocalizedName() + ") was placed " + event.getPos().toString()); World world = event.getWorld(); ModWorldSavedData modWorldSavedData = (ModWorldSavedData) world.getPerWorldStorage().getOrLoadData(ModWorldSavedData.class, cupboard_dataIdentifier); if (modWorldSavedData == null) { modWorldSavedData = new ModWorldSavedData(cupboard_dataIdentifier); } if (event.getPlacedBlock().getBlock().getUnlocalizedName().equals("tile.wooden_toolcupboard")){ ModWorldSavedData.ToolCupboards.add(new Vector3(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ())); world.getPerWorldStorage().setData(cupboard_dataIdentifier, modWorldSavedData); modWorldSavedData.markDirty(); System.out.println("Tool Cupboards: " + ModWorldSavedData.ToolCupboards.size()); } } } package com.cbultimate.stranded; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.WorldSavedData; import java.util.ArrayList; //Created by CBU on 17/1/2017. public class ModWorldSavedData extends WorldSavedData { public static ArrayList<Vector3> ToolCupboards = new ArrayList<Vector3>(); public ModWorldSavedData(String name) { super(name); } @Override public void readFromNBT(NBTTagCompound nbt) { NBTTagList cupboardList = nbt.getTagList("ToolCupboards", 10); ToolCupboards.clear(); for (int i=0; i< cupboardList.tagCount(); i++){ NBTTagCompound newCompound = cupboardList.getCompoundTagAt(i); int X = newCompound.getInteger("x"); int Y = newCompound.getInteger("y"); int Z = newCompound.getInteger("z"); ToolCupboards.add(new Vector3(X, Y, Z)); } System.out.println("Loaded " + ToolCupboards.size() + " cupboards."); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { NBTTagList cupboardList = new NBTTagList(); for (int i=0;i<ToolCupboards.size(); i++){ NBTTagCompound newCompound = new NBTTagCompound(); Vector3 position = ToolCupboards.get(i); newCompound.setInteger("x", position.x); newCompound.setInteger("y", position.y); newCompound.setInteger("z", position.z); cupboardList.appendTag(newCompound); } compound.setTag("ToolCupboards", cupboardList); return compound; } }
-
[1.11] Save server sided list?
I'm starting to understand how WorldSavedData works, but when reload the game it doesn't load any data. Help? package com.cbultimate.stranded; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.WorldSavedData; import java.util.ArrayList; //Created by CBU on 17/1/2017. public class ModWorldSavedData extends WorldSavedData { public static ArrayList<Vector3> ToolCupboards = new ArrayList<Vector3>(); public ModWorldSavedData(String name) { super(name); } @Override public void readFromNBT(NBTTagCompound nbt) { NBTTagList cupboardList = nbt.getTagList("ToolCupboards", 10); ToolCupboards.clear(); for (int i=0; i< cupboardList.tagCount(); i++){ NBTTagCompound newCompound = cupboardList.getCompoundTagAt(i); int X = newCompound.getInteger("x"); int Y = newCompound.getInteger("y"); int Z = newCompound.getInteger("z"); ToolCupboards.add(new Vector3(X, Y, Z)); } System.out.println("Loaded " + ToolCupboards.size() + " cupboards."); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { NBTTagList cupboardList = new NBTTagList(); for (int i=0;i<ToolCupboards.size(); i++){ NBTTagCompound newCompound = new NBTTagCompound(); Vector3 position = ToolCupboards.get(i); newCompound.setInteger("x", position.x); newCompound.setInteger("y", position.y); newCompound.setInteger("z", position.z); cupboardList.appendTag(newCompound); } compound.setTag("ToolCupboards", cupboardList); return compound; } } private final static String cupboard_dataIdentifier = "ToolCupboards"; @SubscribeEvent public void blockPlacedEvent(BlockEvent.PlaceEvent event){ System.out.println("(" + event.getPlacedBlock().getBlock().getUnlocalizedName() + ") was placed " + event.getPos().toString()); World world = event.getWorld(); ModWorldSavedData modWorldSavedData = (ModWorldSavedData) world.getPerWorldStorage().getOrLoadData(ModWorldSavedData.class, cupboard_dataIdentifier); if (modWorldSavedData == null) { modWorldSavedData = new ModWorldSavedData(cupboard_dataIdentifier); } if (event.getPlacedBlock().getBlock().getUnlocalizedName().equals("tile.wooden_toolcupboard")){ ModWorldSavedData.ToolCupboards.add(new Vector3(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ())); } world.getPerWorldStorage().setData(cupboard_dataIdentifier, modWorldSavedData); System.out.println("Tool Cupboards: " + ModWorldSavedData.ToolCupboards.size()); }
-
[1.11] Save server sided list?
How to make a ArrayList of block position on the server side and save it so it can be loaded the next time the server reopens?
-
[1.11] Protecting blocks in a region.
I want to use BlockEvent.PlaceEvent to check if it is within the block(Authentication Block)'s protecting region 16x16x16 and whenever a player place a block, the Authentication block checks if the player's name is in the Arraylist of the block's Tile Entity, if yes, allow player to place. If not, cancel the player's Place event and display a message to them that it's a protected area. I want to know how can my BlockEvent.PlaceEvent check if player is placing a block within the Authentication Block's region. Thanks for helping.
-
[1.11] Protecting blocks in a region.
I've made a block which can be authorized by players.How should I make that when it's authorized, they should be allow to place blocks in a 16x16x16 radius of the block?
-
[1.11] Protecting blocks in a region.
I'm stuck working with TileEntity, I still don't quite understand what's wrong, boolean pass keeps returning false and doesn't get to executeAuthorization(). Please help, thanks in advance.
-
[1.11] Protecting blocks in a region.
I've added createTileEntity in the block class and made a new class for the tile entity which I've already registered, but I'm not sure how should I use it for storing my arrays of authorized players. :'( - hasTileEntity is deprecated. @Nullable @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityToolCupboard(); } public ArrayList<String> Authorized = new ArrayList<String>(); @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) { if (worldIn.isRemote) { return true; } else { boolean isClaimed = false; for (int c = 0; c < Authorized.size(); c++) { if (playerIn.getName().equals(Authorized.get(c))) { isClaimed = true; Authorized.remove(c); playerIn.addChatMessage(new TextComponentString("You have been de-authorized by this tool cupboard.")); break; } } if (!isClaimed) { playerIn.addChatMessage(new TextComponentString("You have been authorized by this tool cupboard.")); Authorized.add(playerIn.getName()); playerIn.addChatMessage(new TextComponentString(Authorized.toString())); } return true; } } package com.cbultimate.stranded.tileentity; import net.minecraft.tileentity.TileEntity; public class TileEntityToolCupboard extends TileEntity { }
-
[1.11] Protecting blocks in a region.
Since I have hardness and resistance set on the block, how should I change it into TileEntity while keeping those settings?
-
[1.11] Protecting blocks in a region.
So far I've made it when I right click the block, a player's name will be on the block's ArrayList, problem is it's not independent. If I have two blocks, the would both have the same list. How can I separate them and step do I take next to protect the 16x16x16 around the block. Thanks in advance!
-
[1.11] Protecting blocks in a region.
How should I make a block to function as a region build protector? I want to make a block when placed, will protect a 16x16x16 region in the world. So far I've only looked up how to cancel BlockEvent.PlaceEvent but I don't know what else I need to learn to piece them together. This could be a bit much so thanks in advance for any small bits of information.
-
[1.11] Modify properties of vanilla blocks?
Hi, I'm pretty new to modding and I would like to know how to modify the hardness and resistance of a vanilla wooden door? Thanks in advance~
-
Modifying Vanilla Iron Ingot
Why does it only smelt 1 Iron Ingot when I set the amount to 2? GameRegistry.addSmelting(new ItemStack(Items.IRON_INGOT, 2), new ItemStack(ModItems.reinforcedIronBar), 1.0F);
-
Modifying Vanilla Iron Ingot
Thanks, item.ingotIron.name=Iron Bar worked well. I'd like to ask where can I get the list of all items?
-
Modifying Vanilla Iron Ingot
Thanks, but it didn't work.
-
Modifying Vanilla Iron Ingot
Hi, I'm very new to modding and I want to know if it is possible to rename the vanilla Iron Ingot into Iron Bar and make that if you smelt Iron Ingot it will become Reinforced Iron Bar (which I've already made). Thanks in advance!
IPS spam blocked by CleanTalk.