mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Merge master
This commit is contained in:
15 files changed
+32
-101
No files matched your search
@@ -15,6 +15,7 @@ import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import org.lwjgl.opengl.ARBShaderObjects;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
@@ -24,7 +25,6 @@ import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.renderer.entity.RenderBiped;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.api.internal.ShaderCallback;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
@@ -80,26 +80,13 @@ public class RenderDoppleganger extends RenderBiped<EntityDoppleganger> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(@Nonnull EntityDoppleganger par1Entity) {
|
||||
protected ResourceLocation getEntityTexture(@Nonnull EntityDoppleganger entity) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
if(!(mc.getRenderViewEntity() instanceof EntityPlayer))
|
||||
if(!(mc.getRenderViewEntity() instanceof AbstractClientPlayer))
|
||||
return DefaultPlayerSkin.getDefaultSkinLegacy();
|
||||
|
||||
EntityPlayer view = (EntityPlayer) mc.getRenderViewEntity();
|
||||
|
||||
// Adapated from TileEntitySkullRenderer.renderTileEntityAt
|
||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = mc.getSkinManager().loadSkinFromCache(view.getGameProfile());
|
||||
|
||||
if (map.containsKey(MinecraftProfileTexture.Type.SKIN))
|
||||
{
|
||||
return mc.getSkinManager().loadSkin(map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
UUID uuid = EntityPlayer.getUUID(view.getGameProfile());
|
||||
return DefaultPlayerSkin.getDefaultSkin(uuid);
|
||||
}
|
||||
return ((AbstractClientPlayer) mc.getRenderViewEntity()).getLocationSkin();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,43 +14,6 @@ import net.minecraft.entity.Entity;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
|
||||
public final class MathHelper {
|
||||
|
||||
public static int[] doubleArrayToIntArray(double[] doubles) {
|
||||
int[] ret = new int[doubles.length * 2];
|
||||
for (int i = 0; i < doubles.length; i++) {
|
||||
long l = Double.doubleToLongBits(doubles[i]);
|
||||
ret[i] = (int) (l >>> 32);
|
||||
ret[i + 1] = (int) l;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int[] longArrayToIntArray(long[] longs) {
|
||||
int[] ret = new int[longs.length * 2];
|
||||
for (int i = 0; i < longs.length; i++) {
|
||||
ret[i] = (int) (longs[i] >>> 32);
|
||||
ret[i + 1] = (int) longs[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static long[] intArrayToLongArray(int[] ints) {
|
||||
long[] ret = new long[ints.length / 2];
|
||||
for (int i = 0; i < ints.length; i += 2) {
|
||||
ret[i / 2] = (long) ints[i] << 32 | ints[i + 1];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static double[] intArrayToDoubleArray(int[] ints) {
|
||||
double[] ret = new double[ints.length / 2];
|
||||
for (int i = 0; i < ints.length; i += 2) {
|
||||
long l = (long) ints[i] << 32 | ints[i + 1];
|
||||
ret[i / 2] = Double.longBitsToDouble(l);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
return (float) Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2));
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
|
||||
player.setSprinting(false);
|
||||
ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2);
|
||||
if(player instanceof EntityPlayerMP)
|
||||
BotaniaAPI.internalHandler.sendBaubleUpdatePacket((EntityPlayerMP) player, 0);
|
||||
BotaniaAPI.internalHandler.sendBaubleUpdatePacket((EntityPlayerMP) player, 4);
|
||||
}
|
||||
} else if(!flying) {
|
||||
boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F;
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.List;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.BaublesApi;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import gnu.trove.list.array.TLongArrayList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -31,11 +30,14 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
@@ -47,12 +49,10 @@ import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemItemFinder extends ItemBauble implements IBaubleRender {
|
||||
|
||||
private static final String TAG_POSITIONS_OLD = "highlightPositions";
|
||||
private static final String TAG_ENTITY_POSITIONS = "highlightPositionsEnt";
|
||||
private static final String TAG_BLOCK_POSITIONS = "highlightPositionsBlock1";
|
||||
|
||||
@@ -76,10 +76,11 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
|
||||
if(!Botania.proxy.isTheClientPlayer(player))
|
||||
return;
|
||||
|
||||
long[] blocks = getBlockPositions(stack);
|
||||
NBTTagList blocks = ItemNBTHelper.getList(stack, TAG_BLOCK_POSITIONS, Constants.NBT.TAG_LONG, false);
|
||||
Botania.proxy.setWispFXDepthTest(false);
|
||||
for(long l : blocks) {
|
||||
BlockPos pos = BlockPos.fromLong(l);
|
||||
|
||||
for(int i = 0; i < blocks.tagCount(); i++) {
|
||||
BlockPos pos = BlockPos.fromLong(((NBTTagLong) blocks.get(i)).getLong());
|
||||
float m = 0.02F;
|
||||
Botania.proxy.wispFX(pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5));
|
||||
}
|
||||
@@ -97,29 +98,26 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
|
||||
}
|
||||
|
||||
protected void tickServer(ItemStack stack, EntityPlayer player) {
|
||||
ItemNBTHelper.removeEntry(stack, TAG_POSITIONS_OLD);
|
||||
|
||||
TIntArrayList entPosBuilder = new TIntArrayList();
|
||||
TLongArrayList blockPosBuilder = new TLongArrayList();
|
||||
NBTTagList blockPosBuilder = new NBTTagList();
|
||||
|
||||
scanForStack(player.getHeldItemMainhand(), player, entPosBuilder, blockPosBuilder);
|
||||
scanForStack(player.getHeldItemOffhand(), player, entPosBuilder, blockPosBuilder);
|
||||
|
||||
int[] currentEnts = entPosBuilder.toArray();
|
||||
long[] currentBlocks = blockPosBuilder.toArray();
|
||||
|
||||
boolean entsEqual = Arrays.equals(currentEnts, ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS));
|
||||
boolean blocksEqual = Arrays.equals(currentBlocks, getBlockPositions(stack));
|
||||
boolean blocksEqual = blockPosBuilder.equals(ItemNBTHelper.getList(stack, TAG_BLOCK_POSITIONS, Constants.NBT.TAG_LONG, false));
|
||||
|
||||
if(!entsEqual)
|
||||
ItemNBTHelper.setIntArray(stack, TAG_ENTITY_POSITIONS, currentEnts);
|
||||
if(!blocksEqual)
|
||||
setBlockPositions(stack, currentBlocks);
|
||||
ItemNBTHelper.setList(stack, TAG_BLOCK_POSITIONS, blockPosBuilder);
|
||||
if(!entsEqual || !blocksEqual)
|
||||
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, 0);
|
||||
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, 4);
|
||||
}
|
||||
|
||||
private void scanForStack(ItemStack pstack, EntityPlayer player, TIntArrayList entIdBuilder, TLongArrayList blockPosBuilder) {
|
||||
private void scanForStack(ItemStack pstack, EntityPlayer player, TIntArrayList entIdBuilder, NBTTagList blockPosBuilder) {
|
||||
if(!pstack.isEmpty() || player.isSneaking()) {
|
||||
int range = 24;
|
||||
|
||||
@@ -172,7 +170,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
|
||||
for(EnumFacing e : EnumFacing.VALUES) {
|
||||
if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e)
|
||||
&& scanInventory(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e), pstack)) {
|
||||
blockPosBuilder.add(pos_.toLong());
|
||||
blockPosBuilder.appendTag(new NBTTagLong(pos_.toLong()));
|
||||
foundCap = true;
|
||||
break;
|
||||
}
|
||||
@@ -180,7 +178,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
|
||||
if(!foundCap && tile instanceof IInventory) {
|
||||
IInventory inv = (IInventory) tile;
|
||||
if(scanInventory(new InvWrapper(inv), pstack))
|
||||
blockPosBuilder.add(pos_.toLong());
|
||||
blockPosBuilder.appendTag(new NBTTagLong(pos_.toLong()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,17 +203,6 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
|
||||
return false;
|
||||
}
|
||||
|
||||
private long[] getBlockPositions(ItemStack stack) {
|
||||
int[] ints = ItemNBTHelper.getIntArray(stack, TAG_BLOCK_POSITIONS);
|
||||
return MathHelper.intArrayToLongArray(ints);
|
||||
}
|
||||
|
||||
private void setBlockPositions(ItemStack stack, long[] vals) {
|
||||
stack.getTagCompound().removeTag(TAG_BLOCK_POSITIONS);
|
||||
int[] write = MathHelper.longArrayToIntArray(vals);
|
||||
ItemNBTHelper.setIntArray(stack, TAG_BLOCK_POSITIONS, write);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack arg0) {
|
||||
return BaubleType.HEAD;
|
||||
|
||||
@@ -40,8 +40,7 @@ public class ItemEnderDagger extends ItemManasteelSword {
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, @Nonnull EntityLivingBase attacker) {
|
||||
if(!target.world.isRemote
|
||||
&& target instanceof EntityEnderman
|
||||
&& attacker instanceof EntityPlayer
|
||||
&& ((EntityPlayer) attacker).getCooledAttackStrength(0) == 1) {
|
||||
&& attacker instanceof EntityPlayer) {
|
||||
target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 20);
|
||||
}
|
||||
|
||||
|
||||
@@ -1407,6 +1407,10 @@ public final class LexiconData {
|
||||
preventingDecay = new DogLexiconEntry(LibLexicon.MISC_PRENTING_DECAY, categoryMisc);
|
||||
preventingDecay.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.monocle));
|
||||
|
||||
banners = new BasicLexiconEntry(LibLexicon.MISC_BANNERS, BotaniaAPI.categoryMisc);
|
||||
banners.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BANNERS))
|
||||
.setIcon(new ItemStack(ModItems.lexicon));
|
||||
|
||||
if (Botania.bcTriggersLoaded) {
|
||||
bcIntegration = new CompatLexiconEntry(LibLexicon.MISC_BC_INTEGRATION, categoryMisc, "BuildCraft");
|
||||
bcIntegration.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Items.REDSTONE));
|
||||
@@ -1436,11 +1440,5 @@ public final class LexiconData {
|
||||
new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b"))
|
||||
.setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
}
|
||||
|
||||
if (Botania.etFuturumLoaded) {
|
||||
banners = new CompatLexiconEntry(LibLexicon.MISC_BANNERS, BotaniaAPI.categoryMisc, "EtFuturum");
|
||||
banners.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BANNERS))
|
||||
.setIcon(new ItemStack(ModItems.lexicon));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,10 +40,6 @@ public class PacketBotaniaEffect implements IMessage {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public PacketBotaniaEffect(EffectType type, double x, double y, double z, double... args) {
|
||||
this(type, x, y, z, MathHelper.doubleArrayToIntArray(args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
type = EffectType.values()[buf.readShort()];
|
||||
|
||||
Reference in new issue
Block a user