Everything posted by Darki
-
[1.8.9] Make a Block to a Falling Block
I know that, I never said that the Code in Bukkit is the same in Minecraft I just said that the getList Method is the same method in Minecraft as in Bukkit (code changed for Minecraft compatibility) That's a good question
-
[1.8.9] Make a Block to a Falling Block
Here is the Code in Bukkit: @EventHandler public void onExplode(EntityExplodeEvent e){ fall(e); } @SuppressWarnings("deprecation") private void fall(EntityExplodeEvent e){ List<Block> list = getBlocksToFall(e); World w = e.getEntity().getLocation().getWorld(); for(Block b : list){ w.spawnFallingBlock(b.getLocation(), b.getType(), (byte) 0); b.setType(Material.AIR); } } private List<Block> getBlocksToFall(EntityExplodeEvent e){ List<Block> affectedBlocks = e.blockList(); List<Integer> xs = new ArrayList<Integer>(); List<Integer> zs = new ArrayList<Integer>(); int exY = e.getEntity().getLocation().getBlockY(); for(Block affectedBlock : affectedBlocks){ Location loc = affectedBlock.getLocation(); int x = loc.getBlockX(); if(!xs.contains(x)){ xs.add(x); } int z = loc.getBlockZ(); if(!zs.contains(z)){ zs.add(z); } } List<Block> blocksToFall = new ArrayList<>(); for(int y = exY; y <= e.getEntity().getLocation().getWorld().getMaxHeight(); y++){ for(int x : xs){ for(int z : zs){ Location loc = new Location(e.getEntity().getLocation().getWorld(), x, y, z); Block b = e.getEntity().getLocation().getWorld().getBlockAt(loc); if(b.getType() != Material.AIR){ blocksToFall.add(b); } } } } return blocksToFall; }
-
[1.8.9] Make a Block to a Falling Block
I dont know why but the same code in Bukkit works very fine. But here...NOPE...So I think the probleme is in spawning the falling sand
-
[1.8.9] Make a Block to a Falling Block
Ups this was the wrong code. I changed the hashmap a little time ago. But why dont spawn the falling sand
-
[1.8.9] Make a Block to a Falling Block
- [1.8.9] Make a Block to a Falling Block
Yeah this is a good idea but my probleme is that the falling sands doesnt spawn- [1.8.9] Make a Block to a Falling Block
Yeah. Not my probleme^^ hm I calculate something: a explosion has a radius of 3 i think you place 5 tnts that is a length of 30 blocks. The world has a 64 height that are 30x6x64 blocks = 11.500 nooooo this will not lagging . Yeah but how can I do that?- [1.8.9] Make a Block to a Falling Block
Yeah this is what I want- [1.8.9] Make a Block to a Falling Block
Ok I dont get any futher. What I want: When something explodes, I want to get all Blocks over the explosion, then I want that all this blocks falling down but I dont know why it isnt working: @SubscribeEvent public void onExplode(ExplosionEvent e) { HashMap<Block,BlockPos> fallingBlocks = getBlocksToFall(e); System.out.println(fallingBlocks.keySet().size() + ""); for (Block b : fallingBlocks.keySet()) { BlockPos blockPos = fallingBlocks.get(b); EntityFallingBlock entityFallingBlock = new EntityFallingBlock(e.world, blockPos.getX(), blockPos.getY(), blockPos.getZ(), e.world.getBlockState(blockPos)); entityFallingBlock.shouldDropItem = false; e.world.spawnEntityInWorld(entityFallingBlock); } } private HashMap<Block,BlockPos> getBlocksToFall(ExplosionEvent e){ List<Integer> xs = new ArrayList<Integer>(); List<Integer> zs = new ArrayList<Integer>(); int exY = (int) Math.round(e.explosion.getPosition().yCoord); for(BlockPos loc : e.explosion.getAffectedBlockPositions()){ int x = loc.getX(); if(!xs.contains(x)){ xs.add(x); } int z = loc.getZ(); if(!zs.contains(z)){ zs.add(z); } } HashMap<Block,BlockPos> blocksToFall = new HashMap<Block,BlockPos>(); for(int y = exY; y <= e.world.getHeight(); y++){ for(int x : xs){ for(int z : zs){ BlockPos pos = new BlockPos(x, y, z); Block b = e.world.getBlockState(pos).getBlock(); if(!b.getRegistryName().contains("air")){ blocksToFall.put(b,pos); } } } } return blocksToFall; }- [1.8.9] Make a Block to a Falling Block
Ok I see there is a Constructor with Material. I made a new Object BlockFalling for every block in the List but how can I make the blockfalling fall?- [1.8.9] Make a Block to a Falling Block
Hmm: public class BlockFalling extends Block { public static boolean fallInstantly; public BlockFalling() { super(Material.sand); this.setCreativeTab(CreativeTabs.tabBlock); } public BlockFalling(Material materialIn) { super(materialIn); } public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); } /** * Called when a neighboring block changes. */ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); } public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (!worldIn.isRemote) { this.checkFallable(worldIn, pos); } } private void checkFallable(World worldIn, BlockPos pos) { if (canFallInto(worldIn, pos.down()) && pos.getY() >= 0) { int i = 32; if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i))) { if (!worldIn.isRemote) { EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos)); this.onStartFalling(entityfallingblock); worldIn.spawnEntityInWorld(entityfallingblock); } } else { worldIn.setBlockToAir(pos); BlockPos blockpos; for (blockpos = pos.down(); canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down()) { ; } if (blockpos.getY() > 0) { worldIn.setBlockState(blockpos.up(), this.getDefaultState()); } } } } protected void onStartFalling(EntityFallingBlock fallingEntity) { } /** * How many world ticks before ticking */ public int tickRate(World worldIn) { return 2; } public static boolean canFallInto(World worldIn, BlockPos pos) { if (worldIn.isAirBlock(pos)) return true; Block block = worldIn.getBlockState(pos).getBlock(); Material material = block.blockMaterial; return block == Blocks.fire || material == Material.air || material == Material.water || material == Material.lava; } public void onEndFalling(World worldIn, BlockPos pos) { } } But how can I make any Block (not Air) with this to a Falling Block?- [1.8.9] Make a Block to a Falling Block
I try to make Blocks that are flying in the air (when something explode under the Blocks) falling on the ground. I have a List with Blocks that "have to fall", but how can I make Blocks falling?- [1.10] Set Max Health of Player
A little question but I dont find a solution: How can I set the max Health of a Player, e.g. that the player only has 5 hearts- [SOLVED] GUI not working
Ok its working. I tried it and than first there was a big error in the console and minecraft crashed but the problem was that I only had the constructor with the guiid but you have to make another constructor without anything. Now it works big thanks to you Choonster that you helped me so long You should get the Mod Rank but yeah thank you very much- [SOLVED] GUI not working
Is that right? @Override public IMessage onMessage(GuiScreenOpenPacket message, MessageContext ctx) { final GuiScreenOpenPacket msg = message; final EntityPlayer player = Minecraft.getMinecraft().thePlayer; Minecraft.getMinecraft().addScheduledTask(new Runnable() { @Override public void run() { player.openGui(Main.getInstance(), msg.gui_id, player.worldObj, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); } }); return null; }- [SOLVED] GUI not working
Ok I tried a little bit. Here my Packet: public class GuiScreenOpenPacket implements IMessage { public int gui_id; public GuiScreenOpenPacket(int gui_id) { this.gui_id = gui_id; } @Override public void fromBytes(ByteBuf buf) { gui_id = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(gui_id); } } And My Handler: public class GuiScreenOpenPacketHandler implements IMessageHandler<GuiScreenOpenPacket, IMessage> { @Override public IMessage onMessage(GuiScreenOpenPacket message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; player.openGui(Main.getInstance(), message.gui_id, player.worldObj, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); return null; } } Is that right? And how can I open the Gui with the Packet now?- [SOLVED] GUI not working
Ok I look in it and its not so difficulty. Its good that I worked with packets in the past when i coding plugins with the spigot api but one big question is open what i have to do you said i should send a packet that opens the the gui but which packet then you said i should do this after the spacketplayerpos hides the guidownloadterrain but how can i proof this? That would be fine when you can answer this- [SOLVED] GUI not working
I never worked with Packets...How can I do that?- [SOLVED] GUI not working
Another problem: When I try to open the GUI screen with the PlayerLoggedInEvent nothing happens because its a server side event but my gui handler returns null: @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; }- [SOLVED] GUI not working
How can I asked whether the GuiDownloadTerrain has been hidden?- [SOLVED] GUI not working
Ok first time after I call it: this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); in: public void handleJoinGame(SPacketJoinGame packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.get(getNetworkManager()).getOverrideDimension(packetIn), packetIn.getDifficulty(), this.gameController.mcProfiler); this.gameController.gameSettings.difficulty = packetIn.getDifficulty(); this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = packetIn.getDimension(); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); this.gameController.thePlayer.setEntityId(packetIn.getPlayerId()); this.currentServerMaxPlayers = packetIn.getMaxPlayers(); this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo()); this.gameController.playerController.setGameType(packetIn.getGameType()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new CPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); } Oh I found it here, this method: public void handlePlayerPosLook(SPacketPlayerPosLook packetIn) will be called after the first and the method do that: this.gameController.displayGuiScreen((GuiScreen)null); I think this is the problem- [SOLVED] GUI not working
Ahhh now I understand...I see it the Mehtod will be called second time after mine. I am looking for it why.- [SOLVED] GUI not working
Ok but I cant see where displayScreen is called too- [SOLVED] GUI not working
Can this be the problem: Object guiContainer = NetworkRegistry.INSTANCE.getLocalGuiContainer(mc, entityPlayer, modGuiId, world, x, y, z); because this method trys to get a GuiContainer but it isnt a container- [SOLVED] GUI not working
Here I have a Video what from the Debug, maybe you find the misstake then better: - [1.8.9] Make a Block to a Falling Block
IPS spam blocked by CleanTalk.
Important Information
By using this site, you agree to our Terms of Use.