mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
Almost done with TEs
This commit is contained in:
1 parent
4736be9d61
commit
6cc88f1c5a
10 files changed
+82
-25
No files matched your search
@@ -90,6 +90,9 @@ public class BotaniaStateProps {
|
||||
// BlockForestDrum
|
||||
public static final PropertyEnum DRUM_VARIANT = PropertyEnum.create("variant", DrumVariant.class);
|
||||
|
||||
// BlockLightRelay
|
||||
public static final PropertyEnum LUMINIZER_VARIANT = PropertyEnum.create("variant", LuminizerVariant.class);
|
||||
|
||||
// BlockLivingRock
|
||||
public static final PropertyEnum LIVINGROCK_VARIANT = PropertyEnum.create("variant", LivingRockVariant.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package vazkii.botania.api.state.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum LuminizerVariant implements IStringSerializable {
|
||||
DEFAULT,
|
||||
DETECTOR;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -34,6 +35,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.LuminizerVariant;
|
||||
import vazkii.botania.api.wand.IWandable;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
@@ -53,6 +56,30 @@ public class BlockLightRelay extends BlockModContainer implements IWandable, ILe
|
||||
setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f);
|
||||
setUnlocalizedName(LibBlockNames.LIGHT_RELAY);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.LUMINIZER_VARIANT, LuminizerVariant.DEFAULT).withProperty(BotaniaStateProps.POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState createBlockState() {
|
||||
return new BlockState(this, BotaniaStateProps.LUMINIZER_VARIANT, BotaniaStateProps.POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
int meta = state.getValue(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.DETECTOR ? 1 : 0;
|
||||
if (((Boolean) state.getValue(BotaniaStateProps.POWERED))) {
|
||||
meta |= 8;
|
||||
} else {
|
||||
meta &= -9;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
boolean powered = (meta & 8) != 0;
|
||||
meta &= -9;
|
||||
return getDefaultState().withProperty(BotaniaStateProps.POWERED, powered).withProperty(BotaniaStateProps.LUMINIZER_VARIANT, meta == 1 ? LuminizerVariant.DETECTOR : LuminizerVariant.DEFAULT);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -80,7 +107,7 @@ public class BlockLightRelay extends BlockModContainer implements IWandable, ILe
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return meta == 0 ? 0 : 1;
|
||||
return state.getValue(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.DEFAULT ? 0 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +138,7 @@ public class BlockLightRelay extends BlockModContainer implements IWandable, ILe
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2);
|
||||
world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 1 | 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,8 +148,8 @@ public class BlockLightRelay extends BlockModContainer implements IWandable, ILe
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing s) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return (meta & 8) != 0 ? 15 : 0;
|
||||
return state.getValue(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.DEFAULT
|
||||
&& ((Boolean) state.getValue(BotaniaStateProps.POWERED)) ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,8 @@ import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.LuminizerVariant;
|
||||
import vazkii.botania.api.wand.IWandBindable;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
@@ -219,9 +221,8 @@ public class TileLightRelay extends TileMod implements IWandBindable, IUpdatePla
|
||||
if(pos.equals(exitPos)) {
|
||||
TileEntity tile = worldObj.getTileEntity(pos);
|
||||
if(tile != null && tile instanceof TileLightRelay) {
|
||||
int meta = worldObj.getBlockMetadata(x, y, z);
|
||||
if(meta > 0) {
|
||||
worldObj.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2);
|
||||
if(worldObj.getBlockState(pos).getValue(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.DETECTOR) {
|
||||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BotaniaStateProps.POWERED, true), 1 | 2);
|
||||
worldObj.scheduleUpdate(pos, tile.getBlockType(), tile.getBlockType().tickRate(worldObj));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.Botania;
|
||||
|
||||
public class TileManaBeacon extends TileMod implements IUpdatePlayerListBox {
|
||||
@@ -28,13 +29,16 @@ public class TileManaBeacon extends TileMod implements IUpdatePlayerListBox {
|
||||
}
|
||||
|
||||
if(!redstone) {
|
||||
float[] color = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)];
|
||||
int hex = ((EnumDyeColor) worldObj.getBlockState(getPos()).getValue(BotaniaStateProps.COLOR)).getMapColor().colorValue;
|
||||
int r = (hex & 0xFF0000) >> 16;
|
||||
int g = (hex & 0xFF00) >> 8;
|
||||
int b = (hex & 0xFF);
|
||||
|
||||
Botania.proxy.setWispFXDistanceLimit(false);
|
||||
Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, color[0], color[1], color[2], (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - yCoord)), (float) (Math.random() - 0.5F));
|
||||
Botania.proxy.wispFX(worldObj, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, r, g, b, (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - pos.getY())), (float) (Math.random() - 0.5F));
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
Botania.proxy.wispFX(worldObj, xCoord + 0.5, 256, zCoord + 0.5, color[0], color[1], color[2], (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F);
|
||||
Botania.proxy.wispFX(worldObj, pos.getX() + 0.5, 256, pos.getZ() + 0.5, r, g, b, (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F);
|
||||
Botania.proxy.setWispFXDistanceLimit(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -33,6 +34,8 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, IUpdatePl
|
||||
|
||||
int mana = 0;
|
||||
|
||||
private static final Method isActivated = ReflectionHelper.findMethod(MobSpawnerBaseLogic.class, null, LibObfuscation.IS_ACTIVATED);
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
TileEntity tileBelow = worldObj.getTileEntity(pos.down());
|
||||
@@ -40,7 +43,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, IUpdatePl
|
||||
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow;
|
||||
MobSpawnerBaseLogic logic = spawner.getSpawnerBaseLogic();
|
||||
|
||||
if(!logic.isActivated()) {
|
||||
if(!((Boolean) isActivated.invoke(logic))) {
|
||||
if(!worldObj.isRemote)
|
||||
mana -= 6;
|
||||
|
||||
@@ -49,10 +52,10 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, IUpdatePl
|
||||
--logic.spawnDelay;
|
||||
|
||||
if(Math.random() > 0.5)
|
||||
Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord - 0.3 + Math.random() * 0.25, zCoord + Math.random(), 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, (float) Math.random() / 3F, -0.025F - 0.005F * (float) Math.random(), 2F);
|
||||
Botania.proxy.wispFX(worldObj, getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() - 0.3 + Math.random() * 0.25, getPos().getZ() + Math.random(), 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, (float) Math.random() / 3F, -0.025F - 0.005F * (float) Math.random(), 2F);
|
||||
|
||||
logic.field_98284_d = logic.field_98287_c;
|
||||
logic.field_98287_c = (logic.field_98287_c + 1000.0F / (logic.spawnDelay + 200.0F)) % 360.0D;
|
||||
logic.prevMobRotation = logic.getMobRotation();
|
||||
logic.mobRotation = (logic.getMobRotation() + 1000.0F / (logic.spawnDelay + 200.0F)) % 360.0D;
|
||||
} else if(logic.spawnDelay == -1)
|
||||
resetTimer(logic);
|
||||
|
||||
@@ -73,23 +76,23 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, IUpdatePl
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
int j = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), new AxisAlignedBB(logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), logic.getSpawnerX() + 1, logic.getSpawnerY() + 1, logic.getSpawnerZ() + 1).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size();
|
||||
int j = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), new AxisAlignedBB(logic.func_177221_b(), logic.func_177221_b().add(1, 1, 1)).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size();
|
||||
|
||||
if (j >= maxNearbyEntities) {
|
||||
resetTimer(logic);
|
||||
return;
|
||||
}
|
||||
|
||||
double d2 = logic.getSpawnerX() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
double d3 = logic.getSpawnerY() + logic.getSpawnerWorld().rand.nextInt(3) - 1;
|
||||
double d4 = logic.getSpawnerZ() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
double d2 = logic.func_177221_b().getX() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
double d3 = logic.func_177221_b().getY() + logic.getSpawnerWorld().rand.nextInt(3) - 1;
|
||||
double d4 = logic.func_177221_b().getZ() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
|
||||
entity.setLocationAndAngles(d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F);
|
||||
|
||||
if(entityliving == null || entityliving.getCanSpawnHere()) {
|
||||
if(!worldObj.isRemote)
|
||||
logic.func_98265_a(entity);
|
||||
logic.getSpawnerWorld().playAuxSFX(2004, logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), 0);
|
||||
logic.getSpawnerWorld().playAuxSFX(2004, logic.func_177221_b(), 0);
|
||||
|
||||
if (entityliving != null)
|
||||
entityliving.spawnExplosionParticle();
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.IManaCollisionGhost;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
@@ -22,12 +23,12 @@ public class TileManaDetector extends TileMod implements IManaCollisionGhost, IU
|
||||
@Override
|
||||
public void update() {
|
||||
if(!worldObj.isRemote) {
|
||||
int meta = getBlockMetadata();
|
||||
int expectedMeta = worldObj.getEntitiesWithinAABB(IManaBurst.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))).size() != 0 ? 1 : 0;
|
||||
if(meta != expectedMeta)
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, expectedMeta, 1 | 2);
|
||||
boolean state = ((Boolean) worldObj.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED));
|
||||
boolean expectedState = worldObj.getEntitiesWithinAABB(IManaBurst.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))).size() != 0;
|
||||
if(state != expectedState)
|
||||
worldObj.setBlockState(getPos(), worldObj.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, expectedState), 1 | 2);
|
||||
|
||||
if(expectedMeta == 1)
|
||||
if(expectedState)
|
||||
for(int i = 0; i < 4; i++)
|
||||
Botania.proxy.sparkleFX(getWorld(), pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.UUID;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -66,6 +66,7 @@ public final class LibObfuscation {
|
||||
public static final String[] CURRENT_GAME_TYPE = new String[] { "currentGameType", "field_78779_k", "i" };
|
||||
|
||||
// MobSpawnerBaseLogic
|
||||
public static final String[] IS_ACTIVATED = new String[] { "isActivated" ,"func_98279_f", "g" };
|
||||
public static final String[] SPAWN_RANGE = new String[] { "spawnRange", "field_98290_m", "m" };
|
||||
public static final String[] SPAWN_COUNT = new String[] { "spawnCount", "field_98294_i", "i" };
|
||||
public static final String[] MAX_NEARBY_ENTITIES = new String[] { "maxNearbyEntities", "field_98292_k", "k" };
|
||||
|
||||
Reference in new issue
Block a user