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 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 b1 = world.getBlock(x + i, y + j + 1, z + k);

View File

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

View File

@ -15,61 +15,56 @@ public class EntityTom extends EntityThrowable {
super(p_i1582_1_);
this.ignoreFrustumCheck = true;
}
@Override
public void onUpdate() {
this.lastTickPosX = this.prevPosX = posX;
this.lastTickPosY = this.prevPosY = posY;
this.lastTickPosZ = this.prevPosZ = posZ;
this.setPosition(posX + this.motionX, posY + this.motionY, posZ + this.motionZ);
if(this.ticksExisted % 100 == 0) {
worldObj.playSoundEffect(posX, posY, posZ, "hbm:alarm.chime", 10000, 1.0F);
}
motionY = -0.5;
if(this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.air)
{
if(!this.worldObj.isRemote) {
EntityTomBlast tom = new EntityTomBlast(worldObj);
tom.posX = posX;
tom.posY = posY;
tom.posZ = posZ;
tom.destructionRange = 500;
worldObj.spawnEntityInWorld(tom);
EntityCloudTom cloud = new EntityCloudTom(worldObj, 500);
cloud.setLocationAndAngles(posX, posY, posZ, 0, 0);
worldObj.spawnEntityInWorld(cloud);
}
this.setDead();
}
if(this.worldObj.getBlock((int) this.posX, (int) this.posY, (int) this.posZ) != Blocks.air) {
if(!this.worldObj.isRemote) {
EntityTomBlast tom = new EntityTomBlast(worldObj);
tom.posX = posX;
tom.posY = posY;
tom.posZ = posZ;
tom.destructionRange = 600;
worldObj.spawnEntityInWorld(tom);
EntityCloudTom cloud = new EntityCloudTom(worldObj, 500);
cloud.setLocationAndAngles(posX, posY, posZ, 0, 0);
worldObj.spawnEntityInWorld(cloud);
}
this.setDead();
}
}
@Override
protected void onImpact(MovingObjectPosition p_70184_1_) {
}
@Override
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance)
{
return distance < 500000;
}
@Override
@Override
@SideOnly(Side.CLIENT)
public int getBrightnessForRender(float p_70070_1_)
{
return 15728880;
}
public boolean isInRangeToRenderDist(double distance) {
return distance < 500000;
}
@Override
public float getBrightness(float p_70013_1_)
{
return 1.0F;
}
}
@Override
@SideOnly(Side.CLIENT)
public int getBrightnessForRender(float p_70070_1_) {
return 15728880;
}
@Override
public float getBrightness(float p_70013_1_) {
return 1.0F;
}
}

View File

@ -2,12 +2,13 @@ package com.hbm.explosion;
import com.hbm.blocks.ModBlocks;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class ExplosionTom
{
public class ExplosionTom {
public int posX;
public int posY;
public int posZ;
@ -21,7 +22,7 @@ public class ExplosionTom
private int shell;
private int leg;
private int element;
public void saveToNbt(NBTTagCompound nbt, String name) {
nbt.setInteger(name + "posX", posX);
nbt.setInteger(name + "posY", posY);
@ -36,7 +37,7 @@ public class ExplosionTom
nbt.setInteger(name + "leg", leg);
nbt.setInteger(name + "element", element);
}
public void readFromNbt(NBTTagCompound nbt, String name) {
posX = nbt.getInteger(name + "posX");
posY = nbt.getInteger(name + "posY");
@ -51,23 +52,21 @@ public class ExplosionTom
leg = nbt.getInteger(name + "leg");
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.posY = y;
this.posZ = z;
this.worldObj = world;
this.radius = rad;
this.radius2 = this.radius * this.radius;
this.nlimit = this.radius2 * 4;
}
public boolean update()
{
public boolean update() {
breakColumn(this.lastposX, this.lastposZ);
this.shell = (int) Math.floor((Math.sqrt(n) + 1) / 2);
int shell2 = this.shell * 2;
@ -79,53 +78,77 @@ public class ExplosionTom
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);
if (dist > 0)
{
if(dist > 0) {
int pX = posX + x;
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 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--) {
if(worldObj.getBlock(pX, i, pZ) != Blocks.air) {
if(i == craterFloor || worldObj.getBlock(pX, i, pZ) != Blocks.air) {
y = i;
break;
}
}
int height = 70;
int offset = 10;
//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;
int height = terrain - 14;
int offset = 20;
int threshold = (int) ((float) Math.sqrt(x * x + z * z) * (float) (height + offset) / (float) this.radius) + worldObj.rand.nextInt(2) - offset;
while(y > threshold) {
if(y == 0)
break;
if(y <= threshold + 2 && worldObj.getBlock(pX, y, pZ) != Blocks.air) {
if(y <= craterFloor) {
if(worldObj.rand.nextInt(499) < 1) {
worldObj.setBlock(pX, y, pZ, ModBlocks.ore_tektite_osmiridium);
} else {
worldObj.setBlock(pX, y, pZ, ModBlocks.tektite);
}
} else {
if(y > 16) {
worldObj.setBlockToAir(pX, y, pZ);
if(y > terrain + 1) {
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 {
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);
}
}
y--;
}
}
}
}
}

View File

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

View File

@ -4,12 +4,14 @@ import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.logic.EntityTomBlast;
import com.hbm.entity.mob.siege.EntitySiegeTunneler;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemBookLore;
import com.hbm.items.special.ItemBookLore.BookLoreType;
import com.hbm.items.special.ItemKitCustom;
import com.hbm.lib.Library;
import com.hbm.saveddata.TomSaveData;
import com.hbm.world.feature.OilSpot;
import net.minecraft.entity.EntityLiving;
@ -36,6 +38,19 @@ public class ItemWandD extends Item {
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);
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.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.saveddata.TomSaveData;
import com.hbm.tileentity.machine.storage.TileEntitySafe;
import com.hbm.tileentity.machine.storage.TileEntitySoyuzCapsule;
import com.hbm.world.dungeon.AncientTomb;
@ -75,24 +76,26 @@ public class HbmWorldGen implements IWorldGenerator {
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(i, j);
if(biome instanceof BiomeGenForest && rand.nextInt(16) == 0) {
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) {
DungeonToolbox.generateFlowers(world, rand, i, j, ModBlocks.plant_flower, EnumFlowerType.WEED.ordinal());
if(!TomSaveData.forWorld(world).impact) {
if(biome instanceof BiomeGenForest && rand.nextInt(16) == 0) {
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)

View File

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

View File

@ -1,6 +1,7 @@
package com.hbm.main;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
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) {
ScaledResolution resolution = event.resolution;
GL11.glPushMatrix();
@ -194,7 +201,7 @@ public class ModEventHandlerClient {
HbmAnimations.hotbar[i] = null;
}
if(!ducked && Keyboard.isKeyDown(Keyboard.KEY_O)) {
if(!ducked && Keyboard.isKeyDown(Keyboard.KEY_O) && Minecraft.getMinecraft().currentScreen == null) {
ducked = true;
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(0, 0, 0, 999, 0));

View File

@ -140,7 +140,7 @@ public class ModEventHandlerImpact {
if(data.impact) {
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;
} 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);
//sends a button press to the held item, assuming it is an ISyncButtons
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 io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
@ -24,8 +25,8 @@ public class PermaSyncHandler {
/// 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 ///
ImpactWorldHandler.lastSyncWorld = player.worldObj;
ImpactWorldHandler.fire = buf.readFloat();

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.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
public class PermaSyncPacket implements IMessage {
@ -33,8 +35,8 @@ public class PermaSyncPacket implements IMessage {
public IMessage onMessage(PermaSyncPacket m, MessageContext ctx) {
try {
EntityPlayerMP player = m.player;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(player != null) PermaSyncHandler.readPacket(m.out, player.worldObj, player);
} catch(Exception x) { }