update forge and fix platforms, more curios

This commit is contained in:
Vincent Lee authored and Vincent Lee committed 2019-06-02 12:44:22 -07:00
1 parent 6ce466273c
commit 3595f35e5b
27 files changed
+298 -389

No files matched your search

@@ -11,6 +11,7 @@
package vazkii.botania.api.item;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
@@ -59,8 +60,8 @@ public interface IBaubleRender {
* Shifts the render for a bauble correctly to the head, including sneaking rotation.
* Use for renders under {@link RenderType#HEAD}.
*/
public static void translateToHeadLevel(EntityPlayer player) {
GlStateManager.translatef(0, -player.getDefaultEyeHeight(), 0);
public static void translateToHeadLevel(EntityLivingBase player) {
GlStateManager.translatef(0, -player.getEyeHeight(), 0);
if (player.isSneaking())
GlStateManager.translatef(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F);
}
@@ -18,6 +18,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.client.model.data.ModelProperty;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.state.enums.AlfPortalState;
import vazkii.botania.api.state.enums.CratePattern;
@@ -29,20 +30,14 @@ public final class BotaniaStateProps {
/** Unlisted properties **/
// The property for specialFlower subtile id
public static final PropertyObject<ResourceLocation> SUBTILE_ID = new PropertyObject<>("subtile_id", ResourceLocation.class);
// The property for floating flower island type
public static final PropertyObject<IFloatingFlower.IslandType> ISLAND_TYPE = new PropertyObject<>("islandtype", IFloatingFlower.IslandType.class);
public static final ModelProperty<IFloatingFlower> FLOATING_DATA = new ModelProperty<>();
// The property for platform held blockstate id
public static final PropertyObject<IBlockState> HELD_STATE = new PropertyObject<>("held_state", IBlockState.class);
// The property for platform held blockstate
public static final ModelProperty<IBlockState> HELD_STATE = new ModelProperty<>();
// The property for platform world object
public static final PropertyObject<IBlockReader> HELD_WORLD = new PropertyObject<>("held_world", IBlockReader.class);
// The proeprty for platform world pos
public static final PropertyObject<BlockPos> HELD_POS = new PropertyObject<>("held_pos", BlockPos.class);
// The property for platform world pos
public static final ModelProperty<BlockPos> HELD_POS = new ModelProperty<>();
/** Common properties to all blocks to use **/
@@ -67,22 +62,6 @@ public final class BotaniaStateProps {
// BlockEnchanter
public static final EnumProperty<EnumFacing.Axis> ENCHANTER_DIRECTION = EnumProperty.create("facing", EnumFacing.Axis.class, Predicates.not(Predicates.equalTo(EnumFacing.Axis.Y)));
// BlockModDoubleFlower (white to gray)
public static final EnumProperty<EnumDyeColor> DOUBLEFLOWER_VARIANT_1 = EnumProperty.create("df_variant", EnumDyeColor.class, new Predicate<EnumDyeColor>() {
@Override
public boolean apply(EnumDyeColor input) {
return input.ordinal() >= 0 && input.ordinal() <= 7;
}
});
// (silver to black)
public static final EnumProperty<EnumDyeColor> DOUBLEFLOWER_VARIANT_2 = EnumProperty.create("df_variant", EnumDyeColor.class, new Predicate<EnumDyeColor>() {
@Override
public boolean apply(EnumDyeColor input) {
return input.ordinal() >= 8 && input.ordinal() <= 15;
}
});
// BlockCraftyCrate
public static final EnumProperty<CratePattern> CRATE_PATTERN = EnumProperty.create("pattern", CratePattern.class);
@@ -1,61 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p>
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.api.state;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import net.minecraftforge.common.property.IUnlistedProperty;
import java.util.Objects;
// Generic base class for unlisted properties
public class PropertyObject<T> implements IUnlistedProperty<T> {
private final String name;
private final Class<T> clazz;
private final Predicate<T> validator;
private final Function<T, String> stringFunction;
public PropertyObject(String name, Class<T> clazz, Predicate<T> validator, Function<T, String> stringFunction) {
this.name = name;
this.clazz = clazz;
this.validator = validator;
this.stringFunction = stringFunction;
}
public PropertyObject(String name, Class<T> clazz) {
this(name, clazz, Predicates.<T>alwaysTrue(), new Function<T, String>() {
@Override
public String apply(T input) {
return Objects.toString(input);
}
});
}
@Override
public String getName() {
return name;
}
@Override
public boolean isValid(T value) {
return validator.apply(value);
}
@Override
public Class<T> getType() {
return clazz;
}
@Override
public String valueToString(T value) {
return stringFunction.apply(value);
}
}
@@ -34,6 +34,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.registries.ForgeRegistries;
@@ -42,6 +45,7 @@ import vazkii.botania.api.capability.FloatingFlowerImpl;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.wand.IWandBindable;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.string.TileRedStringRelay;
@@ -130,7 +134,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickable, IW
return getCapability(BotaniaAPI.FLOATING_FLOWER_CAP).isPresent();
}
public boolean isOnSpecialSoil() {
private boolean isOnSpecialSoil() {
if(isFloating()) {
return false;
} else {
@@ -350,5 +354,14 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickable, IW
return 0;
}
@Nonnull
@Override
public IModelData getModelData() {
if(isFloating()) {
return new ModelDataMap.Builder()
.withInitial(BotaniaStateProps.FLOATING_DATA, floatingData)
.build();
}
return EmptyModelData.INSTANCE;
}
}
@@ -21,8 +21,6 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
@@ -86,22 +84,6 @@ public final class DebugHandler {
event.getLeft().add(" GL_ARB_multitexture: " + caps.GL_ARB_multitexture);
event.getLeft().add(" GL_ARB_texture_non_power_of_two: " + caps.GL_ARB_texture_non_power_of_two);
event.getLeft().add(" OpenGL13: " + caps.OpenGL13);
if (Minecraft.getInstance().objectMouseOver != null
&& Minecraft.getInstance().objectMouseOver.getBlockPos() != null) {
BlockPos pos = Minecraft.getInstance().objectMouseOver.getBlockPos();
IBlockState state = world.getBlockState(pos);
state = state.getBlock().getExtendedState(state, world, pos);
if (state instanceof IExtendedBlockState) {
try {
for (Map.Entry<IUnlistedProperty<?>, Optional<?>> e : ((IExtendedBlockState) state).getUnlistedProperties().entrySet()) {
event.getRight().add(TextFormatting.LIGHT_PURPLE + e.getKey().getName() + ": " + TextFormatting.RESET + e.getValue().orElse(null));
}
} catch (Throwable t) {
event.getRight().add("Error getting extended state");
}
}
}
} else if(Minecraft.IS_RUNNING_ON_MAC)
event.getLeft().add(PREFIX + "SHIFT+CMD for context");
else event.getLeft().add(PREFIX + "SHIFT+CTRL for context");
@@ -88,11 +88,11 @@ public class MiscellaneousIcons {
evt.getModelRegistry().put(new ModelResourceLocation("botania:floating_special_flower", "inventory"), model);
// Platforms
ModelResourceLocation abstruseName = new ModelResourceLocation("botania:abstruse_platform", "normal");
ModelResourceLocation abstruseName = new ModelResourceLocation("botania:abstruse_platform", "");
IBakedModel abstruse = evt.getModelRegistry().get(abstruseName);
ModelResourceLocation spectralName = new ModelResourceLocation("botania:spectral_platform", "normal");
ModelResourceLocation spectralName = new ModelResourceLocation("botania:spectral_platform", "");
IBakedModel spectral = evt.getModelRegistry().get(spectralName);
ModelResourceLocation infrangibleName = new ModelResourceLocation("botania:infrangible_platform", "normal");
ModelResourceLocation infrangibleName = new ModelResourceLocation("botania:infrangible_platform", "");
IBakedModel infrangible = evt.getModelRegistry().get(infrangibleName);
evt.getModelRegistry().put(abstruseName, new PlatformModel(abstruse));
@@ -11,7 +11,6 @@ package vazkii.botania.client.model;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Table;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.model.BakedQuad;
@@ -30,11 +29,12 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.client.model.pipeline.VertexTransformer;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.commons.lang3.tuple.Pair;
import vazkii.botania.api.BotaniaAPIClient;
@@ -43,9 +43,7 @@ import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.decor.BlockFloatingFlower;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -58,7 +56,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
public class FloatingFlowerModel implements IBakedModel {
public class FloatingFlowerModel implements IDynamicBakedModel {
private final Table<IFloatingFlower.IslandType, ResourceLocation, CompositeBakedModel> CACHE = HashBasedTable.create();
@@ -90,27 +88,22 @@ public class FloatingFlowerModel implements IBakedModel {
@Nonnull
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing face, @Nonnull Random rand) {
if(!(state.getBlock() instanceof BlockFloatingFlower))
return Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel().getQuads(state, face, rand);
if(true) // todo 1.13
return ImmutableList.of();
IExtendedBlockState realState = (IExtendedBlockState) state;
IFloatingFlower.IslandType islandType = realState.getValue(BotaniaStateProps.ISLAND_TYPE);
return getModel(islandType, state.getBlock().getRegistryName()).getQuads(state, face, rand);
public List<BakedQuad> getQuads(IBlockState state, EnumFacing face, @Nonnull Random rand, @Nonnull IModelData data) {
if(!data.hasProperty(BotaniaStateProps.FLOATING_DATA))
return Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel().getQuads(state, face, rand, data);
IFloatingFlower floatingData = data.getData(BotaniaStateProps.FLOATING_DATA);
return getModel(floatingData.getIslandType(), floatingData.getDisplayStack()).getQuads(state, face, rand);
}
// Get the model for this islandtype + flower type combination. If it's not cached already, generate it.
private CompositeBakedModel getModel(IFloatingFlower.IslandType islandType, ResourceLocation identifier) {
private CompositeBakedModel getModel(IFloatingFlower.IslandType islandType, ItemStack flower) {
ModelManager modelManager = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getModelManager();
if(islandType == null) // This and the next one can be null if obtained from a non-extended state
islandType = IFloatingFlower.IslandType.GRASS;
if(identifier == null)
identifier = ModBlocks.whiteFloatingFlower.getRegistryName();
if(CACHE.contains(islandType, identifier)) {
return CACHE.get(islandType, identifier);
if(CACHE.contains(islandType, flower.getItem().getRegistryName())) {
return CACHE.get(islandType, flower.getItem().getRegistryName());
} else {
IBakedModel islandModel;
try {
@@ -120,20 +113,12 @@ public class FloatingFlowerModel implements IBakedModel {
islandModel = modelManager.getMissingModel();
}
Item item;
if(identifier.getPath().endsWith(LibBlockNames.FLOATING_FLOWER_SUFFIX)) {
ResourceLocation shinyId = new ResourceLocation(identifier.getNamespace(), identifier.getPath().replaceAll(LibBlockNames.FLOATING_FLOWER_SUFFIX, LibBlockNames.SHINY_FLOWER_SUFFIX));
item = ForgeRegistries.ITEMS.getValue(shinyId);
} else {
item = ForgeRegistries.ITEMS.getValue(identifier);
}
IBakedModel flowerModel = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getItemModel(new ItemStack(item));
IBakedModel flowerModel = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getItemModel(flower);
// Enhance!
CompositeBakedModel model = new CompositeBakedModel(flowerModel, islandModel);
Botania.LOGGER.debug("Cached floating flower model for islandtype {} and flowertype {}", islandType, identifier);
CACHE.put(islandType, identifier, model);
Botania.LOGGER.debug("Cached floating flower model for islandtype {} and flowertype {}", islandType, flower.getItem().getRegistryName());
CACHE.put(islandType, flower.getItem().getRegistryName(), model);
return model;
}
}
@@ -218,8 +203,7 @@ public class FloatingFlowerModel implements IBakedModel {
@Override
public IBakedModel getModelWithOverrides(IBakedModel model, ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
// Items always have GRASS island
IFloatingFlower.IslandType islandType = IFloatingFlower.IslandType.GRASS;
return FloatingFlowerModel.this.getModel(islandType, stack.getItem().getRegistryName());
return FloatingFlowerModel.this.getModel(IFloatingFlower.IslandType.GRASS, stack);
}
};
}
@@ -26,7 +26,10 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.client.model.ModelDataManager;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.BlockCamo;
import vazkii.botania.common.block.BlockPlatform;
@@ -37,7 +40,7 @@ import javax.annotation.Nonnull;
import java.util.List;
import java.util.Random;
public class PlatformModel implements IBakedModel {
public class PlatformModel implements IDynamicBakedModel {
private final IBakedModel original;
public PlatformModel(IBakedModel original) {
@@ -46,7 +49,7 @@ public class PlatformModel implements IBakedModel {
@Nonnull
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, Random rand) {
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, @Nonnull Random rand, @Nonnull IModelData data) {
if(state == null)
return ImmutableList.of();
@@ -58,18 +61,17 @@ public class PlatformModel implements IBakedModel {
layer = BlockRenderLayer.SOLID; // workaround for when this isn't set (digging, etc.)
}
IBlockState heldState = ((IExtendedBlockState) state).getValue(BotaniaStateProps.HELD_STATE);
IBlockReader heldWorld = ((IExtendedBlockState) state).getValue(BotaniaStateProps.HELD_WORLD);
BlockPos heldPos = ((IExtendedBlockState) state).getValue(BotaniaStateProps.HELD_POS);
IBlockState heldState = data.getData(BotaniaStateProps.HELD_STATE);
BlockPos heldPos = data.getData(BotaniaStateProps.HELD_POS);
if (heldWorld == null || heldPos == null) {
if (heldPos == null) {
return ImmutableList.of();
}
Minecraft mc = Minecraft.getInstance();
if(heldState == null && layer == BlockRenderLayer.SOLID) {
// No camo
return original.getQuads(state, side, rand);
return original.getQuads(state, side, rand, data);
} else if(heldState != null) {
// Some people used this to get an invisible block in the past, accommodate that.
@@ -80,9 +82,8 @@ public class PlatformModel implements IBakedModel {
// Steal camo's model
IBakedModel model = mc.getBlockRendererDispatcher().getBlockModelShapes().getModel(heldState);
// Their model can be smart too
IBlockState extended = heldState.getBlock().getExtendedState(heldState, new FakeBlockAccess(heldWorld), heldPos);
return model.getQuads(extended, side, rand);
// todo possible to reimplement calling camo's smart model stuff too?
return model.getQuads(heldState, side, rand, EmptyModelData.INSTANCE);
}
}
@@ -106,34 +107,4 @@ public class PlatformModel implements IBakedModel {
return original.getOverrides();
}
private static class FakeBlockAccess implements IBlockReader {
private final IBlockReader compose;
private FakeBlockAccess(IBlockReader compose) {
this.compose = compose;
}
@Override
public TileEntity getTileEntity(@Nonnull BlockPos pos) {
return compose.getTileEntity(pos);
}
@Nonnull
@Override
public IBlockState getBlockState(@Nonnull BlockPos pos) {
IBlockState state = compose.getBlockState(pos);
if(state.getBlock() instanceof BlockCamo) {
state = ((TileCamo) compose.getTileEntity(pos)).camoState;
}
return state == null ? Blocks.AIR.getDefaultState() : state;
}
@Nonnull
@Override
public IFluidState getFluidState(@Nonnull BlockPos pos) {
return compose.getFluidState(pos);
}
}
}
@@ -34,7 +34,6 @@ import net.minecraftforge.client.model.animation.Animation;
import net.minecraftforge.common.animation.Event;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.animation.CapabilityAnimation;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.Properties;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
@@ -167,8 +167,8 @@ public class Botania {
MinecraftForge.EVENT_BUS.register(new LootHandler());
if(ModList.get().isLoaded("curios")) {
FMLJavaModLoadingContext.get().getModEventBus().addListener(CurioIntegration::sendImc);
MinecraftForge.EVENT_BUS.addGenericListener(ItemStack.class, CurioIntegration::attachCaps);
FMLJavaModLoadingContext.get().getModEventBus().register(CurioIntegration.class);
MinecraftForge.EVENT_BUS.register(CurioIntegration.class);
}
if(Botania.gardenOfGlassLoaded)
@@ -29,8 +29,6 @@ import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.lexicon.ILexiconable;
@@ -66,28 +64,6 @@ public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable,
}
/* todo 1.13
@Nonnull
@Override
public BlockStateContainer createBlockState() {
return new ExtendedBlockState(this, new IProperty[0],
new IUnlistedProperty[] { BotaniaStateProps.HELD_STATE, BotaniaStateProps.HELD_WORLD, BotaniaStateProps.HELD_POS });
}
@Nonnull
@Override
public IBlockState getExtendedState(@Nonnull IBlockState state, IBlockReader world, BlockPos pos) {
state = ((IExtendedBlockState) state).with(BotaniaStateProps.HELD_WORLD, world)
.with(BotaniaStateProps.HELD_POS, pos);
TileEntity te = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
if (te instanceof TileCamo) {
TileCamo tile = (TileCamo) te;
return ((IExtendedBlockState) state).with(BotaniaStateProps.HELD_STATE, tile.camoState);
} else {
return state;
}
}
@Override
public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB par5AxisAlignedBB, @Nonnull List<AxisAlignedBB> stacks, Entity par7Entity, boolean isActualState) {
if(variant == Variant.INFRANGIBLE || variant == Variant.ABSTRUSE && par7Entity != null && par7Entity.posY > pos.getY() + 0.9 && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking()))
@@ -29,8 +29,6 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
@@ -16,6 +16,11 @@ import net.minecraft.nbt.NBTUtil;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import vazkii.botania.api.state.BotaniaStateProps;
import javax.annotation.Nonnull;
public class TileCamo extends TileMod {
@@ -45,6 +50,16 @@ public class TileCamo extends TileMod {
@Override
public void onDataPacket(NetworkManager manager, SPacketUpdateTileEntity packet) {
super.onDataPacket(manager, packet);
requestModelDataUpdate();
world.markBlockRangeForRenderUpdate(pos, pos);
}
@Nonnull
@Override
public IModelData getModelData() {
return new ModelDataMap.Builder()
.withInitial(BotaniaStateProps.HELD_POS, getPos())
.withInitial(BotaniaStateProps.HELD_STATE, camoState)
.build();
}
}
@@ -15,6 +15,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.registries.ObjectHolder;
@@ -23,6 +25,7 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.capability.FloatingFlowerImpl;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.decor.BlockFloatingFlower;
import vazkii.botania.common.lib.LibBlockNames;
@@ -88,4 +91,11 @@ public class TileFloatingFlower extends TileMod {
BotaniaAPI.FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA));
}
@Nonnull
@Override
public IModelData getModelData() {
return new ModelDataMap.Builder()
.withInitial(BotaniaStateProps.FLOATING_DATA, floatingData)
.build();
}
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.brew.potion;
import javafx.geometry.Side;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
@@ -36,13 +37,13 @@ public class PotionMod extends Potion {
@Override
@OnlyIn(Dist.CLIENT)
public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) {
public void renderInventoryEffect(PotionEffect effect, Gui gui, int x, int y, float z) {
render(x + 6, y + 7, 1);
}
@Override
@OnlyIn(Dist.CLIENT)
public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) {
public void renderHUDEffect(PotionEffect effect, Gui gui, int x, int y, float z, float alpha) {
render(x + 3, y + 3, alpha);
}
@@ -7,6 +7,7 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import top.theillusivec4.curios.api.CuriosAPI;
@@ -14,10 +15,16 @@ import top.theillusivec4.curios.api.capability.CuriosCapability;
import top.theillusivec4.curios.api.capability.ICurio;
import top.theillusivec4.curios.api.imc.CurioIMCMessage;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.bauble.ItemAuraRing;
import vazkii.botania.common.item.equipment.bauble.ItemGreaterAuraRing;
import vazkii.botania.common.item.equipment.bauble.ItemIcePendant;
import vazkii.botania.common.item.equipment.bauble.ItemItemFinder;
import vazkii.botania.common.item.equipment.bauble.ItemKnockbackBelt;
import vazkii.botania.common.item.equipment.bauble.ItemMiningRing;
import vazkii.botania.common.item.equipment.bauble.ItemReachRing;
import vazkii.botania.common.item.equipment.bauble.ItemThirdEye;
import vazkii.botania.common.item.equipment.bauble.ItemWaterRing;
import vazkii.botania.common.item.relic.ItemLokiRing;
import vazkii.botania.common.item.relic.ItemOdinRing;
import vazkii.botania.common.lib.LibMisc;
@@ -44,12 +51,16 @@ public class CurioIntegration {
}
}
@SubscribeEvent
public static void sendImc(InterModEnqueueEvent evt) {
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("charm"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("ring"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("belt"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("body"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("head"));
}
@SubscribeEvent
public static void attachCaps(AttachCapabilitiesEvent<ItemStack> evt) {
ItemStack stack = evt.getObject();
@@ -61,8 +72,20 @@ public class CurioIntegration {
evt.addCapability(KEY, new Provider(new ItemKnockbackBelt.Curio(stack)));
} else if (stack.getItem() == ModItems.odinRing) {
evt.addCapability(KEY, new Provider(new ItemOdinRing.Curio(stack, ((ItemOdinRing) ModItems.odinRing).getDummy())));
} else if (stack.getItem() == ModItems.lokiRing) {
evt.addCapability(KEY, new Provider(new ItemLokiRing.Curio(stack, ((ItemLokiRing) ModItems.lokiRing).getDummy())));
} else if (stack.getItem() == ModItems.reachRing) {
evt.addCapability(KEY, new Provider(new ItemReachRing.Curio(stack)));
} else if (stack.getItem() == ModItems.thirdEye) {
evt.addCapability(KEY, new Provider(new ItemThirdEye.Curio(stack)));
} else if (stack.getItem() == ModItems.itemFinder) {
evt.addCapability(KEY, new Provider(new ItemItemFinder.Curio(stack)));
} else if (stack.getItem() == ModItems.auraRing) {
evt.addCapability(KEY, new Provider(new ItemAuraRing.Curio(stack)));
} else if (stack.getItem() == ModItems.auraRingGreater) {
evt.addCapability(KEY, new Provider(new ItemGreaterAuraRing.Curio(stack)));
} else if (stack.getItem() == ModItems.miningRing) {
evt.addCapability(KEY, new Provider(new ItemMiningRing.Curio(stack)));
}
}
}
@@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaGivingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemAuraRing extends ItemBauble implements IManaGivingItem {
@@ -23,22 +24,16 @@ public class ItemAuraRing extends ItemBauble implements IManaGivingItem {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
if(player instanceof EntityPlayer && player.ticksExisted % getDelay() == 0)
ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
int getDelay() {
return 10;
@Override
public void onCurioTick(String identifier, EntityLivingBase player) {
if(player instanceof EntityPlayer && player.ticksExisted % 10 == 0)
ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true);
}
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.RING;
}
*/
}
@@ -17,9 +17,9 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
@@ -47,7 +47,7 @@ public class ItemDodgeRing extends ItemBauble {
@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public static void onKeyDown(KeyInputEvent event) {
public static void onKeyDown(InputEvent.KeyInputEvent event) {
Minecraft mc = Minecraft.getInstance();
IItemHandler baublesInv = null; // BaublesApi.getBaublesHandler(mc.player);
@@ -10,16 +10,28 @@
*/
package vazkii.botania.common.item.equipment.bauble;
import vazkii.botania.common.lib.LibItemNames;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaGivingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
public class ItemGreaterAuraRing extends ItemAuraRing {
public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem {
public ItemGreaterAuraRing(Properties props) {
super(props);
}
@Override
int getDelay() {
return 2;
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, EntityLivingBase player) {
if(player instanceof EntityPlayer && player.ticksExisted % 2 == 0)
ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true);
}
}
}
@@ -38,19 +38,22 @@ import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.IBaubleRender;
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.integration.curios.BaseCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class ItemItemFinder extends ItemBauble implements IBaubleRender {
public class ItemItemFinder extends ItemBauble {
private static final String TAG_ENTITY_POSITIONS = "highlightPositionsEnt";
private static final String TAG_BLOCK_POSITIONS = "highlightPositionsBlock";
@@ -59,16 +62,47 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
if(!(player instanceof EntityPlayer))
return;
@Override
public void onCurioTick(String identifier, EntityLivingBase player) {
if(!(player instanceof EntityPlayer))
return;
if(player.world.isRemote)
tickClient(stack, (EntityPlayer) player);
else tickServer(stack, (EntityPlayer) player);
if(player.world.isRemote)
((ItemItemFinder) ModItems.itemFinder).tickClient(stack, (EntityPlayer) player);
else ((ItemItemFinder) ModItems.itemFinder).tickServer(stack, (EntityPlayer) player);
}
@Override
public boolean shouldSyncToTracking(String identifier, EntityLivingBase living) {
return true;
}
@Override
public boolean hasRender(String identifier, EntityLivingBase entityLivingBase) {
return true;
}
@Override
public void doRender(String identifier, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.itemFinderGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty();
IBaubleRender.Helper.translateToHeadLevel(living);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.4F, -1.4F, armor ? -0.3F : -0.25F);
GlStateManager.scalef(0.75F, 0.75F, 0.75F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 16F);
}
}
protected void tickClient(ItemStack stack, EntityPlayer player) {
@@ -105,15 +139,8 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
int[] currentEnts = entPosBuilder.elements();
boolean entsEqual = Arrays.equals(currentEnts, ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS));
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)
ItemNBTHelper.setList(stack, TAG_BLOCK_POSITIONS, blockPosBuilder);
if(!entsEqual || !blocksEqual)
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, 4);
ItemNBTHelper.setIntArray(stack, TAG_ENTITY_POSITIONS, currentEnts);
ItemNBTHelper.setList(stack, TAG_BLOCK_POSITIONS, blockPosBuilder);
}
private void scanForStack(ItemStack pstack, EntityPlayer player, IntArrayList entIdBuilder, NBTTagList blockPosBuilder) {
@@ -142,8 +169,8 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
} else if(e instanceof EntityPlayer) {
EntityPlayer player_ = (EntityPlayer) e;
LazyOptional<IItemHandler> playerInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
LazyOptional<IItemHandler> binv = LazyOptional.empty(); // todo 1.13 BaublesApi.getBaublesHandler(player);
if(scanInventory(binv, pstack) || scanInventory(playerInv, pstack))
LazyOptional<Collection<? extends IItemHandler>> binv = CuriosAPI.getCuriosHandler(player_).map(h -> h.getCurioMap().values());
if(scanInventory(playerInv, pstack) || scanInventories(binv, pstack))
entIdBuilder.add(player_.getEntityId());
} else if(e instanceof EntityVillager) {
@@ -188,45 +215,29 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2);
}
private boolean scanInventory(LazyOptional<IItemHandler> optInv, ItemStack pstack) {
if(pstack.isEmpty())
return false;
return optInv.map(inv -> {
for(int l = 0; l < inv.getSlots(); l++) {
ItemStack istack = inv.getStackInSlot(l);
if(!istack.isEmpty() && equalStacks(istack, pstack))
private boolean scanInventories(LazyOptional<Collection<? extends IItemHandler>> invs, ItemStack pstack) {
return invs.map(coll -> {
for(IItemHandler inv : coll)
if(scanInventory(inv, pstack))
return true;
}
return false;
}).orElse(false);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.HEAD;
private boolean scanInventory(LazyOptional<IItemHandler> optInv, ItemStack pstack) {
return optInv.map(inv -> scanInventory(inv, pstack)).orElse(false);
}
*/
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.itemFinderGem;
if(type == RenderType.HEAD) {
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty();
Helper.translateToHeadLevel(player);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.4F, -1.4F, armor ? -0.3F : -0.25F);
GlStateManager.scalef(0.75F, 0.75F, 0.75F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 16F);
private boolean scanInventory(IItemHandler inv, ItemStack pstack) {
if(pstack.isEmpty())
return false;
for(int l = 0; l < inv.getSlots(); l++) {
ItemStack istack = inv.getStackInSlot(l);
if(!istack.isEmpty() && equalStacks(istack, pstack))
return true;
}
return false;
}
}
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
@@ -25,41 +26,38 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
if(player instanceof EntityPlayer && !player.world.isRemote) {
int manaCost = 5;
boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false);
if(!hasMana)
onUnequipped(stack, player);
else {
if(player.getActivePotionEffect(MobEffects.HASTE) != null)
player.removePotionEffect(MobEffects.HASTE);
@Override
public void onCurioTick(String identifier, EntityLivingBase player) {
if(player instanceof EntityPlayer && !player.world.isRemote) {
int manaCost = 5;
boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false);
if(!hasMana)
onUnequipped(identifier, player);
else {
if(player.getActivePotionEffect(MobEffects.HASTE) != null)
player.removePotionEffect(MobEffects.HASTE);
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, Integer.MAX_VALUE, 1, true, true));
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, Integer.MAX_VALUE, 1, true, true));
}
if(player.swingProgress == 0.25F)
ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true);
}
}
if(player.swingProgress == 0.25F)
ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true);
@Override
public void onUnequipped(String identifier, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(MobEffects.HASTE);
if(effect != null && effect.getAmplifier() == 1)
player.removePotionEffect(MobEffects.HASTE);
}
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(MobEffects.HASTE);
if(effect != null && effect.getAmplifier() == 1)
player.removePotionEffect(MobEffects.HASTE);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
@Override
public boolean usesMana(ItemStack stack) {
return true;
@@ -32,61 +32,53 @@ import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
import java.util.List;
public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleRender {
public class ItemThirdEye extends ItemBauble implements IManaUsingItem {
private static final int COST = 2;
public ItemThirdEye(Properties props) {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
if(!(player instanceof EntityPlayer))
return;
EntityPlayer eplayer = (EntityPlayer) player;
double range = 24;
AxisAlignedBB aabb = new AxisAlignedBB(player.posX, player.posY, player.posZ, player.posX, player.posY, player.posZ).grow(range);
List<EntityLivingBase> mobs = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, (Entity e) -> e instanceof IMob);
if(!mobs.isEmpty())
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, EntityLivingBase living) {
if(!(living instanceof EntityPlayer))
return;
EntityPlayer eplayer = (EntityPlayer) living;
double range = 24;
AxisAlignedBB aabb = new AxisAlignedBB(living.posX, living.posY, living.posZ, living.posX, living.posY, living.posZ).grow(range);
List<EntityLivingBase> mobs = living.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, (Entity e) -> e instanceof IMob);
for(EntityLivingBase e : mobs) {
PotionEffect potion = e.getActivePotionEffect(MobEffects.GLOWING);
if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true))
e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 12, 0));
}
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.BODY;
}
*/
}
@Override
public boolean usesMana(ItemStack stack) {
return true;
}
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
@Override
public void doRender(String identifier, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
double scale = 0.6;
boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.3, -0.6, armor ? -0.18 : -0.12);
GlStateManager.scaled(scale, scale, scale);
GlStateManager.scaled(0.6, 0.6, 0.6);
for(int i = 0; i < 3; i++) {
GlStateManager.pushMatrix();
@@ -96,19 +88,19 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleR
case 1:
double scale1 = 0.75;
width /= 2F;
GlStateManager.translated(0.15, 0.15, -0.05);
double time = ClientTickHandler.total * 0.12;
double dist = 0.05;
GlStateManager.translated(Math.sin(time) * dist, Math.cos(time * 0.5) * dist, 0);
GlStateManager.scaled(scale1, scale1, scale1);
break;
case 2:
GlStateManager.translated(0, 0, -0.05);
break;
}
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.thirdEyeLayers[i];
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
@@ -119,5 +111,10 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleR
}
}
}
@Override
public boolean usesMana(ItemStack stack) {
return true;
}
}
@@ -34,12 +34,14 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.ISequentialBreaker;
import vazkii.botania.api.item.IWireframeCoordinateListProvider;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.integration.curios.RelicCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
import vazkii.botania.common.lib.LibItemNames;
@@ -69,17 +71,6 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
if(lokiRing.isEmpty() || !player.isSneaking())
return;
int slot = -1;
if (1==1) return; // todo 1.13
IItemHandler inv = null; // BaublesApi.getBaublesHandler(player);
for(int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack == lokiRing) {
slot = i;
break;
}
}
ItemStack heldItemStack = event.getItemStack();
BlockPos originCoords = getOriginPos(lokiRing);
RayTraceResult lookPos = ToolCommons.raytraceFromEntity(player.world, player, true, 10F);
@@ -94,11 +85,9 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
if(originCoords.getY() == -1) {
setOriginPos(lokiRing, lookPos.getBlockPos());
setCursorList(lokiRing, null);
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
} else {
if(originCoords.equals(lookPos.getBlockPos())) {
setOriginPos(lokiRing, new BlockPos(0, -1, 0));
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
} else {
addCursor : {
BlockPos relPos = lookPos.getBlockPos().add(new BlockPos(-originCoords.getX(), -originCoords.getY(), -originCoords.getZ()));
@@ -107,12 +96,10 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
if(cursor.equals(relPos)) {
cursors.remove(cursor);
setCursorList(lokiRing, cursors);
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
break addCursor;
}
addCursor(lokiRing, relPos);
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot);
}
}
}
@@ -151,16 +138,20 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
}
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
public static class Curio extends RelicCurio {
public Curio(ItemStack stack, ItemRelic relicDelegate) {
super(stack, relicDelegate);
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
setCursorList(stack, null);
@Override
public boolean shouldSyncToTracking(String identifier, EntityLivingBase living) {
return true;
}
@Override
public void onUnequipped(String identifier, EntityLivingBase living) {
setCursorList(stack, null);
}
}
@Override
@@ -195,12 +186,10 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
}
private static ItemStack getLokiRing(EntityPlayer player) {
IItemHandler baubles = null; // BaublesApi.getBaublesHandler(player);
int slot = -1; // todo 1.13 BaublesApi.isBaubleEquipped(player, ModItems.lokiRing);
if (slot < 0) {
return ItemStack.EMPTY;
}
return baubles.getStackInSlot(slot);
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(ModItems.lokiRing, player);
if(result != null)
return result.getStack();
return ItemStack.EMPTY;
}