-
Posts
796 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Kokkie
-
Change player inventory client side causes problems.
Kokkie replied to Raycoms's topic in Modder Support
You can't change anything that has to do with world data on client-side -
Can anyone please help?
-
I put it before the if-statement, but it didn't fire, my commonhandler is registered the same way as my clienthandler (only on serverside obviously) my main class @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = "[1.11]") public class KokkieMod { @SidedProxy(clientSide = Reference.CLIENTPROXY, serverSide = Reference.COMMONPROXY) public static CommonProxy proxy; @Instance(Reference.MODID) public static KokkieMod KMInstance; @EventHandler public void preInit(FMLPreInitializationEvent event) { new CheeseBlocks(); new CheeseItems(); new CheeseMobs(); new CheeseAchievements(); new CheeseSpawnPlacementRegistry(); new CheeseBiomes(); new CheeseTabs(); new CheesePacketHandler(); new CheeseDimension(); proxy.registerModels(); proxy.renderEntities(); proxy.setTitle("Minecraft - " + Minecraft.getMinecraft().getVersion() + " | KokkieMod - " + Reference.VERSION); } @EventHandler public static void init(FMLInitializationEvent event) { new CheeseCraftingAndSmelting(); proxy.registerEventHandler(); NetworkRegistry.INSTANCE.registerGuiHandler(KMInstance, new CheeseGuiHandler()); GameRegistry.registerWorldGenerator(new CheeseGeneration(), 0); } @EventHandler public static void postInit(FMLPostInitializationEvent event) { WorldType CHEESE = new WorldTypeCheese(4, "Cheese"); } } my common proxy public class CommonProxy { public void registerModels() { } public void renderEntities() { } public void setTitle(String title) { } public void registerEventHandler() { MinecraftForge.EVENT_BUS.register(new CheeseCommonHandler()); } } my common handler public class CheeseCommonHandler { @SubscribeEvent public void playerInteract(PlayerInteractEvent.LeftClickBlock event) { BlockPos pos = event.getPos(); World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); pos = pos.offset(event.getFace()); if (world.getBlockState(pos).getBlock() == CheeseBlocks.CHEESE_FIRE) { event.setCanceled(true); player.playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, 1.0F); world.setBlockToAir(pos); } } }
-
It breaks the block itself (what is on fire) and I put a println before the event.setCanceled(true) but it wasn't fired.. I also put a println at the top of the event and it didn't get fired, am I maybe using the wrong event?
-
Oh lol
-
BTW search hycrafthd on youtube, he has a 1.9 tutorial on arrows and makes them explose, it's German but I don't speak German but still just copied the code and understood the minimum
-
I don't know why either, sorry
-
Don't call your arrow class EntityArrow, it makes things pretty confusing, and extends EntityArrow, not EntityTippedArrow
-
1. Make sure to import the right things 2. CheeseItems.CHEESE_ARROW is just my arrow item, you need to put your own there 3. Can you post the errors?
-
I have this: public class EntityCheeseArrow extends EntityArrow { private int duration = 200; public EntityCheeseArrow(World worldIn) { super(worldIn); } public EntityCheeseArrow(World worldIn, EntityLivingBase shooter) { super(worldIn, shooter); } public EntityCheeseArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } @Override public void onUpdate() { super.onUpdate(); if (this.worldObj.isRemote && !this.inGround) { this.worldObj.spawnParticle(EnumParticleTypes.END_ROD, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]); } else if (!this.worldObj.isRemote && this.inGround) { worldObj.createExplosion(shootingEntity, this.posX, this.posY, this.posZ, 1.0F, true); this.setDead(); } } @Override public ItemStack getArrowStack() { return new ItemStack(CheeseItems.CHEESE_ARROW); } @Override public void arrowHit(EntityLivingBase living) { super.arrowHit(living); World world = living.getEntityWorld(); if(living != shootingEntity) { world.createExplosion(shootingEntity, living.posX, living.posY, living.posZ, 1.0F, true); } } } That works for me...
-
Hello, I made a portal and dimension, the dimension works but that portal crashes when going through it, the code of the teleporter class: public class CheeseTeleporter extends Teleporter { private final WorldServer worldServerInstance; /** A private Random() function in Teleporter */ private final Random random; private final Long2ObjectMap<CheeseTeleporter.PortalPosition> destinationCoordinateCache = new Long2ObjectOpenHashMap( 4096); public CheeseTeleporter(WorldServer worldIn) { super(worldIn); this.worldServerInstance = worldIn; this.random = new Random(worldIn.getSeed()); } public void placeInPortal(Entity entityIn, float rotationYaw) { if (this.worldServerInstance.provider.getDimensionType().getId() != 1) { if (!this.placeInExistingPortal(entityIn, rotationYaw)) { this.makePortal(entityIn); this.placeInExistingPortal(entityIn, rotationYaw); } } else { int i = MathHelper.floor_double(entityIn.posX); int j = MathHelper.floor_double(entityIn.posY) - 1; int k = MathHelper.floor_double(entityIn.posZ); int l = 1; int i1 = 0; for (int j1 = -2; j1 <= 2; ++j1) { for (int k1 = -2; k1 <= 2; ++k1) { for (int l1 = -1; l1 < 3; ++l1) { int i2 = i + k1 * 1 + j1 * 0; int j2 = j + l1; int k2 = k + k1 * 0 - j1 * 1; boolean flag = l1 < 0; this.worldServerInstance.setBlockState(new BlockPos(i2, j2, k2), flag ? CheeseBlocks.CHEESE_BLOCK.getDefaultState() : Blocks.AIR.getDefaultState()); } } } entityIn.setLocationAndAngles((double) i, (double) j, (double) k, entityIn.rotationYaw, 0.0F); entityIn.motionX = 0.0D; entityIn.motionY = 0.0D; entityIn.motionZ = 0.0D; } } public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) { int i = 128; double d0 = -1.0D; int j = MathHelper.floor_double(entityIn.posX); int k = MathHelper.floor_double(entityIn.posZ); boolean flag = true; BlockPos blockpos = BlockPos.ORIGIN; long l = ChunkPos.asLong(j, k); if (this.destinationCoordinateCache.containsKey(l)) { CheeseTeleporter.PortalPosition teleporter$portalposition = (CheeseTeleporter.PortalPosition) this.destinationCoordinateCache .get(l); d0 = 0.0D; blockpos = teleporter$portalposition; teleporter$portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); flag = false; } else { BlockPos blockpos3 = new BlockPos(entityIn); for (int i1 = -128; i1 <= 128; ++i1) { BlockPos blockpos2; for (int j1 = -128; j1 <= 128; ++j1) { for (BlockPos blockpos1 = blockpos3.add(i1, this.worldServerInstance.getActualHeight() - 1 - blockpos3.getY(), j1); blockpos1 .getY() >= 0; blockpos1 = blockpos2) { blockpos2 = blockpos1.down(); if (this.worldServerInstance.getBlockState(blockpos1).getBlock() == CheeseBlocks.CHEESE_PORTAL) { for (blockpos2 = blockpos1.down(); this.worldServerInstance.getBlockState(blockpos2) .getBlock() == CheeseBlocks.CHEESE_PORTAL; blockpos2 = blockpos2.down()) { blockpos1 = blockpos2; } double d1 = blockpos1.distanceSq(blockpos3); if (d0 < 0.0D || d1 < d0) { d0 = d1; blockpos = blockpos1; } } } } } } if (d0 >= 0.0D) { if (flag) { this.destinationCoordinateCache.put(l, new CheeseTeleporter.PortalPosition(blockpos, this.worldServerInstance.getTotalWorldTime())); } double d5 = (double) blockpos.getX() + 0.5D; double d7 = (double) blockpos.getZ() + 0.5D; BlockPattern.PatternHelper blockpattern$patternhelper = CheeseBlocks.CHEESE_PORTAL .createPatternHelper(this.worldServerInstance, blockpos); boolean flag1 = blockpattern$patternhelper.getForwards().rotateY() .getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE; double d2 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? (double) blockpattern$patternhelper.getFrontTopLeft().getZ() : (double) blockpattern$patternhelper.getFrontTopLeft().getX(); double d6 = (double) (blockpattern$patternhelper.getFrontTopLeft().getY() + 1) - entityIn.getLastPortalVec().yCoord * (double) blockpattern$patternhelper.getHeight(); if (flag1) { ++d2; } if (blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X) { d7 = d2 + (1.0D - entityIn.getLastPortalVec().xCoord) * (double) blockpattern$patternhelper.getWidth() * (double) blockpattern$patternhelper.getForwards().rotateY().getAxisDirection().getOffset(); } else { d5 = d2 + (1.0D - entityIn.getLastPortalVec().xCoord) * (double) blockpattern$patternhelper.getWidth() * (double) blockpattern$patternhelper.getForwards().rotateY().getAxisDirection().getOffset(); } float f = 0.0F; float f1 = 0.0F; float f2 = 0.0F; float f3 = 0.0F; if (blockpattern$patternhelper.getForwards().getOpposite() == entityIn.getTeleportDirection()) { f = 1.0F; f1 = 1.0F; } else if (blockpattern$patternhelper.getForwards().getOpposite() == entityIn.getTeleportDirection() .getOpposite()) { f = -1.0F; f1 = -1.0F; } else if (blockpattern$patternhelper.getForwards().getOpposite() == entityIn.getTeleportDirection() .rotateY()) { f2 = 1.0F; f3 = -1.0F; } else { f2 = -1.0F; f3 = 1.0F; } double d3 = entityIn.motionX; double d4 = entityIn.motionZ; entityIn.motionX = d3 * (double) f + d4 * (double) f3; entityIn.motionZ = d3 * (double) f2 + d4 * (double) f1; entityIn.rotationYaw = rotationYaw - (float) (entityIn.getTeleportDirection().getOpposite().getHorizontalIndex() * 90) + (float) (blockpattern$patternhelper.getForwards().getHorizontalIndex() * 90); if (entityIn instanceof EntityPlayerMP) { ((EntityPlayerMP) entityIn).connection.setPlayerLocation(d5, d6, d7, entityIn.rotationYaw, entityIn.rotationPitch); } else { entityIn.setLocationAndAngles(d5, d6, d7, entityIn.rotationYaw, entityIn.rotationPitch); } return true; } else { return false; } } public boolean makePortal(Entity entityIn) { int i = 16; double d0 = -1.0D; int j = MathHelper.floor_double(entityIn.posX); int k = MathHelper.floor_double(entityIn.posY); int l = MathHelper.floor_double(entityIn.posZ); int i1 = j; int j1 = k; int k1 = l; int l1 = 0; int i2 = this.random.nextInt(4); BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int j2 = j - 16; j2 <= j + 16; ++j2) { double d1 = (double) j2 + 0.5D - entityIn.posX; for (int l2 = l - 16; l2 <= l + 16; ++l2) { double d2 = (double) l2 + 0.5D - entityIn.posZ; label146: for (int j3 = this.worldServerInstance.getActualHeight() - 1; j3 >= 0; --j3) { if (this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.setPos(j2, j3, l2))) { while (j3 > 0 && this.worldServerInstance .isAirBlock(blockpos$mutableblockpos.setPos(j2, j3 - 1, l2))) { --j3; } for (int k3 = i2; k3 < i2 + 4; ++k3) { int l3 = k3 % 2; int i4 = 1 - l3; if (k3 % 4 >= 2) { l3 = -l3; i4 = -i4; } for (int j4 = 0; j4 < 3; ++j4) { for (int k4 = 0; k4 < 4; ++k4) { for (int l4 = -1; l4 < 4; ++l4) { int i5 = j2 + (k4 - 1) * l3 + j4 * i4; int j5 = j3 + l4; int k5 = l2 + (k4 - 1) * i4 - j4 * l3; blockpos$mutableblockpos.setPos(i5, j5, k5); if (l4 < 0 && !this.worldServerInstance.getBlockState(blockpos$mutableblockpos) .getMaterial().isSolid() || l4 >= 0 && !this.worldServerInstance .isAirBlock(blockpos$mutableblockpos)) { continue label146; } } } } double d5 = (double) j3 + 0.5D - entityIn.posY; double d7 = d1 * d1 + d5 * d5 + d2 * d2; if (d0 < 0.0D || d7 < d0) { d0 = d7; i1 = j2; j1 = j3; k1 = l2; l1 = k3 % 4; } } } } } } if (d0 < 0.0D) { for (int l5 = j - 16; l5 <= j + 16; ++l5) { double d3 = (double) l5 + 0.5D - entityIn.posX; for (int j6 = l - 16; j6 <= l + 16; ++j6) { double d4 = (double) j6 + 0.5D - entityIn.posZ; label567: for (int i7 = this.worldServerInstance.getActualHeight() - 1; i7 >= 0; --i7) { if (this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.setPos(l5, i7, j6))) { while (i7 > 0 && this.worldServerInstance .isAirBlock(blockpos$mutableblockpos.setPos(l5, i7 - 1, j6))) { --i7; } for (int k7 = i2; k7 < i2 + 2; ++k7) { int j8 = k7 % 2; int j9 = 1 - j8; for (int j10 = 0; j10 < 4; ++j10) { for (int j11 = -1; j11 < 4; ++j11) { int j12 = l5 + (j10 - 1) * j8; int i13 = i7 + j11; int j13 = j6 + (j10 - 1) * j9; blockpos$mutableblockpos.setPos(j12, i13, j13); if (j11 < 0 && !this.worldServerInstance.getBlockState(blockpos$mutableblockpos) .getMaterial().isSolid() || j11 >= 0 && !this.worldServerInstance .isAirBlock(blockpos$mutableblockpos)) { continue label567; } } } double d6 = (double) i7 + 0.5D - entityIn.posY; double d8 = d3 * d3 + d6 * d6 + d4 * d4; if (d0 < 0.0D || d8 < d0) { d0 = d8; i1 = l5; j1 = i7; k1 = j6; l1 = k7 % 2; } } } } } } } int i6 = i1; int k2 = j1; int k6 = k1; int l6 = l1 % 2; int i3 = 1 - l6; if (l1 % 4 >= 2) { l6 = -l6; i3 = -i3; } if (d0 < 0.0D) { j1 = MathHelper.clamp_int(j1, 70, this.worldServerInstance.getActualHeight() - 10); k2 = j1; for (int j7 = -1; j7 <= 1; ++j7) { for (int l7 = 1; l7 < 3; ++l7) { for (int k8 = -1; k8 < 3; ++k8) { int k9 = i6 + (l7 - 1) * l6 + j7 * i3; int k10 = k2 + k8; int k11 = k6 + (l7 - 1) * i3 - j7 * l6; boolean flag = k8 < 0; this.worldServerInstance.setBlockState(new BlockPos(k9, k10, k11), flag ? CheeseBlocks.CHEESE_BLOCK.getDefaultState() : Blocks.AIR.getDefaultState()); } } } } IBlockState iblockstate = CheeseBlocks.CHEESE_PORTAL.getDefaultState().withProperty(BlockPortal.AXIS, l6 == 0 ? EnumFacing.Axis.Z : EnumFacing.Axis.X); for (int i8 = 0; i8 < 4; ++i8) { for (int l8 = 0; l8 < 4; ++l8) { for (int l9 = -1; l9 < 4; ++l9) { int l10 = i6 + (l8 - 1) * l6; int l11 = k2 + l9; int k12 = k6 + (l8 - 1) * i3; boolean flag1 = l8 == 0 || l8 == 3 || l9 == -1 || l9 == 3; this.worldServerInstance.setBlockState(new BlockPos(l10, l11, k12), flag1 ? CheeseBlocks.CHEESE_BLOCK.getDefaultState() : iblockstate, 2); } } for (int i9 = 0; i9 < 4; ++i9) { for (int i10 = -1; i10 < 4; ++i10) { int i11 = i6 + (i9 - 1) * l6; int i12 = k2 + i10; int l12 = k6 + (i9 - 1) * i3; BlockPos blockpos = new BlockPos(i11, i12, l12); this.worldServerInstance.notifyNeighborsOfStateChange(blockpos, this.worldServerInstance.getBlockState(blockpos).getBlock(), false); } } } return true; } /** * called periodically to remove out-of-date portal locations from the cache * list. Argument par1 is a WorldServer.getTotalWorldTime() value. */ public void removeStalePortalLocations(long worldTime) { if (worldTime % 100L == 0L) { long i = worldTime - 300L; ObjectIterator<CheeseTeleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values() .iterator(); while (objectiterator.hasNext()) { CheeseTeleporter.PortalPosition teleporter$portalposition = (CheeseTeleporter.PortalPosition) objectiterator .next(); if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i) { objectiterator.remove(); } } } } public class PortalPosition extends BlockPos { /** The worldtime at which this PortalPosition was last verified */ public long lastUpdateTime; public PortalPosition(BlockPos pos, long lastUpdate) { super(pos.getX(), pos.getY(), pos.getZ()); this.lastUpdateTime = lastUpdate; } } } The portal class public class CheesePortal extends BlockBreakable { public static final PropertyEnum<EnumFacing.Axis> AXIS = PropertyEnum.<EnumFacing.Axis>create("axis", EnumFacing.Axis.class, new EnumFacing.Axis[] { EnumFacing.Axis.X, EnumFacing.Axis.Z }); protected static final AxisAlignedBB X_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D); protected static final AxisAlignedBB Z_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D); protected static final AxisAlignedBB Y_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D); public CheesePortal() { super(Material.PORTAL, false); this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.X)); this.setTickRandomly(true); } public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { switch ((EnumFacing.Axis) state.getValue(AXIS)) { case X: return X_AABB; case Y: default: return Y_AABB; case Z: return Z_AABB; } } public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { super.updateTick(worldIn, pos, state, rand); if (worldIn.provider.isSurfaceWorld() && worldIn.getGameRules().getBoolean("doMobSpawning") && rand.nextInt(2000) < worldIn.getDifficulty().getDifficultyId()) { int i = pos.getY(); BlockPos blockpos; for (blockpos = pos; !worldIn.getBlockState(blockpos).isFullyOpaque() && blockpos.getY() > 0; blockpos = blockpos.down()) { ; } if (i > 0 && !worldIn.getBlockState(blockpos.up()).isNormalCube()) { Entity entity = ItemMonsterPlacer.spawnCreature(worldIn, EntityList.func_191306_a(EntityPigZombie.class), (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 1.1D, (double) blockpos.getZ() + 0.5D); if (entity != null) { entity.timeUntilPortal = entity.getPortalCooldown(); } } } } @Nullable public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return NULL_AABB; } public static int getMetaForAxis(EnumFacing.Axis axis) { return axis == EnumFacing.Axis.X ? 1 : (axis == EnumFacing.Axis.Z ? 2 : 0); } public boolean isFullCube(IBlockState state) { return false; } public boolean trySpawnPortal(World worldIn, BlockPos pos) { CheesePortal.Size blockportal$size = new CheesePortal.Size(worldIn, pos, EnumFacing.Axis.X); if (blockportal$size.isValid() && blockportal$size.portalBlockCount == 0) { blockportal$size.placePortalBlocks(); return true; } else { CheesePortal.Size blockportal$size1 = new CheesePortal.Size(worldIn, pos, EnumFacing.Axis.Z); if (blockportal$size1.isValid() && blockportal$size1.portalBlockCount == 0) { blockportal$size1.placePortalBlocks(); return true; } else { return false; } } } /** * Called when a neighboring block was changed and marks that this state * should perform any checks during a neighbor change. Cases may include * when redstone power is updated, cactus blocks popping off due to a * neighboring solid block, etc. */ public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) { EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis) state.getValue(AXIS); if (enumfacing$axis == EnumFacing.Axis.X) { CheesePortal.Size blockportal$size = new CheesePortal.Size(worldIn, pos, EnumFacing.Axis.X); if (!blockportal$size.isValid() || blockportal$size.portalBlockCount < blockportal$size.width * blockportal$size.height) { worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); } } else if (enumfacing$axis == EnumFacing.Axis.Z) { CheesePortal.Size blockportal$size1 = new CheesePortal.Size(worldIn, pos, EnumFacing.Axis.Z); if (!blockportal$size1.isValid() || blockportal$size1.portalBlockCount < blockportal$size1.width * blockportal$size1.height) { worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); } } } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { pos = pos.offset(side); EnumFacing.Axis enumfacing$axis = null; if (blockState.getBlock() == this) { enumfacing$axis = (EnumFacing.Axis) blockState.getValue(AXIS); if (enumfacing$axis == null) { return false; } if (enumfacing$axis == EnumFacing.Axis.Z && side != EnumFacing.EAST && side != EnumFacing.WEST) { return false; } if (enumfacing$axis == EnumFacing.Axis.X && side != EnumFacing.SOUTH && side != EnumFacing.NORTH) { return false; } } boolean flag = blockAccess.getBlockState(pos.west()).getBlock() == this && blockAccess.getBlockState(pos.west(2)).getBlock() != this; boolean flag1 = blockAccess.getBlockState(pos.east()).getBlock() == this && blockAccess.getBlockState(pos.east(2)).getBlock() != this; boolean flag2 = blockAccess.getBlockState(pos.north()).getBlock() == this && blockAccess.getBlockState(pos.north(2)).getBlock() != this; boolean flag3 = blockAccess.getBlockState(pos.south()).getBlock() == this && blockAccess.getBlockState(pos.south(2)).getBlock() != this; boolean flag4 = flag || flag1 || enumfacing$axis == EnumFacing.Axis.X; boolean flag5 = flag2 || flag3 || enumfacing$axis == EnumFacing.Axis.Z; return flag4 && side == EnumFacing.WEST ? true : (flag4 && side == EnumFacing.EAST ? true : (flag5 && side == EnumFacing.NORTH ? true : flag5 && side == EnumFacing.SOUTH)); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random random) { return 0; } /** * Called When an Entity Collided with the Block */ public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss()) { if (entityIn.timeUntilPortal > 0) { entityIn.timeUntilPortal = entityIn.getPortalCooldown(); } else { if (!worldIn.isRemote && !pos.equals(getField(Entity.class, entityIn, "lastPortalPos"))) { setField(Entity.class, entityIn, "lastPortalPos", pos); BlockPattern.PatternHelper blockpattern$patternhelper = CheeseBlocks.CHEESE_PORTAL.createPatternHelper(worldIn, pos); double d0 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? (double) blockpattern$patternhelper.getFrontTopLeft().getZ() : (double) blockpattern$patternhelper.getFrontTopLeft().getX(); double d1 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? entityIn.posZ : entityIn.posX; d1 = Math.abs(MathHelper.pct( d1 - (double) (blockpattern$patternhelper.getForwards().rotateY() .getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ? 1 : 0), d0, d0 - (double) blockpattern$patternhelper.getWidth())); double d2 = MathHelper.pct(entityIn.posY - 1.0D, (double) blockpattern$patternhelper.getFrontTopLeft().getY(), (double) (blockpattern$patternhelper.getFrontTopLeft().getY() - blockpattern$patternhelper.getHeight())); setField(Entity.class, entityIn, "lastPortalVex", new Vec3d(d1, d2, 0.0D)); setField(Entity.class, entityIn, "teleportDirection", blockpattern$patternhelper.getForwards()); } setField(Entity.class, entityIn, "inPortal", true); } if (entityIn instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) entityIn; if (player.timeUntilPortal > 0) { player.timeUntilPortal = 10; } else if (player.dimension == 0) { player.timeUntilPortal = 10; MinecraftServer server = player.mcServer; server.getPlayerList().transferPlayerToDimension(player, CheeseDimension.DIMENSION_ID, new CheeseTeleporter(server.worldServerForDimension(CheeseDimension.DIMENSION_ID))); } else if (player.dimension == CheeseDimension.DIMENSION_ID) { player.timeUntilPortal = 10; MinecraftServer server = player.mcServer; server.getPlayerList().transferPlayerToDimension(player, 0, new CheeseTeleporter(server.worldServerForDimension(0))); } } } } public Object getField(Class clazz, Object obj, String fieldstr) { try { Field field = clazz.getDeclaredField(fieldstr); field.setAccessible(true); return field.get(obj); } catch(Exception ex) { return null; } } public void setField(Class clazz, Object obj, String fieldstr, Object value) { try { Field field = clazz.getDeclaredField(fieldstr); field.setAccessible(true); field.set(obj, value); } catch(Exception ex) { } } public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return ItemStack.field_190927_a; } /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(AXIS, (meta & 3) == 2 ? EnumFacing.Axis.Z : EnumFacing.Axis.X); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (rand.nextInt(100) == 0) { worldIn.playSound((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, rand.nextFloat() * 0.4F + 0.8F, false); } for (int i = 0; i < 4; ++i) { double d0 = (double) ((float) pos.getX() + rand.nextFloat()); double d1 = (double) ((float) pos.getY() + rand.nextFloat()); double d2 = (double) ((float) pos.getZ() + rand.nextFloat()); double d3 = ((double) rand.nextFloat() - 0.5D) * 0.5D; double d4 = ((double) rand.nextFloat() - 0.5D) * 0.5D; double d5 = ((double) rand.nextFloat() - 0.5D) * 0.5D; int j = rand.nextInt(2) * 2 - 1; if (worldIn.getBlockState(pos.west()).getBlock() != this && worldIn.getBlockState(pos.east()).getBlock() != this) { d0 = (double) pos.getX() + 0.5D + 0.25D * (double) j; d3 = (double) (rand.nextFloat() * 2.0F * (float) j); } else { d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) j; d5 = (double) (rand.nextFloat() * 2.0F * (float) j); } worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]); } } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return getMetaForAxis((EnumFacing.Axis) state.getValue(AXIS)); } /** * Returns the blockstate with the given rotation from the passed * blockstate. If inapplicable, returns the passed blockstate. */ public IBlockState withRotation(IBlockState state, Rotation rot) { switch (rot) { case COUNTERCLOCKWISE_90: case CLOCKWISE_90: switch ((EnumFacing.Axis) state.getValue(AXIS)) { case X: return state.withProperty(AXIS, EnumFacing.Axis.Z); case Z: return state.withProperty(AXIS, EnumFacing.Axis.X); default: return state; } default: return state; } } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { AXIS }); } public static BlockPattern.PatternHelper createPatternHelper(World worldIn, BlockPos p_181089_2_) { EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Z; CheesePortal.Size blockportal$size = new CheesePortal.Size(worldIn, p_181089_2_, EnumFacing.Axis.X); LoadingCache<BlockPos, BlockWorldState> loadingcache = BlockPattern.createLoadingCache(worldIn, true); if (!blockportal$size.isValid()) { enumfacing$axis = EnumFacing.Axis.X; blockportal$size = new CheesePortal.Size(worldIn, p_181089_2_, EnumFacing.Axis.Z); } if (!blockportal$size.isValid()) { return new BlockPattern.PatternHelper(p_181089_2_, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1); } else { int[] aint = new int[EnumFacing.AxisDirection.values().length]; EnumFacing enumfacing = blockportal$size.rightDir.rotateYCCW(); BlockPos blockpos = blockportal$size.bottomLeft.up(blockportal$size.getHeight() - 1); for (EnumFacing.AxisDirection enumfacing$axisdirection : EnumFacing.AxisDirection.values()) { BlockPattern.PatternHelper blockpattern$patternhelper = new BlockPattern.PatternHelper( enumfacing.getAxisDirection() == enumfacing$axisdirection ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1); for (int i = 0; i < blockportal$size.getWidth(); ++i) { for (int j = 0; j < blockportal$size.getHeight(); ++j) { BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1); if (blockworldstate.getBlockState() != null && blockworldstate.getBlockState().getMaterial() != Material.AIR) { ++aint[enumfacing$axisdirection.ordinal()]; } } } } EnumFacing.AxisDirection enumfacing$axisdirection1 = EnumFacing.AxisDirection.POSITIVE; for (EnumFacing.AxisDirection enumfacing$axisdirection2 : EnumFacing.AxisDirection.values()) { if (aint[enumfacing$axisdirection2.ordinal()] < aint[enumfacing$axisdirection1.ordinal()]) { enumfacing$axisdirection1 = enumfacing$axisdirection2; } } return new BlockPattern.PatternHelper( enumfacing.getAxisDirection() == enumfacing$axisdirection1 ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1); } } public static class Size { private final World world; private final EnumFacing.Axis axis; private final EnumFacing rightDir; private final EnumFacing leftDir; private int portalBlockCount; private BlockPos bottomLeft; private int height; private int width; public Size(World worldIn, BlockPos p_i45694_2_, EnumFacing.Axis p_i45694_3_) { this.world = worldIn; this.axis = p_i45694_3_; if (p_i45694_3_ == EnumFacing.Axis.X) { this.leftDir = EnumFacing.EAST; this.rightDir = EnumFacing.WEST; } else { this.leftDir = EnumFacing.NORTH; this.rightDir = EnumFacing.SOUTH; } for (BlockPos blockpos = p_i45694_2_; p_i45694_2_.getY() > blockpos.getY() - 21 && p_i45694_2_.getY() > 0 && this.isEmptyBlock( worldIn.getBlockState(p_i45694_2_.down()).getBlock()); p_i45694_2_ = p_i45694_2_.down()) { ; } int i = this.getDistanceUntilEdge(p_i45694_2_, this.leftDir) - 1; if (i >= 0) { this.bottomLeft = p_i45694_2_.offset(this.leftDir, i); this.width = this.getDistanceUntilEdge(this.bottomLeft, this.rightDir); if (this.width < 2 || this.width > 21) { this.bottomLeft = null; this.width = 0; } } if (this.bottomLeft != null) { this.height = this.calculatePortalHeight(); } } protected int getDistanceUntilEdge(BlockPos p_180120_1_, EnumFacing p_180120_2_) { int i; for (i = 0; i < 22; ++i) { BlockPos blockpos = p_180120_1_.offset(p_180120_2_, i); if (!this.isEmptyBlock(this.world.getBlockState(blockpos).getBlock()) || this.world.getBlockState(blockpos.down()).getBlock() != CheeseBlocks.CHEESE_BLOCK) { break; } } Block block = this.world.getBlockState(p_180120_1_.offset(p_180120_2_, i)).getBlock(); return block == CheeseBlocks.CHEESE_BLOCK ? i : 0; } public int getHeight() { return this.height; } public int getWidth() { return this.width; } protected int calculatePortalHeight() { label24: for (this.height = 0; this.height < 21; ++this.height) { for (int i = 0; i < this.width; ++i) { BlockPos blockpos = this.bottomLeft.offset(this.rightDir, i).up(this.height); Block block = this.world.getBlockState(blockpos).getBlock(); if (!this.isEmptyBlock(block)) { break label24; } if (block == CheeseBlocks.CHEESE_PORTAL) { ++this.portalBlockCount; } if (i == 0) { block = this.world.getBlockState(blockpos.offset(this.leftDir)).getBlock(); if (block != CheeseBlocks.CHEESE_BLOCK) { break label24; } } else if (i == this.width - 1) { block = this.world.getBlockState(blockpos.offset(this.rightDir)).getBlock(); if (block != CheeseBlocks.CHEESE_BLOCK) { break label24; } } } } for (int j = 0; j < this.width; ++j) { if (this.world.getBlockState(this.bottomLeft.offset(this.rightDir, j).up(this.height)) .getBlock() != CheeseBlocks.CHEESE_BLOCK) { this.height = 0; break; } } if (this.height <= 21 && this.height >= 3) { return this.height; } else { this.bottomLeft = null; this.width = 0; this.height = 0; return 0; } } protected boolean isEmptyBlock(Block blockIn) { return blockIn.getMaterial(blockIn.getDefaultState()) == Material.AIR || blockIn == CheeseBlocks.CHEESE_FIRE || blockIn == CheeseBlocks.CHEESE_PORTAL; } public boolean isValid() { return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } public void placePortalBlocks() { for (int i = 0; i < this.width; ++i) { BlockPos blockpos = this.bottomLeft.offset(this.rightDir, i); for (int j = 0; j < this.height; ++j) { this.world.setBlockState(blockpos.up(j), CheeseBlocks.CHEESE_PORTAL.getDefaultState().withProperty(CheesePortal.AXIS, this.axis), 2); } } } } } The crash [16:00:16] [server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: net.minecraft.util.ReportedException: Colliding entity with block at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_77] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:27) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_77] Caused by: net.minecraft.util.ReportedException: Colliding entity with block at net.minecraft.entity.Entity.moveEntity(Entity.java:999) ~[Entity.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:501) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayer.processPacket(CPacketPlayer.java:36) ~[CPacketPlayer.class:?] at net.minecraft.network.play.client.CPacketPlayer$PositionRotation.processPacket(CPacketPlayer.java:125) ~[CPacketPlayer$PositionRotation.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_77] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:26) ~[util.class:?] ... 5 more Caused by: java.lang.NullPointerException at com.Kokkie.cheesemod.world.dimension.CheeseTeleporter.placeInExistingPortal(CheeseTeleporter.java:131) ~[CheeseTeleporter.class:?] at com.Kokkie.cheesemod.world.dimension.CheeseTeleporter.placeInPortal(CheeseTeleporter.java:38) ~[CheeseTeleporter.class:?] at net.minecraft.server.management.PlayerList.transferEntityToWorld(PlayerList.java:732) ~[PlayerList.class:?] at net.minecraft.server.management.PlayerList.transferPlayerToDimension(PlayerList.java:639) ~[PlayerList.class:?] at com.Kokkie.cheesemod.blocks.CheesePortal.onEntityCollidedWithBlock(CheesePortal.java:239) ~[CheesePortal.class:?] at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:1074) ~[Entity.class:?] at net.minecraft.entity.Entity.moveEntity(Entity.java:992) ~[Entity.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:501) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayer.processPacket(CPacketPlayer.java:36) ~[CPacketPlayer.class:?] at net.minecraft.network.play.client.CPacketPlayer$PositionRotation.processPacket(CPacketPlayer.java:125) ~[CPacketPlayer$PositionRotation.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_77] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:26) ~[util.class:?] ... 5 more
-
It think it needs to be: pls.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 1000000, 128, true, true));
-
Ehm, anyone?
-
You need to set ITEM1.hoverStart to 0
-
@SubscribeEvent public void playerInteract(PlayerInteractEvent.LeftClickBlock event) { BlockPos pos = event.getPos(); World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); pos = pos.offset(event.getFace()); if (world.getBlockState(pos).getBlock() == CheeseBlocks.CHEESE_FIRE) { event.setCanceled(true); player.playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, 1.0F); world.setBlockToAir(pos); } } Doesn't work
-
It just breaks the block under it and I don't hear the fire extinguished sound
-
I have this but it still doesn't work D: : @SubscribeEvent public void playerInteract(PlayerInteractEvent.LeftClickBlock event) { BlockPos pos = event.getPos(); World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); pos = pos.offset(event.getFace()); if (world.getBlockState(pos).getBlock() == CheeseBlocks.CHEESE_FIRE) { world.playEvent(player, 1009, pos, 0); world.setBlockToAir(pos); } }
-
So now I have this: @SubscribeEvent public void playerInteract(PlayerInteractEvent event) { BlockPos pos = event.getPos(); World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); pos = pos.offset(event.getFace()); if (world.getBlockState(pos).getBlock() == CheeseBlocks.CHEESE_FIRE) { world.playEvent(player, 1009, pos, 0); world.setBlockToAir(pos); } } in my common event handler but it doesn't work..?
-
But that's impossible because there is 'no bounding box to click'
-
So I made custom fire but when I hit it to put it out the block under it breaks and then because of that the fire goes out, here's my code: public class CheeseFire extends Block { public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15); public static final PropertyBool NORTH = PropertyBool.create("north"); public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool WEST = PropertyBool.create("west"); public static final PropertyBool UPPER = PropertyBool.create("up"); private final Map<Block, Integer> encouragements = Maps.<Block, Integer>newIdentityHashMap(); private final Map<Block, Integer> flammabilities = Maps.<Block, Integer>newIdentityHashMap(); /** * Get the actual Block state of this Block at the given position. This * applies properties not visible in the metadata, such as fence * connections. */ public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !CheeseBlocks.CHEESE_FIRE.canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { return state.withProperty(NORTH, this.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) .withProperty(EAST, this.canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) .withProperty(SOUTH, this.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) .withProperty(WEST, this.canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) .withProperty(UPPER, this.canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)); } return this.getDefaultState(); } public CheeseFire() { super(Material.FIRE); this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)) .withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)) .withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)) .withProperty(UPPER, Boolean.valueOf(false))); this.setTickRandomly(true); } public static void init() { CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.PLANKS, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.DOUBLE_WOODEN_SLAB, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.WOODEN_SLAB, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.OAK_FENCE_GATE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.SPRUCE_FENCE_GATE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.BIRCH_FENCE_GATE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.JUNGLE_FENCE_GATE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.DARK_OAK_FENCE_GATE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.ACACIA_FENCE_GATE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.OAK_FENCE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.SPRUCE_FENCE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.BIRCH_FENCE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.JUNGLE_FENCE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.DARK_OAK_FENCE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.ACACIA_FENCE, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.OAK_STAIRS, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.BIRCH_STAIRS, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.SPRUCE_STAIRS, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.JUNGLE_STAIRS, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.ACACIA_STAIRS, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.DARK_OAK_STAIRS, 5, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.LOG, 5, 5); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.LOG2, 5, 5); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.LEAVES, 30, 60); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.LEAVES2, 30, 60); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.BOOKSHELF, 30, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.TNT, 15, 100); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.TALLGRASS, 60, 100); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.DOUBLE_PLANT, 60, 100); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.YELLOW_FLOWER, 60, 100); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.RED_FLOWER, 60, 100); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.DEADBUSH, 60, 100); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.WOOL, 30, 60); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.VINE, 15, 100); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.COAL_BLOCK, 5, 5); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.HAY_BLOCK, 60, 20); CheeseBlocks.CHEESE_FIRE.setFireInfo(Blocks.CARPET, 60, 20); } public void setFireInfo(Block blockIn, int encouragement, int flammability) { if (blockIn == Blocks.AIR) throw new IllegalArgumentException("Tried to set air on fire... This is bad."); this.encouragements.put(blockIn, Integer.valueOf(encouragement)); this.flammabilities.put(blockIn, Integer.valueOf(flammability)); } @Nullable public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return NULL_AABB; } /** * Used to determine ambient occlusion and culling when rebuilding chunks * for render */ public boolean isOpaqueCube(IBlockState state) { return false; } public boolean isFullCube(IBlockState state) { return false; } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random random) { return 0; } /** * How many world ticks before ticking */ public int tickRate(World worldIn) { return 30; } public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (worldIn.getGameRules().getBoolean("doFireTick")) { if (!this.canPlaceBlockAt(worldIn, pos)) { worldIn.setBlockToAir(pos); } Block block = worldIn.getBlockState(pos.down()).getBlock(); boolean flag = block.isFireSource(worldIn, pos.down(), EnumFacing.UP); int i = ((Integer) state.getValue(AGE)).intValue(); if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos) && rand.nextFloat() < 0.2F + (float) i * 0.03F) { worldIn.setBlockToAir(pos); } else { if (i < 15) { state = state.withProperty(AGE, Integer.valueOf(i + rand.nextInt(3) / 2)); worldIn.setBlockState(pos, state, 4); } worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + rand.nextInt(10)); if (!flag) { if (!this.canNeighborCatchFire(worldIn, pos)) { if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP)) { worldIn.setBlockToAir(pos); } return; } if (!this.canCatchFire(worldIn, pos.down(), EnumFacing.UP) && rand.nextInt(50) == 0) { worldIn.setBlockToAir(pos); return; } } boolean flag1 = worldIn.isBlockinHighHumidity(pos); int j = 0; if (flag1) { j = -50; } this.tryCatchFire(worldIn, pos.east(), 51 + j, rand, i, EnumFacing.WEST); this.tryCatchFire(worldIn, pos.west(), 51 + j, rand, i, EnumFacing.EAST); this.tryCatchFire(worldIn, pos.down(), 51 + j, rand, i, EnumFacing.UP); this.tryCatchFire(worldIn, pos.up(), 51 + j, rand, i, EnumFacing.DOWN); this.tryCatchFire(worldIn, pos.north(), 51 + j, rand, i, EnumFacing.SOUTH); this.tryCatchFire(worldIn, pos.south(), 51 + j, rand, i, EnumFacing.NORTH); for (int k = -1; k <= 1; ++k) { for (int l = -1; l <= 1; ++l) { for (int i1 = -1; i1 <= 4; ++i1) { if (k != 0 || i1 != 0 || l != 0) { int j1 = 100; if (i1 > 1) { j1 += (i1 - 1) * 100; } BlockPos blockpos = pos.add(k, i1, l); int k1 = this.getNeighborEncouragement(worldIn, blockpos); if (k1 > 0) { int l1 = (k1 + 40 + worldIn.getDifficulty().getDifficultyId() * 7) / (i + 30); if (flag1) { l1 /= 2; } if (l1 > 0 && rand.nextInt(j1) <= l1 && !this.canDie(worldIn, blockpos)) { int i2 = i + rand.nextInt(5) / 4; if (i2 > 15) { i2 = 15; } worldIn.setBlockState(blockpos, state.withProperty(AGE, Integer.valueOf(i2)), 3); } } } } } } } } } protected boolean canDie(World worldIn, BlockPos pos) { return false; } public boolean requiresUpdates() { return false; } @Deprecated // Use Block.getFlammability public int getFlammability(Block blockIn) { Integer integer = (Integer) this.flammabilities.get(blockIn); return integer == null ? 0 : integer.intValue(); } @Deprecated // Use Block.getFlammability public int getEncouragement(Block blockIn) { Integer integer = (Integer) this.encouragements.get(blockIn); return integer == null ? 0 : integer.intValue(); } @Deprecated // Use tryCatchFire with face below private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age) { this.tryCatchFire(worldIn, pos, chance, random, age, EnumFacing.UP); } private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) { int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face); if (random.nextInt(chance) < i) { IBlockState iblockstate = worldIn.getBlockState(pos); if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) { int j = age + random.nextInt(5) / 4; if (j > 15) { j = 15; } worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3); } else { worldIn.setBlockToAir(pos); } if (iblockstate.getBlock() == Blocks.TNT) { Blocks.TNT.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true))); } } } private boolean canNeighborCatchFire(World worldIn, BlockPos pos) { for (EnumFacing enumfacing : EnumFacing.values()) { if (this.canCatchFire(worldIn, pos.offset(enumfacing), enumfacing.getOpposite())) { return true; } } return false; } private int getNeighborEncouragement(World worldIn, BlockPos pos) { if (!worldIn.isAirBlock(pos)) { return 0; } else { int i = 0; for (EnumFacing enumfacing : EnumFacing.values()) { i = Math.max(worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getFireSpreadSpeed(worldIn, pos.offset(enumfacing), enumfacing.getOpposite()), i); } return i; } } /** * Returns if this block is collidable. Only used by fire, although stairs * return that of the block that the stair is made of (though nobody's going * to make fire stairs, right?) */ public boolean isCollidable() { return false; } /** * Checks if the block can be caught on fire */ @Deprecated // Use canCatchFire with face sensitive version below public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos) { return canCatchFire(worldIn, pos, EnumFacing.UP); } public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { return worldIn.getBlockState(pos.down()).isFullyOpaque() || this.canNeighborCatchFire(worldIn, pos); } /** * Called when a neighboring block was changed and marks that this state * should perform any checks during a neighbor change. Cases may include * when redstone power is updated, cactus blocks popping off due to a * neighboring solid block, etc. */ public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) { if (!worldIn.getBlockState(pos.down()).isFullyOpaque() && !this.canNeighborCatchFire(worldIn, pos)) { worldIn.setBlockToAir(pos); } } /** * Called after the block is set in the Chunk data, but before the Tile * Entity is set */ public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (worldIn.provider.getDimensionType().getId() > 0 || !CheeseBlocks.CHEESE_PORTAL.trySpawnPortal(worldIn, pos)) { if (!worldIn.getBlockState(pos.down()).isFullyOpaque() && !this.canNeighborCatchFire(worldIn, pos)) { worldIn.setBlockToAir(pos); } else { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + worldIn.rand.nextInt(10)); } } } @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (rand.nextInt(24) == 0) { worldIn.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), (double) ((float) pos.getZ() + 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false); } if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !CheeseBlocks.CHEESE_FIRE.canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { if (CheeseBlocks.CHEESE_FIRE.canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) { for (int j = 0; j < 2; ++j) { double d3 = (double) pos.getX() + rand.nextDouble() * 0.10000000149011612D; double d8 = (double) pos.getY() + rand.nextDouble(); double d13 = (double) pos.getZ() + rand.nextDouble(); worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, new int[0]); } } if (CheeseBlocks.CHEESE_FIRE.canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) { for (int k = 0; k < 2; ++k) { double d4 = (double) (pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D; double d9 = (double) pos.getY() + rand.nextDouble(); double d14 = (double) pos.getZ() + rand.nextDouble(); worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, new int[0]); } } if (CheeseBlocks.CHEESE_FIRE.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) { for (int l = 0; l < 2; ++l) { double d5 = (double) pos.getX() + rand.nextDouble(); double d10 = (double) pos.getY() + rand.nextDouble(); double d15 = (double) pos.getZ() + rand.nextDouble() * 0.10000000149011612D; worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, new int[0]); } } if (CheeseBlocks.CHEESE_FIRE.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) { for (int i1 = 0; i1 < 2; ++i1) { double d6 = (double) pos.getX() + rand.nextDouble(); double d11 = (double) pos.getY() + rand.nextDouble(); double d16 = (double) (pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D; worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, new int[0]); } } if ((CheeseBlocks.CHEESE_FIRE).canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)) { for (int j1 = 0; j1 < 2; ++j1) { double d7 = (double) pos.getX() + rand.nextDouble(); double d12 = (double) (pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D; double d17 = (double) pos.getZ() + rand.nextDouble(); worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, new int[0]); } } } else { for (int i = 0; i < 3; ++i) { double d0 = (double) pos.getX() + rand.nextDouble(); double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D; double d2 = (double) pos.getZ() + rand.nextDouble(); worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); } } } /** * Get the MapColor for this Block and the given BlockState */ public MapColor getMapColor(IBlockState state) { return MapColor.TNT; } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta)); } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return ((Integer) state.getValue(AGE)).intValue(); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { AGE, NORTH, EAST, SOUTH, WEST, UPPER }); } /* * ================================= Forge Start ====================================== */ /** * Side sensitive version that calls the block function. * * @param world * The current world * @param pos * Block position * @param face * The side the fire is coming from * @return True if the face can catch fire. */ public boolean canCatchFire(IBlockAccess world, BlockPos pos, EnumFacing face) { return world.getBlockState(pos).getBlock().isFlammable(world, pos, face); } /* * ================================= Forge End ====================================== */ } Help is much appreciated And yes, I intentionally removed some of the age things because it is really strong fire (texture is blue and cheese is obviously a really good lighting material)
-
Thanks Draco, I copied some of your code mixed with vanilla code and it works thanks!
-
Hello, I want to make a dimension for my mod but I have no idea where to start, I have a portal block and all but how do I make the dimension and terrain generation and all? Please help, if you know any tutorials that still work (would like video but text'll do) please post a link to them
-
Introducing Mercurius! Stats and Analytics for Forge
Kokkie replied to a topic in Site News (non-forge)
But with the session id you can login to any account? -
Don't bump so much, diesieben doesn't like it and will get you banned