fixed broken packet, new tom crater

This commit is contained in:
Bob 2022-11-11 21:15:35 +01:00
parent 3a784919fa
commit adf88b70e3
13 changed files with 152 additions and 110 deletions

View File

@ -133,6 +133,8 @@ public class WasteEarth extends Block {
for(int j = -1; j < 2; j++) { for(int j = -1; j < 2; j++) {
for(int k = -1; k < 2; k++) { for(int k = -1; k < 2; k++) {
if(!world.blockExists(x + i, y + j, z + k)) continue;
Block b0 = world.getBlock(x + i, y + j, z + k); Block b0 = world.getBlock(x + i, y + j, z + k);
Block b1 = world.getBlock(x + i, y + j + 1, z + k); Block b1 = world.getBlock(x + i, y + j + 1, z + k);

View File

@ -149,17 +149,8 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
clearChunkLoader(); clearChunkLoader();
loadedChunks.clear(); loadedChunks.clear();
loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ));
int minX = Math.min(newChunkX, newChunkX + (int) Math.ceil((this.posX + this.motionX) / 16D)); loadedChunks.add(new ChunkCoordIntPair(newChunkX + (int) Math.ceil((this.posX + this.motionX) / 16D), newChunkZ + (int) Math.ceil((this.posZ + this.motionZ) / 16D)));
int maxX = Math.max(newChunkX, newChunkX + (int) Math.ceil((this.posX + this.motionX) / 16D));
int minZ = Math.min(newChunkZ, newChunkZ + (int) Math.ceil((this.posZ + this.motionZ) / 16D));
int maxZ = Math.max(newChunkZ, newChunkZ + (int) Math.ceil((this.posZ + this.motionZ) / 16D));
for(int x = minX; x <= maxX; x++) {
for(int z = minZ; z <= maxZ; z++) {
loadedChunks.add(new ChunkCoordIntPair(x, z));
}
}
for(ChunkCoordIntPair chunk : loadedChunks) { for(ChunkCoordIntPair chunk : loadedChunks) {
ForgeChunkManager.forceChunk(loaderTicket, chunk); ForgeChunkManager.forceChunk(loaderTicket, chunk);

View File

@ -19,7 +19,6 @@ public class EntityTom extends EntityThrowable {
@Override @Override
public void onUpdate() { public void onUpdate() {
this.lastTickPosX = this.prevPosX = posX; this.lastTickPosX = this.prevPosX = posX;
this.lastTickPosY = this.prevPosY = posY; this.lastTickPosY = this.prevPosY = posY;
this.lastTickPosZ = this.prevPosZ = posZ; this.lastTickPosZ = this.prevPosZ = posZ;
@ -31,45 +30,41 @@ public class EntityTom extends EntityThrowable {
motionY = -0.5; motionY = -0.5;
if(this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.air) if(this.worldObj.getBlock((int) this.posX, (int) this.posY, (int) this.posZ) != Blocks.air) {
{ if(!this.worldObj.isRemote) {
if(!this.worldObj.isRemote) { EntityTomBlast tom = new EntityTomBlast(worldObj);
EntityTomBlast tom = new EntityTomBlast(worldObj); tom.posX = posX;
tom.posX = posX; tom.posY = posY;
tom.posY = posY; tom.posZ = posZ;
tom.posZ = posZ; tom.destructionRange = 600;
tom.destructionRange = 500; worldObj.spawnEntityInWorld(tom);
worldObj.spawnEntityInWorld(tom);
EntityCloudTom cloud = new EntityCloudTom(worldObj, 500); EntityCloudTom cloud = new EntityCloudTom(worldObj, 500);
cloud.setLocationAndAngles(posX, posY, posZ, 0, 0); cloud.setLocationAndAngles(posX, posY, posZ, 0, 0);
worldObj.spawnEntityInWorld(cloud); worldObj.spawnEntityInWorld(cloud);
} }
this.setDead(); this.setDead();
} }
} }
@Override @Override
protected void onImpact(MovingObjectPosition p_70184_1_) { protected void onImpact(MovingObjectPosition p_70184_1_) {
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance) public boolean isInRangeToRenderDist(double distance) {
{ return distance < 500000;
return distance < 500000; }
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getBrightnessForRender(float p_70070_1_) public int getBrightnessForRender(float p_70070_1_) {
{ return 15728880;
return 15728880; }
}
@Override @Override
public float getBrightness(float p_70013_1_) public float getBrightness(float p_70013_1_) {
{ return 1.0F;
return 1.0F; }
}
} }

View File

@ -2,12 +2,13 @@ package com.hbm.explosion;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ExplosionTom public class ExplosionTom {
{
public int posX; public int posX;
public int posY; public int posY;
public int posZ; public int posZ;
@ -52,8 +53,7 @@ public class ExplosionTom
element = nbt.getInteger(name + "element"); element = nbt.getInteger(name + "element");
} }
public ExplosionTom(int x, int y, int z, World world, int rad) public ExplosionTom(int x, int y, int z, World world, int rad) {
{
this.posX = x; this.posX = x;
this.posY = y; this.posY = y;
this.posZ = z; this.posZ = z;
@ -66,8 +66,7 @@ public class ExplosionTom
this.nlimit = this.radius2 * 4; this.nlimit = this.radius2 * 4;
} }
public boolean update() public boolean update() {
{
breakColumn(this.lastposX, this.lastposZ); breakColumn(this.lastposX, this.lastposZ);
this.shell = (int) Math.floor((Math.sqrt(n) + 1) / 2); this.shell = (int) Math.floor((Math.sqrt(n) + 1) / 2);
int shell2 = this.shell * 2; int shell2 = this.shell * 2;
@ -79,35 +78,37 @@ public class ExplosionTom
return this.n > this.nlimit; return this.n > this.nlimit;
} }
private void breakColumn(int x, int z) private void breakColumn(int x, int z) {
{
int dist = this.radius2 - (x * x + z * z); int dist = this.radius2 - (x * x + z * z);
if (dist > 0) if(dist > 0) {
{
int pX = posX + x; int pX = posX + x;
int pZ = posZ + z; int pZ = posZ + z;
double X = Math.pow((this.posX - pX), 2);
double Z = Math.pow((this.posZ - pZ), 2);
double distance = MathHelper.sqrt_double(X + Z); // Distance calculations used for crater rim stuff
int y = 256; int y = 256;
int terrain = 63;
double cA = (terrain - Math.pow(Math.E, -Math.pow(Math.sqrt(x * x + z * z), 2) / 40000) * 13) + worldObj.rand.nextInt(2); // Basic crater bowl shape
double cB = cA + Math.pow(Math.E, -Math.pow(Math.sqrt(x * x + z * z) - 200, 2) / 400) * 13 ;// Crater peak ring
int craterFloor = (int) (cB + Math.pow(Math.E, -Math.pow(Math.sqrt(x * x + z * z) - 500, 2) / 2000) * 37); // Crater rim
for(int i = 256; i > 0; i--) { for(int i = 256; i > 0; i--) {
if(worldObj.getBlock(pX, i, pZ) != Blocks.air) { if(i == craterFloor || worldObj.getBlock(pX, i, pZ) != Blocks.air) {
y = i; y = i;
break; break;
} }
} }
int height = terrain - 14;
int height = 70; int offset = 20;
int offset = 10; int threshold = (int) ((float) Math.sqrt(x * x + z * z) * (float) (height + offset) / (float) this.radius) + worldObj.rand.nextInt(2) - offset;
//int threshold = height - (int) ((float)dist * (float)height / (float)this.radius2) - 1 + worldObj.rand.nextInt(2);
int threshold = (int) ((float)Math.sqrt(x * x + z * z) * (float)(height + offset) / (float)this.radius) + worldObj.rand.nextInt(2) - offset;
while(y > threshold) { while(y > threshold) {
if(y == 0) if(y == 0)
break; break;
if(y <= craterFloor) {
if(y <= threshold + 2 && worldObj.getBlock(pX, y, pZ) != Blocks.air) {
if(worldObj.rand.nextInt(499) < 1) { if(worldObj.rand.nextInt(499) < 1) {
worldObj.setBlock(pX, y, pZ, ModBlocks.ore_tektite_osmiridium); worldObj.setBlock(pX, y, pZ, ModBlocks.ore_tektite_osmiridium);
@ -116,14 +117,36 @@ public class ExplosionTom
} }
} else { } else {
if(y > 16) { if(y > terrain + 1) {
worldObj.setBlockToAir(pX, y, pZ); if(distance < 500) // used so that old terrain inside crater rim is destroyed, while rim material "floods" terrain outside.
{
for(int i = -2; i < 3; i++) {
for(int j = -2; j < 3; j++) {
for(int k = -2; k < 3; k++) {
if(worldObj.getBlock(pX + i, y + j, pZ + k).getMaterial() == Material.water || worldObj.getBlock(pX + i, y + j, pZ + k).getMaterial() == Material.ice || worldObj.getBlock(pX + i, y + j, pZ + k).getMaterial() == Material.snow || worldObj.getBlock(pX + i, y + j, pZ + k).getMaterial().getCanBurn()) {
worldObj.setBlockToAir(pX + i, y + j, pZ + k);
worldObj.setBlockToAir(pX, y, pZ);
}
}
}
}
worldObj.setBlockToAir(pX, y, pZ);
}
} else { } else {
for(int i = -2; i < 3; i++) {
for(int j = -2; j < 3; j++) {
for(int k = -2; k < 3; k++) {
if(worldObj.getBlock(pX + i, y + j, pZ + k).getMaterial() == Material.water || worldObj.getBlock(pX + i, y + j, pZ + k).getMaterial() == Material.ice || worldObj.getBlock(pX + i, y, pZ + k) == Blocks.air) {
worldObj.setBlock(pX + i, y, pZ + k, Blocks.lava, 0, 2);
worldObj.setBlock(pX, y, pZ, Blocks.lava, 0, 2);
}
}
}
}
worldObj.setBlock(pX, y, pZ, Blocks.lava, 0, 2); worldObj.setBlock(pX, y, pZ, Blocks.lava, 0, 2);
} }
} }
y--; y--;
} }
} }

View File

@ -27,7 +27,7 @@ public class ImpactWorldHandler {
if(!(world instanceof WorldServer)) if(!(world instanceof WorldServer))
return; return;
if(!(world.provider.dimensionId == 0)) { if(world.provider.dimensionId != 0) {
return; return;
} }

View File

@ -4,12 +4,14 @@ import java.util.List;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.entity.effect.EntityNukeTorex; import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.logic.EntityTomBlast;
import com.hbm.entity.mob.siege.EntitySiegeTunneler; import com.hbm.entity.mob.siege.EntitySiegeTunneler;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.special.ItemBookLore; import com.hbm.items.special.ItemBookLore;
import com.hbm.items.special.ItemBookLore.BookLoreType; import com.hbm.items.special.ItemBookLore.BookLoreType;
import com.hbm.items.special.ItemKitCustom; import com.hbm.items.special.ItemKitCustom;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.saveddata.TomSaveData;
import com.hbm.world.feature.OilSpot; import com.hbm.world.feature.OilSpot;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
@ -36,6 +38,19 @@ public class ItemWandD extends Item {
if(pos != null) { if(pos != null) {
TomSaveData data = TomSaveData.forWorld(world);
data.impact = false;
data.fire = 0F;
data.dust = 0F;
data.markDirty();
/*EntityTomBlast tom = new EntityTomBlast(world);
tom.posX = pos.blockX;
tom.posY = pos.blockY;
tom.posZ = pos.blockZ;
tom.destructionRange = 600;
world.spawnEntityInWorld(tom);*/
/*ItemStack itemStack = new ItemStack(ModItems.book_lore); /*ItemStack itemStack = new ItemStack(ModItems.book_lore);
BookLoreType.setTypeForStack(itemStack, BookLoreType.BOOK_IODINE); BookLoreType.setTypeForStack(itemStack, BookLoreType.BOOK_IODINE);

View File

@ -10,6 +10,7 @@ import com.hbm.config.GeneralConfig;
import com.hbm.config.WorldConfig; import com.hbm.config.WorldConfig;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.saveddata.TomSaveData;
import com.hbm.tileentity.machine.storage.TileEntitySafe; import com.hbm.tileentity.machine.storage.TileEntitySafe;
import com.hbm.tileentity.machine.storage.TileEntitySoyuzCapsule; import com.hbm.tileentity.machine.storage.TileEntitySoyuzCapsule;
import com.hbm.world.dungeon.AncientTomb; import com.hbm.world.dungeon.AncientTomb;
@ -75,24 +76,26 @@ public class HbmWorldGen implements IWorldGenerator {
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(i, j); BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(i, j);
if(biome instanceof BiomeGenForest && rand.nextInt(16) == 0) { if(!TomSaveData.forWorld(world).impact) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.FOXGLOVE.ordinal());
}
if(biome == BiomeGenBase.roofedForest && rand.nextInt(8) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.NIGHTSHADE.ordinal());
}
if(biome instanceof BiomeGenJungle && rand.nextInt(8) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.TOBACCO.ordinal());
}
if(biome instanceof BiomeGenRiver && rand.nextInt(4) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.reeds, 0);
}
if(biome instanceof BiomeGenBeach && rand.nextInt(8) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.reeds, 0);
}
if(rand.nextInt(64) == 0) { if(biome instanceof BiomeGenForest && rand.nextInt(16) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.WEED.ordinal()); DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.FOXGLOVE.ordinal());
}
if(biome == BiomeGenBase.roofedForest && rand.nextInt(8) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.NIGHTSHADE.ordinal());
}
if(biome instanceof BiomeGenJungle && rand.nextInt(8) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.TOBACCO.ordinal());
}
if(rand.nextInt(64) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.WEED.ordinal());
}
if(biome instanceof BiomeGenRiver && rand.nextInt(4) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.reeds, 0);
}
if(biome instanceof BiomeGenBeach && rand.nextInt(8) == 0) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.reeds, 0);
}
} }
if(WorldConfig.oilcoalSpawn > 0 && rand.nextInt(WorldConfig.oilcoalSpawn) == 0) if(WorldConfig.oilcoalSpawn > 0 && rand.nextInt(WorldConfig.oilcoalSpawn) == 0)

View File

@ -826,6 +826,7 @@ public class MainRegistry {
ModEventHandlerImpact impactHandler = new ModEventHandlerImpact(); ModEventHandlerImpact impactHandler = new ModEventHandlerImpact();
FMLCommonHandler.instance().bus().register(impactHandler); FMLCommonHandler.instance().bus().register(impactHandler);
MinecraftForge.EVENT_BUS.register(impactHandler); MinecraftForge.EVENT_BUS.register(impactHandler);
MinecraftForge.TERRAIN_GEN_BUS.register(impactHandler);
OreDictManager oreMan = new OreDictManager(); OreDictManager oreMan = new OreDictManager();
MinecraftForge.EVENT_BUS.register(oreMan); //OreRegisterEvent MinecraftForge.EVENT_BUS.register(oreMan); //OreRegisterEvent

View File

@ -1,6 +1,7 @@
package com.hbm.main; package com.hbm.main;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@ -166,6 +167,12 @@ public class ModEventHandlerClient {
} }
} }
/*List<String> text = new ArrayList();
text.add("IMPACT: " + ImpactWorldHandler.getImpactForClient(world));
text.add("DUST: " + ImpactWorldHandler.getDustForClient(world));
text.add("FIRE: " + ImpactWorldHandler.getFireForClient(world));
ILookOverlay.printGeneric(event, "DEBUG", 0xffff00, 0x4040000, text);*/
/*if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK) { /*if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK) {
ScaledResolution resolution = event.resolution; ScaledResolution resolution = event.resolution;
GL11.glPushMatrix(); GL11.glPushMatrix();
@ -194,7 +201,7 @@ public class ModEventHandlerClient {
HbmAnimations.hotbar[i] = null; HbmAnimations.hotbar[i] = null;
} }
if(!ducked && Keyboard.isKeyDown(Keyboard.KEY_O)) { if(!ducked && Keyboard.isKeyDown(Keyboard.KEY_O) && Minecraft.getMinecraft().currentScreen == null) {
ducked = true; ducked = true;
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(0, 0, 0, 999, 0)); PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(0, 0, 0, 999, 0));

View File

@ -140,7 +140,7 @@ public class ModEventHandlerImpact {
if(data.impact) { if(data.impact) {
if(mat == Material.wood || mat == Material.glass || b == Blocks.ladder || b instanceof BlockCrops || if(mat == Material.wood || mat == Material.glass || b == Blocks.ladder || b instanceof BlockCrops ||
b == Blocks.chest || b instanceof BlockDoor || mat == Material.cloth || mat == Material.water) { b == Blocks.chest || b instanceof BlockDoor || mat == Material.cloth || mat == Material.water || b == Blocks.stone_slab) {
event.replacement = Blocks.air; event.replacement = Blocks.air;
} else if(b == Blocks.cobblestone || b == Blocks.stonebrick) { } else if(b == Blocks.cobblestone || b == Blocks.stonebrick) {

View File

@ -101,6 +101,8 @@ public class PacketDispatcher {
wrapper.registerMessage(NBTItemControlPacket.Handler.class, NBTItemControlPacket.class, i++, Side.SERVER); wrapper.registerMessage(NBTItemControlPacket.Handler.class, NBTItemControlPacket.class, i++, Side.SERVER);
//sends a button press to the held item, assuming it is an ISyncButtons //sends a button press to the held item, assuming it is an ISyncButtons
wrapper.registerMessage(SyncButtonsPacket.Handler.class, SyncButtonsPacket.class, i++, Side.SERVER); wrapper.registerMessage(SyncButtonsPacket.Handler.class, SyncButtonsPacket.class, i++, Side.SERVER);
//General syncing for global values
wrapper.registerMessage(PermaSyncPacket.Handler.class, PermaSyncPacket.class, i++, Side.CLIENT);
} }
} }

View File

@ -4,6 +4,7 @@ import com.hbm.handler.ImpactWorldHandler;
import com.hbm.saveddata.TomSaveData; import com.hbm.saveddata.TomSaveData;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -24,7 +25,7 @@ public class PermaSyncHandler {
/// TOM IMPACT DATA /// /// TOM IMPACT DATA ///
} }
public static void readPacket(ByteBuf buf, World world, EntityPlayerMP player) { public static void readPacket(ByteBuf buf, World world, EntityPlayer player) {
/// TOM IMPACT DATA /// /// TOM IMPACT DATA ///
ImpactWorldHandler.lastSyncWorld = player.worldObj; ImpactWorldHandler.lastSyncWorld = player.worldObj;

View File

@ -4,6 +4,8 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
public class PermaSyncPacket implements IMessage { public class PermaSyncPacket implements IMessage {
@ -34,7 +36,7 @@ public class PermaSyncPacket implements IMessage {
try { try {
EntityPlayerMP player = m.player; EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(player != null) PermaSyncHandler.readPacket(m.out, player.worldObj, player); if(player != null) PermaSyncHandler.readPacket(m.out, player.worldObj, player);
} catch(Exception x) { } } catch(Exception x) { }