mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-19 19:49:41 +00:00
More work on updating Mantle to 1.13.2.
Pulsar now functions!
This commit is contained in:
1 parent
e65a173890
commit
de4423f18b
76 files changed
+694
-575
No files matched your search
@@ -5,7 +5,7 @@ import javax.annotation.Nonnull;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -21,12 +21,12 @@ public class BlockConnectedTexture extends Block {
|
||||
|
||||
// These are the properties used for determining whether or not a side is connected. They
|
||||
// do NOT take up block IDs, they are unlisted properties
|
||||
public static final PropertyBool CONNECTED_DOWN = PropertyBool.create("connected_down");
|
||||
public static final PropertyBool CONNECTED_UP = PropertyBool.create("connected_up");
|
||||
public static final PropertyBool CONNECTED_NORTH = PropertyBool.create("connected_north");
|
||||
public static final PropertyBool CONNECTED_SOUTH = PropertyBool.create("connected_south");
|
||||
public static final PropertyBool CONNECTED_WEST = PropertyBool.create("connected_west");
|
||||
public static final PropertyBool CONNECTED_EAST = PropertyBool.create("connected_east");
|
||||
public static final BooleanProperty CONNECTED_DOWN = BooleanProperty.create("connected_down");
|
||||
public static final BooleanProperty CONNECTED_UP = BooleanProperty.create("connected_up");
|
||||
public static final BooleanProperty CONNECTED_NORTH = BooleanProperty.create("connected_north");
|
||||
public static final BooleanProperty CONNECTED_SOUTH = BooleanProperty.create("connected_south");
|
||||
public static final BooleanProperty CONNECTED_WEST = BooleanProperty.create("connected_west");
|
||||
public static final BooleanProperty CONNECTED_EAST = BooleanProperty.create("connected_east");
|
||||
|
||||
public BlockConnectedTexture(Material material) {
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package slimeknights.mantle.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.awt.print.Book;
|
||||
|
||||
import slimeknights.mantle.client.book.BookLoader;
|
||||
import slimeknights.mantle.common.CommonProxy;
|
||||
|
||||
@@ -20,12 +18,12 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
bookLoader.onResourceManagerReload(Minecraft.getMinecraft().getResourceManager());
|
||||
bookLoader.onResourceManagerReload(Minecraft.getInstance().getResourceManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(bookLoader);
|
||||
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener(bookLoader);
|
||||
MinecraftForge.EVENT_BUS.register(new ExtraHeartRenderHandler());
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package slimeknights.mantle.client;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CreativeTab extends CreativeTabs {
|
||||
public class CreativeTab extends ItemGroup {
|
||||
|
||||
private ItemStack icon;
|
||||
|
||||
@@ -25,16 +25,16 @@ public class CreativeTab extends CreativeTabs {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
public ItemStack getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public ItemStack getTabIconItem() {
|
||||
public ItemStack createIcon() {
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
@@ -2,35 +2,34 @@ package slimeknights.mantle.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import slimeknights.mantle.Mantle;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ExtraHeartRenderHandler {
|
||||
private static final ResourceLocation ICON_HEARTS = new ResourceLocation(Mantle.modId, "textures/gui/hearts.png");
|
||||
private static final ResourceLocation ICON_ABSORB = new ResourceLocation(Mantle.modId, "textures/gui/absorb.png");
|
||||
private static final ResourceLocation ICON_VANILLA = Gui.ICONS;
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
private int updateCounter = 0;
|
||||
private int playerHealth = 0;
|
||||
@@ -46,7 +45,7 @@ public class ExtraHeartRenderHandler {
|
||||
private static int left_height = 39;
|
||||
|
||||
public void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) {
|
||||
Minecraft.getMinecraft().ingameGUI.drawTexturedModalRect(x, y, textureX, textureY, width, height);
|
||||
Minecraft.getInstance().ingameGUI.drawTexturedModalRect(x, y, textureX, textureY, width, height);
|
||||
}
|
||||
|
||||
/* HUD */
|
||||
@@ -62,15 +61,14 @@ public class ExtraHeartRenderHandler {
|
||||
|
||||
// extra setup stuff from us
|
||||
left_height = GuiIngameForge.left_height;
|
||||
ScaledResolution resolution = event.getResolution();
|
||||
width = resolution.getScaledWidth();
|
||||
height = resolution.getScaledHeight();
|
||||
width = mc.mainWindow.getScaledWidth();
|
||||
height = mc.mainWindow.getScaledHeight();
|
||||
event.setCanceled(true);
|
||||
updateCounter = mc.ingameGUI.getUpdateCounter();
|
||||
updateCounter = mc.ingameGUI.getTicks();
|
||||
|
||||
// start default forge/mc rendering
|
||||
// changes are indicated by comment
|
||||
mc.mcProfiler.startSection("health");
|
||||
mc.profiler.startSection("health");
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
int health = MathHelper.ceil(player.getHealth());
|
||||
@@ -78,27 +76,27 @@ public class ExtraHeartRenderHandler {
|
||||
|
||||
if (health < this.playerHealth && player.hurtResistantTime > 0)
|
||||
{
|
||||
this.lastSystemTime = Minecraft.getSystemTime();
|
||||
this.lastSystemTime = Util.milliTime();
|
||||
this.healthUpdateCounter = (long)(this.updateCounter + 20);
|
||||
}
|
||||
else if (health > this.playerHealth && player.hurtResistantTime > 0)
|
||||
{
|
||||
this.lastSystemTime = Minecraft.getSystemTime();
|
||||
this.lastSystemTime = Util.milliTime();
|
||||
this.healthUpdateCounter = (long)(this.updateCounter + 10);
|
||||
}
|
||||
|
||||
if (Minecraft.getSystemTime() - this.lastSystemTime > 1000L)
|
||||
if (Util.milliTime() - this.lastSystemTime > 1000L)
|
||||
{
|
||||
this.playerHealth = health;
|
||||
this.lastPlayerHealth = health;
|
||||
this.lastSystemTime = Minecraft.getSystemTime();
|
||||
this.lastSystemTime = Util.milliTime();
|
||||
}
|
||||
|
||||
this.playerHealth = health;
|
||||
int healthLast = this.lastPlayerHealth;
|
||||
|
||||
IAttributeInstance attrMaxHealth = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
|
||||
float healthMax = (float)attrMaxHealth.getAttributeValue();
|
||||
IAttributeInstance attrMaxHealth = player.getAttribute(SharedMonsterAttributes.MAX_HEALTH);
|
||||
float healthMax = (float)attrMaxHealth.getValue();
|
||||
float absorb = MathHelper.ceil(player.getAbsorptionAmount());
|
||||
|
||||
// CHANGE: simulate 10 hearts max if there's more, so vanilla only renders one row max
|
||||
@@ -122,7 +120,7 @@ public class ExtraHeartRenderHandler {
|
||||
regen = updateCounter % 25;
|
||||
}
|
||||
|
||||
final int TOP = 9 * (mc.world.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
|
||||
final int TOP = 9 * (mc.world.getWorldInfo().isHardcore() ? 5 : 0);
|
||||
final int BACKGROUND = (highlight ? 25 : 16);
|
||||
int MARGIN = 16;
|
||||
if (player.isPotionActive(MobEffects.POISON)) MARGIN += 36;
|
||||
@@ -185,7 +183,7 @@ public class ExtraHeartRenderHandler {
|
||||
event.setCanceled(true);
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
mc.mcProfiler.endSection();
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
private void renderExtraHearts(int xBasePos, int yBasePos, EntityPlayer player) {
|
||||
@@ -237,7 +235,7 @@ public class ExtraHeartRenderHandler {
|
||||
if(potion != null) {
|
||||
potionOffset = 9;
|
||||
}
|
||||
if(mc.world.getWorldInfo().isHardcoreModeEnabled()) {
|
||||
if(mc.world.getWorldInfo().isHardcore()) {
|
||||
potionOffset += 27;
|
||||
}
|
||||
return potionOffset;
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
@@ -28,11 +28,11 @@ public class ModelHelper {
|
||||
|
||||
public static TextureAtlasSprite getTextureFromBlock(Block block, int meta) {
|
||||
IBlockState state = block.getStateFromMeta(meta);
|
||||
return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state);
|
||||
return Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state);
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getTextureFromBlockstate(IBlockState state) {
|
||||
return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state);
|
||||
return Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state);
|
||||
}
|
||||
|
||||
public static BakedQuad colorQuad(int color, BakedQuad quad) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -9,10 +9,10 @@ import java.util.Arrays;
|
||||
public class BookHelper {
|
||||
|
||||
public static String getSavedPage(ItemStack item) {
|
||||
if(!item.isEmpty() && item.hasTagCompound()) {
|
||||
NBTTagCompound mantleBook = item.getTagCompound().getCompoundTag("mantle").getCompoundTag("book");
|
||||
if(!item.isEmpty() && item.hasTag()) {
|
||||
NBTTagCompound mantleBook = item.getTag().getCompound("mantle").getCompound("book");
|
||||
|
||||
if(mantleBook.hasKey("page", Arrays.asList(NBTBase.NBT_TYPES).indexOf("STRING"))) {
|
||||
if(mantleBook.contains("page", Arrays.asList(INBTBase.NBT_TYPES).indexOf("STRING"))) {
|
||||
return mantleBook.getString("page");
|
||||
}
|
||||
}
|
||||
@@ -21,20 +21,20 @@ public class BookHelper {
|
||||
}
|
||||
|
||||
public static void writeSavedPage(ItemStack item, String page) {
|
||||
NBTTagCompound compound = item.getTagCompound();
|
||||
NBTTagCompound compound = item.getTag();
|
||||
|
||||
if(compound == null) {
|
||||
compound = new NBTTagCompound();
|
||||
}
|
||||
|
||||
NBTTagCompound mantle = compound.getCompoundTag("mantle");
|
||||
NBTTagCompound book = mantle.getCompoundTag("book");
|
||||
NBTTagCompound mantle = compound.getCompound("mantle");
|
||||
NBTTagCompound book = mantle.getCompound("book");
|
||||
|
||||
book.setString("page", page);
|
||||
book.putString("page", page);
|
||||
|
||||
mantle.setTag("book", book);
|
||||
compound.setTag("mantle", mantle);
|
||||
item.setTagCompound(compound);
|
||||
mantle.put("book", book);
|
||||
compound.put("mantle", mantle);
|
||||
item.setTag(compound);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,31 +3,25 @@ package slimeknights.mantle.client.book;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import slimeknights.mantle.Mantle;
|
||||
import slimeknights.mantle.client.book.action.StringActionProcessor;
|
||||
import slimeknights.mantle.client.book.action.protocol.ProtocolGoToPage;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.book.data.PageData;
|
||||
import slimeknights.mantle.client.book.data.SectionData;
|
||||
import slimeknights.mantle.client.book.data.content.ContentBlank;
|
||||
import slimeknights.mantle.client.book.data.content.ContentBlockInteraction;
|
||||
import slimeknights.mantle.client.book.data.content.ContentCrafting;
|
||||
import slimeknights.mantle.client.book.data.content.ContentError;
|
||||
import slimeknights.mantle.client.book.data.content.ContentImage;
|
||||
import slimeknights.mantle.client.book.data.content.ContentImageText;
|
||||
import slimeknights.mantle.client.book.data.content.ContentSmelting;
|
||||
@@ -43,7 +37,7 @@ import slimeknights.mantle.client.book.repository.BookRepository;
|
||||
import slimeknights.mantle.network.NetworkWrapper;
|
||||
import slimeknights.mantle.network.book.PacketUpdateSavedPage;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class BookLoader implements IResourceManagerReloadListener {
|
||||
|
||||
/** GSON object to be used for book loading purposes */
|
||||
@@ -130,7 +124,7 @@ public class BookLoader implements IResourceManagerReloadListener {
|
||||
public static BookData registerBook(String name, boolean appendIndex, boolean appendContentTable, BookRepository... repositories) {
|
||||
BookData info = new BookData(repositories);
|
||||
|
||||
books.put(name.contains(":") ? name : Loader.instance().activeModContainer().getModId() + ":" + name, info);
|
||||
books.put(name.contains(":") ? name : ModLoadingContext.get().getActiveContainer().getNamespace() + ":" + name, info);
|
||||
|
||||
if(appendIndex) {
|
||||
info.addTransformer(BookTransformer.IndexTranformer());
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Fluids;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.EnumLightType;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.gen.Heightmap.Type;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class StructureBlockAccess implements IBlockAccess {
|
||||
|
||||
public class StructureBlockAccess implements IWorldReader
|
||||
{
|
||||
private final StructureInfo data;
|
||||
private final IBlockState[][][] structure;
|
||||
|
||||
@@ -33,6 +43,11 @@ public class StructureBlockAccess implements IBlockAccess {
|
||||
return 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightFor(EnumLightType type, BlockPos pos) {
|
||||
return 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getBlockState(BlockPos pos) {
|
||||
int x = pos.getX();
|
||||
@@ -68,12 +83,62 @@ public class StructureBlockAccess implements IBlockAccess {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldType getWorldType() {
|
||||
public int getLightSubtracted(BlockPos pos, int amount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeeSky(BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(Type heightmapType, int x, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getClosestPlayer(double x, double y, double z, double distance, Predicate<Entity> predicate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default) {
|
||||
public int getSkylightSubtracted() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldBorder getWorldBorder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkNoEntityCollision(Entity entityIn, VoxelShape shape) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemote() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSeaLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getDimension() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidState getFluidState(BlockPos pos) {
|
||||
return Fluids.EMPTY.getDefaultState();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import slimeknights.mantle.client.book.data.element.BlockData;
|
||||
|
||||
public class StructureInfo {
|
||||
@@ -50,7 +48,7 @@ public class StructureInfo {
|
||||
}
|
||||
|
||||
private IBlockState convert(BlockData data) {
|
||||
Block block = Block.getBlockFromName(data.block);
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(data.block));
|
||||
if(block == null) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
@@ -62,7 +60,7 @@ public class StructureInfo {
|
||||
state = block.getDefaultState();
|
||||
|
||||
for(Map.Entry<String, String> entry : data.state.entrySet()) {
|
||||
Optional<IProperty<?>> property = state.getPropertyKeys().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst();
|
||||
Optional<IProperty<?>> property = state.getProperties().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst();
|
||||
|
||||
if(property.isPresent()) {
|
||||
state = setProperty(state, property.get(), entry.getValue());
|
||||
@@ -73,9 +71,9 @@ public class StructureInfo {
|
||||
}
|
||||
|
||||
private <T extends Comparable<T>> IBlockState setProperty(IBlockState state, IProperty<T> prop, String valueString) {
|
||||
com.google.common.base.Optional<T> value = prop.parseValue(valueString);
|
||||
java.util.Optional<T> value = prop.parseValue(valueString);
|
||||
if(value.isPresent()) {
|
||||
state = state.withProperty(prop, value.get());
|
||||
state = state.with(prop, value.get());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package slimeknights.mantle.client.book.data;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class AppearanceData implements IDataItem {
|
||||
|
||||
public int coverColor = 0x8B4631;
|
||||
|
||||
@@ -4,8 +4,8 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.Mantle;
|
||||
import slimeknights.mantle.client.book.BookLoader;
|
||||
import slimeknights.mantle.client.book.BookTransformer;
|
||||
@@ -23,7 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class BookData implements IDataItem {
|
||||
|
||||
public transient int unnamedSectionCounter = 0;
|
||||
@@ -330,7 +330,7 @@ public class BookData implements IDataItem {
|
||||
|
||||
public String getItemAction(ItemStackData item) {
|
||||
for(ItemStackData.ItemLink link : itemLinks) {
|
||||
if(item.id.equals(link.item.id) && (!link.damageSensitive || item.damage == link.item.damage)) {
|
||||
if(item.id.equals(link.item.id) && (!link.damageSensitive)) {
|
||||
return link.action;
|
||||
}
|
||||
}
|
||||
@@ -360,8 +360,8 @@ public class BookData implements IDataItem {
|
||||
if(!initialized) {
|
||||
load();
|
||||
}
|
||||
if(Minecraft.getMinecraft().player != null) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiBook(this, item));
|
||||
if(Minecraft.getInstance().player != null) {
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiBook(this, item));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package slimeknights.mantle.client.book.data;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface IDataItem {
|
||||
|
||||
void load();
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package slimeknights.mantle.client.book.data;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.BookLoader;
|
||||
import slimeknights.mantle.client.book.data.content.ContentError;
|
||||
import slimeknights.mantle.client.book.data.content.PageContent;
|
||||
@@ -17,7 +17,7 @@ import slimeknights.mantle.client.book.data.element.DataLocation;
|
||||
import slimeknights.mantle.client.book.data.element.ItemStackData;
|
||||
import slimeknights.mantle.client.book.repository.BookRepository;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class PageData implements IDataItem {
|
||||
|
||||
private static final transient ArrayList<ValueHotswap> hotswaps = new ArrayList<>();
|
||||
|
||||
@@ -2,9 +2,9 @@ package slimeknights.mantle.client.book.data;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.BookLoader;
|
||||
import slimeknights.mantle.client.book.data.content.ContentError;
|
||||
import slimeknights.mantle.client.book.data.element.ImageData;
|
||||
@@ -16,7 +16,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class SectionData implements IDataItem {
|
||||
|
||||
public String name = null;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentBlank extends PageContent {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentDummy extends PageContent {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.book.data.element.TextData;
|
||||
import slimeknights.mantle.client.gui.book.GuiBook;
|
||||
import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementText;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentError extends PageContent {
|
||||
|
||||
private String errorStage;
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.book.data.element.ImageData;
|
||||
import slimeknights.mantle.client.gui.book.GuiBook;
|
||||
import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementImage;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentImage extends PageContent {
|
||||
|
||||
public String title = null;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.book.data.element.ImageData;
|
||||
import slimeknights.mantle.client.book.data.element.TextData;
|
||||
@@ -13,7 +12,7 @@ import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementImage;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementText;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentImageText extends PageContent {
|
||||
|
||||
public String title = null;
|
||||
|
||||
@@ -66,20 +66,35 @@ public class ContentSmelting extends PageContent {
|
||||
public NonNullList<ItemStack> getFuelsList() {
|
||||
//TODO ask JEI for fuel list if it is present
|
||||
|
||||
NonNullList<ItemStack> fuels = NonNullList.<ItemStack> withSize(13, ItemStack.EMPTY);
|
||||
fuels.set(0, new ItemStack(Blocks.WOODEN_SLAB));
|
||||
fuels.set(1, new ItemStack(Blocks.PLANKS));
|
||||
fuels.set(2, new ItemStack(Blocks.COAL_BLOCK));
|
||||
fuels.set(3, new ItemStack(Items.WOODEN_PICKAXE));
|
||||
fuels.set(4, new ItemStack(Items.WOODEN_SWORD));
|
||||
fuels.set(5, new ItemStack(Items.WOODEN_HOE));
|
||||
fuels.set(6, new ItemStack(Items.STICK));
|
||||
fuels.set(7, new ItemStack(Items.COAL));
|
||||
fuels.set(8, new ItemStack(Items.LAVA_BUCKET));
|
||||
fuels.set(9, new ItemStack(Blocks.SAPLING));
|
||||
fuels.set(10, new ItemStack(Items.BLAZE_ROD));
|
||||
fuels.set(11, new ItemStack(Items.WOODEN_SHOVEL));
|
||||
fuels.set(12, new ItemStack(Items.WOODEN_AXE));
|
||||
NonNullList<ItemStack> fuels = NonNullList.<ItemStack> withSize(28, ItemStack.EMPTY);
|
||||
fuels.set(0, new ItemStack(Blocks.OAK_SLAB));
|
||||
fuels.set(1, new ItemStack(Blocks.SPRUCE_SLAB));
|
||||
fuels.set(2, new ItemStack(Blocks.BIRCH_SLAB));
|
||||
fuels.set(3, new ItemStack(Blocks.JUNGLE_SLAB));
|
||||
fuels.set(4, new ItemStack(Blocks.ACACIA_SLAB));
|
||||
fuels.set(5, new ItemStack(Blocks.DARK_OAK_SLAB));
|
||||
fuels.set(6, new ItemStack(Blocks.OAK_PLANKS));
|
||||
fuels.set(7, new ItemStack(Blocks.SPRUCE_PLANKS));
|
||||
fuels.set(8, new ItemStack(Blocks.BIRCH_PLANKS));
|
||||
fuels.set(9, new ItemStack(Blocks.JUNGLE_PLANKS));
|
||||
fuels.set(10, new ItemStack(Blocks.ACACIA_PLANKS));
|
||||
fuels.set(11, new ItemStack(Blocks.DARK_OAK_PLANKS));
|
||||
fuels.set(12, new ItemStack(Blocks.COAL_BLOCK));
|
||||
fuels.set(13, new ItemStack(Items.WOODEN_PICKAXE));
|
||||
fuels.set(14, new ItemStack(Items.WOODEN_SWORD));
|
||||
fuels.set(15, new ItemStack(Items.WOODEN_HOE));
|
||||
fuels.set(16, new ItemStack(Items.STICK));
|
||||
fuels.set(17, new ItemStack(Items.COAL));
|
||||
fuels.set(18, new ItemStack(Items.LAVA_BUCKET));
|
||||
fuels.set(19, new ItemStack(Blocks.OAK_SAPLING));
|
||||
fuels.set(20, new ItemStack(Blocks.SPRUCE_SAPLING));
|
||||
fuels.set(21, new ItemStack(Blocks.BIRCH_SAPLING));
|
||||
fuels.set(22, new ItemStack(Blocks.JUNGLE_SAPLING));
|
||||
fuels.set(23, new ItemStack(Blocks.ACACIA_SAPLING));
|
||||
fuels.set(24, new ItemStack(Blocks.DARK_OAK_SAPLING));
|
||||
fuels.set(25, new ItemStack(Items.BLAZE_ROD));
|
||||
fuels.set(26, new ItemStack(Items.WOODEN_SHOVEL));
|
||||
fuels.set(27, new ItemStack(Items.WOODEN_AXE));
|
||||
|
||||
return fuels;
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,8 +32,8 @@ public class ContentTableOfContents extends PageContent {
|
||||
for(int i = 0; i < data.length; i++) {
|
||||
TextData text = data[i];
|
||||
list.add(new ElementText(0, y + i * (int) (Minecraft
|
||||
.getMinecraft().fontRenderer.FONT_HEIGHT * text.scale), GuiBook.PAGE_WIDTH, Minecraft
|
||||
.getMinecraft().fontRenderer.FONT_HEIGHT, new TextData[]{text}));
|
||||
.getInstance().fontRenderer.FONT_HEIGHT * text.scale), GuiBook.PAGE_WIDTH, Minecraft
|
||||
.getInstance().fontRenderer.FONT_HEIGHT, new TextData[]{text}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -11,7 +11,7 @@ import slimeknights.mantle.client.gui.book.GuiBook;
|
||||
import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementText;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentText extends PageContent {
|
||||
|
||||
public String title = null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -13,7 +13,7 @@ import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementImage;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementText;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentTextImage extends PageContent {
|
||||
|
||||
public String title = null;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -13,7 +13,7 @@ import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementImage;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementText;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentTextLeftImage extends PageContent {
|
||||
|
||||
public String title = null;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -13,7 +13,7 @@ import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementImage;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementText;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentTextRightImage extends PageContent {
|
||||
|
||||
public String title;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.book.data.PageData;
|
||||
import slimeknights.mantle.client.book.data.element.TextData;
|
||||
@@ -13,7 +12,7 @@ import slimeknights.mantle.client.gui.book.GuiBook;
|
||||
import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.ElementText;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class PageContent {
|
||||
|
||||
public static final transient int TITLE_HEIGHT = 16;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package slimeknights.mantle.client.book.data.element;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ImageData extends DataLocation {
|
||||
|
||||
public static final ImageData MISSING = new ImageData();
|
||||
|
||||
@@ -2,20 +2,21 @@ package slimeknights.mantle.client.book.data.element;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.command.CommandGive;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.arguments.ItemArgument;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import slimeknights.mantle.client.book.BookLoader;
|
||||
import slimeknights.mantle.client.book.repository.BookRepository;
|
||||
|
||||
@@ -28,7 +29,6 @@ public class ItemStackData {
|
||||
|
||||
public String id = "";
|
||||
public byte amount = 1;
|
||||
public short damage = 0;
|
||||
public JsonObject nbt;
|
||||
|
||||
public NonNullList<ItemStack> getItems() {
|
||||
@@ -56,8 +56,8 @@ public class ItemStackData {
|
||||
Item item;
|
||||
boolean isMissingItem = false;
|
||||
try {
|
||||
item = CommandGive.getItemByText(null, id);
|
||||
} catch(NumberInvalidException e) {
|
||||
item = ItemArgument.getItem(null, id).getItem();
|
||||
} catch(Exception e) {
|
||||
item = Item.getItemFromBlock(Blocks.BARRIER);
|
||||
isMissingItem = true;
|
||||
}
|
||||
@@ -67,22 +67,22 @@ public class ItemStackData {
|
||||
isMissingItem = true;
|
||||
}
|
||||
|
||||
ItemStack itemStack = new ItemStack(item, amount, damage);
|
||||
ItemStack itemStack = new ItemStack(item, amount);
|
||||
|
||||
if(nbt != null) {
|
||||
try {
|
||||
itemStack.setTagCompound(JsonToNBT.getTagFromJson(filterJsonQuotes(nbt.toString())));
|
||||
} catch(NBTException ignored) {
|
||||
itemStack.setTag(JsonToNBT.getTagFromJson(filterJsonQuotes(nbt.toString())));
|
||||
} catch(CommandSyntaxException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if(isMissingItem) {
|
||||
NBTTagCompound display = itemStack.getOrCreateSubCompound("display");
|
||||
display.setString("Name", "\u00A7rUnknown Item");
|
||||
NBTTagCompound display = itemStack.getOrCreateChildTag("display");
|
||||
display.putString("Name", "\u00A7rUnknown Item");
|
||||
NBTTagList lore = new NBTTagList();
|
||||
lore.appendTag(new NBTTagString("\u00A7r\u00A7eItem Name:"));
|
||||
lore.appendTag(new NBTTagString("\u00A7r\u00A7e" + id));
|
||||
display.setTag("Lore", lore);
|
||||
lore.add(new NBTTagString("\u00A7r\u00A7eItem Name:"));
|
||||
lore.add(new NBTTagString("\u00A7r\u00A7e" + id));
|
||||
display.put("Lore", lore);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
@@ -94,11 +94,10 @@ public class ItemStackData {
|
||||
|
||||
public static ItemStackData getItemStackData(ItemStack stack, boolean ignoreNbt) {
|
||||
ItemStackData data = new ItemStackData();
|
||||
data.id = Item.REGISTRY.getNameForObject(stack.getItem()).toString();
|
||||
data.id = ForgeRegistries.ITEMS.getKey(stack.getItem()).toString();
|
||||
data.amount = (byte) stack.getCount();
|
||||
data.damage = (short) stack.getItemDamage();
|
||||
if(!ignoreNbt && stack.getTagCompound() != null) {
|
||||
data.nbt = BookLoader.GSON.toJsonTree(stack.getTagCompound(), NBTTagCompound.class).getAsJsonObject();
|
||||
if(!ignoreNbt && stack.getTag() != null) {
|
||||
data.nbt = BookLoader.GSON.toJsonTree(stack.getTag(), NBTTagCompound.class).getAsJsonObject();
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package slimeknights.mantle.client.book.data.element;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TextData {
|
||||
|
||||
public static final TextData LINEBREAK = new TextData("\n");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.client.book.repository;
|
||||
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.client.book.repository;
|
||||
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.book.repository;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
@@ -38,9 +38,9 @@ public class FileRepository extends BookRepository {
|
||||
if(!path.contains(":")) {
|
||||
String langPath = null;
|
||||
|
||||
if(Minecraft.getMinecraft().getLanguageManager() != null && Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage() != null)
|
||||
if(Minecraft.getInstance().getLanguageManager() != null && Minecraft.getInstance().getLanguageManager().getCurrentLanguage() != null)
|
||||
{
|
||||
langPath = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode();
|
||||
langPath = Minecraft.getInstance().getLanguageManager().getCurrentLanguage().getLanguageCode();
|
||||
}
|
||||
|
||||
String defaultLangPath = "en_US";
|
||||
@@ -77,7 +77,7 @@ public class FileRepository extends BookRepository {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Minecraft.getMinecraft().getResourceManager().getResource(loc);
|
||||
return Minecraft.getInstance().getResourceManager().getResource(loc);
|
||||
} catch(IOException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class FileRepository extends BookRepository {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Minecraft.getMinecraft().getResourceManager().getResource(location);
|
||||
Minecraft.getInstance().getResourceManager().getResource(location);
|
||||
return true;
|
||||
} catch(IOException e) {
|
||||
return false;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package slimeknights.mantle.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
/**
|
||||
* Represents a GUI element INSIDE the graphics file.
|
||||
* The coordinates all refer to the coordinates inside the graphics!
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiElement {
|
||||
|
||||
// this is totally completely ugly but it's a simple solution that doesn't clutter everything too much >_>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package slimeknights.mantle.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiElementScalable extends GuiElement {
|
||||
|
||||
public GuiElementScalable(int x, int y, int w, int h, int texW, int texH) {
|
||||
|
||||
@@ -3,14 +3,14 @@ package slimeknights.mantle.client.gui;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
// a sub-gui. Mostly the same as a separate GuiContainer, but doesn't do the calls that affect the game as if this were the only gui
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class GuiModule extends GuiContainer {
|
||||
|
||||
protected final GuiMultiModule parent;
|
||||
@@ -77,9 +77,9 @@ public abstract class GuiModule extends GuiContainer {
|
||||
mouseY >= this.guiTop && mouseY < this.guiBottom();
|
||||
}
|
||||
|
||||
public boolean isMouseOverFullSlot(int mouseX, int mouseY) {
|
||||
public boolean isMouseOverFullSlot(double mouseX, double mouseY) {
|
||||
for(Slot slot : inventorySlots.inventorySlots) {
|
||||
if(parent.isMouseOverSlot(slot, mouseX, mouseY) && slot.getHasStack()) {
|
||||
if(parent.isSlotSelected(slot, mouseX, mouseY) && slot.getHasStack()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public abstract class GuiModule extends GuiContainer {
|
||||
*
|
||||
* @return True to prevent the main container handling the mouseclick
|
||||
*/
|
||||
public boolean handleMouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
public boolean handleMouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public abstract class GuiModule extends GuiContainer {
|
||||
*
|
||||
* @return True to prevent the main container handling the mouseclick
|
||||
*/
|
||||
public boolean handleMouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
public boolean handleMouseClickMove(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLastClick) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public abstract class GuiModule extends GuiContainer {
|
||||
*
|
||||
* @return True to prevent the main container handling the mouseclick
|
||||
*/
|
||||
public boolean handleMouseReleased(int mouseX, int mouseY, int state) {
|
||||
public boolean handleMouseReleased(double mouseX, double mouseY, int state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,8 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
@@ -24,10 +23,8 @@ import slimeknights.mantle.Mantle;
|
||||
import slimeknights.mantle.inventory.ContainerMultiModule;
|
||||
import slimeknights.mantle.inventory.SlotWrapper;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
||||
// todo: NEI
|
||||
public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiMultiModule extends GuiContainer {
|
||||
|
||||
// NEI-stuff >:(
|
||||
private static Field NEI_Manager;
|
||||
@@ -104,16 +101,16 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
for(GuiModule module : modules) {
|
||||
// set correct state for the module
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(-this.guiLeft, -this.guiTop, 0.0F);
|
||||
GlStateManager.translate(module.guiLeft, module.guiTop, 0.0F);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.translatef(-this.guiLeft, -this.guiTop, 0.0F);
|
||||
GlStateManager.translatef(module.guiLeft, module.guiTop, 0.0F);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
module.handleDrawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawBackground(ResourceLocation background) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, realWidth, realHeight);
|
||||
}
|
||||
@@ -127,7 +124,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
protected void drawPlayerInventoryName() {
|
||||
String localizedName = Minecraft.getMinecraft().player.inventory.getDisplayName().getUnformattedText();
|
||||
String localizedName = Minecraft.getInstance().player.inventory.getDisplayName().getUnformattedComponentText();
|
||||
this.fontRenderer.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040);
|
||||
}
|
||||
|
||||
@@ -160,7 +157,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
int oldX = guiLeft;
|
||||
int oldY = guiTop;
|
||||
@@ -171,7 +168,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
guiTop = cornerY;
|
||||
xSize = realWidth;
|
||||
ySize = realHeight;
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
guiLeft = oldX;
|
||||
guiTop = oldY;
|
||||
@@ -182,7 +179,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
|
||||
// needed to get the correct slot on clicking
|
||||
@Override
|
||||
protected boolean isPointInRegion(int left, int top, int right, int bottom, int pointX, int pointY) {
|
||||
protected boolean isPointInRegion(int left, int top, int right, int bottom, double pointX, double pointY) {
|
||||
pointX -= this.cornerX;
|
||||
pointY -= this.cornerY;
|
||||
return pointX >= left - 1 && pointX < left + right + 1 && pointY >= top - 1 && pointY < top + bottom + 1;
|
||||
@@ -232,7 +229,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY) {
|
||||
public boolean isSlotSelected(Slot slotIn, double mouseX, double mouseY) {
|
||||
GuiModule module = getModuleForSlot(slotIn.slotNumber);
|
||||
|
||||
// mouse inside the module of the slot?
|
||||
@@ -247,46 +244,46 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return super.isMouseOverSlot(slotIn, mouseX, mouseY);
|
||||
return super.isSlotSelected(slotIn, mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||
GuiModule module = getModuleForPoint(mouseX, mouseY);
|
||||
if(module != null) {
|
||||
if(module.handleMouseClicked(mouseX, mouseY, mouseButton)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLastClick, double unkowwn) {
|
||||
GuiModule module = getModuleForPoint(mouseX, mouseY);
|
||||
if(module != null) {
|
||||
if(module.handleMouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
return super.mouseDragged(mouseX, mouseY, clickedMouseButton, timeSinceLastClick, unkowwn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int state) {
|
||||
GuiModule module = getModuleForPoint(mouseX, mouseY);
|
||||
if(module != null) {
|
||||
if(module.handleMouseReleased(mouseX, mouseY, state)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
return super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
protected GuiModule getModuleForPoint(int x, int y) {
|
||||
protected GuiModule getModuleForPoint(double x, double y) {
|
||||
for(GuiModule module : modules) {
|
||||
if(this.isPointInRegion(module.guiLeft, module.guiTop, module.guiRight(), module.guiBottom(),
|
||||
x + this.cornerX, y + this.cornerY)) {
|
||||
@@ -314,60 +311,4 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
protected ContainerMultiModule getContainer() {
|
||||
return (ContainerMultiModule) inventorySlots;
|
||||
}
|
||||
|
||||
/* NEI INTEGRATION */
|
||||
// todo: NEI
|
||||
/*
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public VisiblityData modifyVisiblity(GuiContainer guiContainer, VisiblityData visiblityData) {
|
||||
int x = LayoutManager.stateButtons[0].x + LayoutManager.stateButtons[0].w;
|
||||
int x2 = LayoutManager.timeButtons[3].x + LayoutManager.timeButtons[3].w;
|
||||
int y2 = LayoutManager.heal.y + LayoutManager.heal.h;
|
||||
|
||||
|
||||
for(GuiModule module : modules) {
|
||||
if(x > module.guiLeft) {
|
||||
visiblityData.showStateButtons = false;
|
||||
}
|
||||
if(x2 > module.guiLeft && y2 > module.guiTop) {
|
||||
visiblityData.showUtilityButtons = false;
|
||||
}
|
||||
}
|
||||
|
||||
return visiblityData;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer guiContainer, ItemStack itemStack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer guiContainer) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public boolean handleDragNDrop(GuiContainer guiContainer, int x, int y, ItemStack itemStack, int k) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public boolean hideItemPanelSlot(GuiContainer guiContainer, int x, int y, int w, int h) {
|
||||
for(GuiModule module : modules) {
|
||||
// check if the panel overlaps the module (check totally not stolen from stackoverflow)
|
||||
if(module.guiLeft < x + w && module.guiRight() > x &&
|
||||
module.guiTop < y + h && module.guiBottom() > y) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package slimeknights.mantle.client.gui;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class GuiWidget {
|
||||
|
||||
public int xPos;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package slimeknights.mantle.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
// a vertical slider!
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiWidgetSlider extends GuiWidget {
|
||||
|
||||
// gui info
|
||||
@@ -149,7 +149,7 @@ public class GuiWidgetSlider extends GuiWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean mouseDown = Mouse.isButtonDown(0); // left mouse button
|
||||
boolean mouseDown = Minecraft.getInstance().mouseHelper.isLeftDown(); // left mouse button
|
||||
int wheel = Mouse.getDWheel();
|
||||
|
||||
if(useMouseWheel) {
|
||||
|
||||
@@ -4,18 +4,16 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiWidgetTabs extends GuiWidget {
|
||||
|
||||
private static final ResourceLocation
|
||||
@@ -61,7 +59,7 @@ public class GuiWidgetTabs extends GuiWidget {
|
||||
}
|
||||
|
||||
public void update(int mouseX, int mouseY) {
|
||||
boolean mouseDown = Mouse.isButtonDown(0); // left mouse button
|
||||
boolean mouseDown = Minecraft.getInstance().mouseHelper.isLeftDown(); // left mouse button
|
||||
|
||||
// did we click on a tab?
|
||||
mouseX -= this.xPos;
|
||||
@@ -142,7 +140,7 @@ public class GuiWidgetTabs extends GuiWidget {
|
||||
// todo: draw all the tabs first and then all the itemstacks so it doesn't have to switch texture in between all the time
|
||||
|
||||
// rebind texture from drawing an itemstack
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(tabsResource);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(tabsResource);
|
||||
actualTab.draw(x, y);
|
||||
|
||||
|
||||
@@ -158,8 +156,8 @@ public class GuiWidgetTabs extends GuiWidget {
|
||||
|
||||
// guiContainer.drawItemStack
|
||||
private void drawItemStack(ItemStack stack, int x, int y) {
|
||||
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
|
||||
GlStateManager.translate(0.0F, 0.0F, 32.0F);
|
||||
ItemRenderer itemRender = Minecraft.getInstance().getItemRenderer();
|
||||
GlStateManager.translatef(0.0F, 0.0F, 32.0F);
|
||||
itemRender.zLevel = 200;
|
||||
//FontRenderer font = stack.getItem().getFontRenderer(stack);
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.CPacketClientStatus;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
@@ -43,7 +43,7 @@ import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import static slimeknights.mantle.client.gui.book.Textures.TEX_BOOK;
|
||||
import static slimeknights.mantle.client.gui.book.Textures.TEX_BOOKFRONT;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiBook extends GuiScreen {
|
||||
|
||||
public static boolean debug = false;
|
||||
@@ -90,7 +90,7 @@ public class GuiBook extends GuiScreen {
|
||||
this.book = book;
|
||||
this.item = item;
|
||||
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.mc = Minecraft.getInstance();
|
||||
this.fontRenderer = mc.fontRenderer;
|
||||
init();
|
||||
|
||||
@@ -102,9 +102,9 @@ public class GuiBook extends GuiScreen {
|
||||
|
||||
public void drawerTransform(boolean rightSide) {
|
||||
if(rightSide) {
|
||||
GlStateManager.translate(width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN, height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0);
|
||||
GlStateManager.translatef(width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN, height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0);
|
||||
} else {
|
||||
GlStateManager.translate(width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN, height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0);
|
||||
GlStateManager.translatef(width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN, height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class GuiBook extends GuiScreen {
|
||||
fontRenderer.drawString("DEBUG", 2, 2, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
// The books are unreadable at Gui Scale set to small, so we'll double the scale
|
||||
@@ -176,21 +176,21 @@ public class GuiBook extends GuiScreen {
|
||||
}
|
||||
*/
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
GlStateManager.color3f(1F, 1F, 1F);
|
||||
|
||||
float coverR = ((book.appearance.coverColor >> 16) & 0xff) / 255.F;
|
||||
float coverG = ((book.appearance.coverColor >> 8) & 0xff) / 255.F;
|
||||
float coverB = (book.appearance.coverColor & 0xff) / 255.F;
|
||||
|
||||
TextureManager render = this.mc.renderEngine;
|
||||
TextureManager render = this.mc.textureManager;
|
||||
|
||||
if(page == -1) {
|
||||
render.bindTexture(TEX_BOOKFRONT);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GlStateManager.color(coverR, coverG, coverB);
|
||||
GlStateManager.color3f(coverR, coverG, coverB);
|
||||
drawModalRectWithCustomSizedTexture(width / 2 - PAGE_WIDTH_UNSCALED / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
GlStateManager.color3f(1F, 1F, 1F);
|
||||
|
||||
if(!book.appearance.title.isEmpty()) {
|
||||
drawModalRectWithCustomSizedTexture(width / 2 - PAGE_WIDTH_UNSCALED / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
|
||||
@@ -32,25 +32,26 @@ public class GuiBookmark extends GuiButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
if(visible) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
int tex_y = TEX_Y + HEIGHT * type;
|
||||
|
||||
mc.renderEngine.bindTexture(TEX_BOOK);
|
||||
minecraft.textureManager.bindTexture(TEX_BOOK);
|
||||
|
||||
float r = ((data.color >> 16) & 0xff) / 255.F;
|
||||
float g = ((data.color >> 8) & 0xff) / 255.F;
|
||||
float b = (data.color & 0xff) / 255.F;
|
||||
|
||||
GlStateManager.color(r, g, b);
|
||||
GlStateManager.color3f(r, g, b);
|
||||
Gui.drawScaledCustomSizeModalRect(x, y, TEX_X, tex_y, WIDTH, HEIGHT, width, height, 512, 512);
|
||||
|
||||
if(data.text != null && !data.text.isEmpty()) {
|
||||
TextDataRenderer
|
||||
.drawScaledString(mc.fontRenderer, data.text, x + 1, y + height / 2 - mc.fontRenderer.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE);
|
||||
.drawScaledString(minecraft.fontRenderer, data.text, x + 1, y + height / 2 - minecraft.fontRenderer.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE);
|
||||
}
|
||||
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
GlStateManager.color3f(1F, 1F, 1F);
|
||||
|
||||
if(data.page.equals("ADD")) {
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width / 2 - ADD_W / 2, y + height / 2 - ADD_H / 2, ADD_X, ADD_Y, ADD_W, ADD_H, 512, 512);
|
||||
|
||||
@@ -8,9 +8,9 @@ import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import slimeknights.mantle.Mantle;
|
||||
import slimeknights.mantle.client.book.data.element.TextData;
|
||||
@@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TextDataRenderer {
|
||||
/**
|
||||
* @deprecated Call drawText with tooltip param and then call drawTooltip separately on the tooltip layer to prevent overlap
|
||||
@@ -149,7 +149,14 @@ public class TextDataRenderer {
|
||||
}
|
||||
|
||||
if(atY >= y + boxHeight) {
|
||||
fr.drawString("...", atX, atY, 0, item.dropshadow);
|
||||
if(item.dropshadow)
|
||||
{
|
||||
fr.drawStringWithShadow("...", atX, atY, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fr.drawString("...", atX, atY, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
y = atY;
|
||||
@@ -222,9 +229,16 @@ public class TextDataRenderer {
|
||||
|
||||
public static void drawScaledString(FontRenderer font, String text, float x, float y, int color, boolean dropShadow, float scale) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x, y, 0);
|
||||
GlStateManager.scale(scale, scale, 1F);
|
||||
font.drawString(text, 0, 0, color, dropShadow);
|
||||
GlStateManager.translatef(x, y, 0);
|
||||
GlStateManager.scalef(scale, scale, 1F);
|
||||
if(dropShadow)
|
||||
{
|
||||
font.drawStringWithShadow(text, 0, 0, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
font.drawString(text, 0, 0, color);
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@@ -238,8 +252,8 @@ public class TextDataRenderer {
|
||||
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (endColor & 255) / 255.0F;
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.blendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.shadeModel(7425);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder vertexBuffer = tessellator.getBuffer();
|
||||
@@ -250,7 +264,7 @@ public class TextDataRenderer {
|
||||
vertexBuffer.pos((double) right, (double) bottom, 0D).color(f5, f6, f7, f4).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
//END METHODS FROM GUI
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
@@ -8,22 +9,23 @@ import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import slimeknights.mantle.client.gui.book.GuiBook;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class BookElement extends Gui {
|
||||
|
||||
public GuiBook parent;
|
||||
|
||||
protected Minecraft mc = Minecraft.getMinecraft();
|
||||
protected TextureManager renderEngine = mc.renderEngine;
|
||||
protected Minecraft mc = Minecraft.getInstance();
|
||||
protected TextureManager renderEngine = mc.textureManager;
|
||||
|
||||
public int x, y;
|
||||
|
||||
@@ -55,13 +57,14 @@ public abstract class BookElement extends Gui {
|
||||
|
||||
public void renderToolTip(FontRenderer fontRenderer, ItemStack stack, int x, int y) {
|
||||
if(stack != null) {
|
||||
List<String> list = stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
|
||||
|
||||
List<ITextComponent> list = stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
|
||||
List<String> list1 = Lists.<String>newArrayList();
|
||||
|
||||
for(int i = 0; i < list.size(); ++i) {
|
||||
if(i == 0) {
|
||||
list.set(i, stack.getRarity().rarityColor + list.get(i));
|
||||
list1.set(i, stack.getRarity().color + list.get(i).deepCopy().getFormattedText());
|
||||
} else {
|
||||
list.set(i, TextFormatting.GRAY + list.get(i));
|
||||
list1.set(i, TextFormatting.GRAY + list.get(i).deepCopy().getFormattedText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +72,7 @@ public abstract class BookElement extends Gui {
|
||||
if(font == null) {
|
||||
font = fontRenderer;
|
||||
}
|
||||
GuiUtils.drawHoveringText(list, x, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT, -1, font);
|
||||
GuiUtils.drawHoveringText(list1, x, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT, -1, font);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
}
|
||||
@@ -77,7 +80,7 @@ public abstract class BookElement extends Gui {
|
||||
@Deprecated
|
||||
public void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font) {
|
||||
if(!textLines.isEmpty()) {
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.disableDepthTest();
|
||||
int i = 0;
|
||||
|
||||
for(String s : textLines) {
|
||||
@@ -128,7 +131,7 @@ public abstract class BookElement extends Gui {
|
||||
i2 += 10;
|
||||
}
|
||||
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.enableDepthTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package slimeknights.mantle.client.gui.book.element;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import slimeknights.mantle.client.book.data.element.ImageData;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ElementImage extends SizedBookElement {
|
||||
|
||||
public ImageData image;
|
||||
@@ -60,7 +60,7 @@ public class ElementImage extends SizedBookElement {
|
||||
float g = ((colorMultiplier >> 8) & 0xff) / 255.F;
|
||||
float b = (colorMultiplier & 0xff) / 255.F;
|
||||
|
||||
GlStateManager.color(r, g, b);
|
||||
GlStateManager.color3f(r, g, b);
|
||||
|
||||
if(image.item == null) {
|
||||
renderEngine.bindTexture(image.location);
|
||||
@@ -68,9 +68,9 @@ public class ElementImage extends SizedBookElement {
|
||||
drawScaledCustomSizeModalRect(x, y, image.u, image.v, image.uw, image.vh, width, height, image.texWidth, image.texHeight);
|
||||
} else {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(width, height, 1F);
|
||||
GlStateManager.scalef(width, height, 1F);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(image.item.getItems().get(0), x, y);
|
||||
mc.getItemRenderer().renderItemAndEffectIntoGUI(image.item.getItems().get(0), x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import slimeknights.mantle.client.book.action.StringActionProcessor;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ElementItem extends SizedBookElement {
|
||||
|
||||
public static final int ITEM_SIZE_HARDCODED = 16;
|
||||
@@ -84,11 +84,11 @@ public class ElementItem extends SizedBookElement {
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x, y, 0);
|
||||
GlStateManager.scale(scale, scale, 1.0F);
|
||||
GlStateManager.translatef(x, y, 0);
|
||||
GlStateManager.scalef(scale, scale, 1.0F);
|
||||
|
||||
if(currentItem < itemCycle.size()) {
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(itemCycle.get(currentItem), 0, 0);
|
||||
mc.getItemRenderer().renderItemAndEffectIntoGUI(itemCycle.get(currentItem), 0, 0);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -37,12 +37,12 @@ public class ElementSection extends SizedBookElement {
|
||||
drawRect(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, parent.book.appearance.hoverColor);
|
||||
}
|
||||
if(unlocked) {
|
||||
GlStateManager.color(1F, 1F, 1F, hover ? 1F : 0.5F);
|
||||
GlStateManager.color4f(1F, 1F, 1F, hover ? 1F : 0.5F);
|
||||
} else {
|
||||
float r = ((parent.book.appearance.lockedSectionColor >> 16) & 0xff) / 255.F;
|
||||
float g = ((parent.book.appearance.lockedSectionColor >> 8) & 0xff) / 255.F;
|
||||
float b = (parent.book.appearance.lockedSectionColor & 0xff) / 255.F;
|
||||
GlStateManager.color(r, g, b, 0.75F);
|
||||
GlStateManager.color4f(r, g, b, 0.75F);
|
||||
}
|
||||
|
||||
if(section.icon.item == null) {
|
||||
@@ -53,10 +53,10 @@ public class ElementSection extends SizedBookElement {
|
||||
}
|
||||
} else {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(iconX, iconY, 0);
|
||||
GlStateManager.scale(2F, 2F, 1F);
|
||||
GlStateManager.translatef(iconX, iconY, 0);
|
||||
GlStateManager.scalef(2F, 2F, 1F);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(section.icon.item.getItems().get(0), 0, 0);
|
||||
mc.getItemRenderer().renderItemAndEffectIntoGUI(section.icon.item.getItems().get(0), 0, 0);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import slimeknights.mantle.client.book.StructureBlockAccess;
|
||||
import slimeknights.mantle.client.book.StructureInfo;
|
||||
@@ -150,7 +148,7 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) {
|
||||
if(lastClick != null) {
|
||||
if(Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
|
||||
if(Minecraft.getInstance().mouseHelper.isLeftDown() || Minecraft.getInstance().mouseHelper.isRightDown()) {
|
||||
int dx = mouseX - lastClick[0];
|
||||
int dy = mouseY - lastClick[1];
|
||||
float maxSpeed = 10f;
|
||||
@@ -195,18 +193,18 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa
|
||||
int i = 0;
|
||||
ItemStack highlighted = null;
|
||||
|
||||
final BlockRendererDispatcher blockRender = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||
final BlockRendererDispatcher blockRender = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
|
||||
float f = (float) Math.sqrt(structureHeight * structureHeight + structureWidth * structureWidth + structureLength * structureLength);
|
||||
yOffTotal = 10 + Math.max(10 + (structureHeight > 1 ? 36 : 0), (int) (f * scale));
|
||||
//GlStateManager.translate(x + 60, y + 10 + f / 2 * scale, Math.max(structureHeight, Math.max(structureWidth, structureLength)));
|
||||
GlStateManager.translate(xTranslate, yTranslate, Math.max(structureHeight, Math.max(structureWidth, structureLength)));
|
||||
GlStateManager.translatef(xTranslate, yTranslate, Math.max(structureHeight, Math.max(structureWidth, structureLength)));
|
||||
// todo: translate where it actually needs to be and to counter z-layer of the book
|
||||
GlStateManager.scale(scale, -scale, 1);
|
||||
GlStateManager.rotate(rotX, 1, 0, 0);
|
||||
GlStateManager.rotate(rotY, 0, 1, 0);
|
||||
GlStateManager.scalef(scale, -scale, 1);
|
||||
GlStateManager.rotatef(rotX, 1, 0, 0);
|
||||
GlStateManager.rotatef(rotY, 0, 1, 0);
|
||||
|
||||
GlStateManager.translate((float)structureLength/-2f, (float)structureHeight/-2f, (float)structureWidth/-2f);
|
||||
GlStateManager.translatef((float)structureLength/-2f, (float)structureHeight/-2f, (float)structureWidth/-2f);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
@@ -232,7 +230,8 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
blockRender.renderBlock(state, pos, blockAccess, buffer);
|
||||
Random random = new Random();
|
||||
blockRender.renderBlock(state, pos, blockAccess, buffer, random);
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.action.StringActionProcessor;
|
||||
import slimeknights.mantle.client.book.data.element.TextData;
|
||||
import slimeknights.mantle.client.gui.book.TextDataRenderer;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ElementText extends SizedBookElement {
|
||||
public TextData[] text;
|
||||
private List<String> tooltip = new ArrayList<String>();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class SizedBookElement extends BookElement {
|
||||
|
||||
public int width, height;
|
||||
|
||||
@@ -5,13 +5,15 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Groups multiple baked models into a single one. Does not respect state etc. when getting quads.
|
||||
@@ -29,7 +31,7 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
return parts.get(Optional.fromNullable(side));
|
||||
}
|
||||
|
||||
@@ -44,14 +46,14 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(IBakedModel model, IBlockState state, long rand) {
|
||||
public void add(IBakedModel model, IBlockState state, Random rand) {
|
||||
add(model, state, null, rand);
|
||||
for(EnumFacing side : EnumFacing.values()) {
|
||||
add(model, state, side, rand);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(IBakedModel model, IBlockState state, EnumFacing side, long rand) {
|
||||
public void add(IBakedModel model, IBlockState state, EnumFacing side, Random rand) {
|
||||
int index;
|
||||
if(side == null) {
|
||||
index = 6;
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
@@ -16,8 +16,10 @@ import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
public class BakedSimple implements IBakedModel {
|
||||
@@ -62,7 +64,7 @@ public class BakedSimple implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
return quads;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package slimeknights.mantle.client.model;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
@@ -15,8 +15,10 @@ import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
public class BakedWrapper implements IBakedModel {
|
||||
@@ -29,7 +31,7 @@ public class BakedWrapper implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
return parent.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
package slimeknights.mantle.client.model;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import slimeknights.mantle.client.ModelHelper;
|
||||
@@ -33,10 +35,10 @@ public class BlockItemModelWrapper implements IBakedModel {
|
||||
Matrix4f matrix = null;
|
||||
// fix transformation in hand
|
||||
if(cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND) {
|
||||
matrix = ModelHelper.BLOCK_THIRD_PERSON_RIGHT.getMatrix();
|
||||
matrix = ModelHelper.BLOCK_THIRD_PERSON_RIGHT.getMatrixVec();
|
||||
}
|
||||
else if(cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND) {
|
||||
matrix = ModelHelper.BLOCK_THIRD_PERSON_LEFT.getMatrix();
|
||||
matrix = ModelHelper.BLOCK_THIRD_PERSON_LEFT.getMatrixVec();
|
||||
}
|
||||
|
||||
return Pair.of(this, matrix);
|
||||
@@ -44,7 +46,7 @@ public class BlockItemModelWrapper implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
return parent.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
@@ -78,6 +80,6 @@ public class BlockItemModelWrapper implements IBakedModel {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return ItemOverrideList.NONE;
|
||||
return ItemOverrideList.EMPTY;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package slimeknights.mantle.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
@@ -20,6 +19,7 @@ import net.minecraftforge.client.model.pipeline.VertexTransformer;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix3f;
|
||||
@@ -71,7 +71,7 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, Random rand) {
|
||||
// transform quads obtained from parent
|
||||
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
@@ -80,7 +80,7 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
try {
|
||||
// adjust side to facing-rotation
|
||||
if(side != null && side.getHorizontalIndex() > -1) {
|
||||
side = EnumFacing.getHorizontal((side.getHorizontalIndex() + faceOffset) % 4);
|
||||
side = EnumFacing.byHorizontalIndex((side.getHorizontalIndex() + faceOffset) % 4);
|
||||
}
|
||||
for(BakedQuad quad : original.getQuads(state, side, rand)) {
|
||||
Transformer transformer = new Transformer(transformation, quad.getFormat());
|
||||
@@ -133,15 +133,15 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
private final TRSRBakedModel model;
|
||||
|
||||
public TRSROverride(TRSRBakedModel model) {
|
||||
super(ImmutableList.<ItemOverride>of());
|
||||
super(null, null, null,ImmutableList.<ItemOverride>of());
|
||||
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull EntityLivingBase entity) {
|
||||
IBakedModel baked = model.original.getOverrides().handleItemState(originalModel, stack, world, entity);
|
||||
public IBakedModel getModelWithOverrides(@Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull EntityLivingBase entity) {
|
||||
IBakedModel baked = model.original.getOverrides().getModelWithOverrides(originalModel, stack, world, entity);
|
||||
|
||||
return new TRSRBakedModel(baked, model.transformation);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
public Transformer(TRSRTransformation transformation, VertexFormat format) {
|
||||
super(new UnpackedBakedQuad.Builder(format));
|
||||
// position transform
|
||||
this.transformation = transformation.getMatrix();
|
||||
this.transformation = transformation.getMatrixVec();
|
||||
// normal transform
|
||||
this.normalTransformation = new Matrix3f();
|
||||
this.transformation.getRotationScale(this.normalTransformation);
|
||||
|
||||
@@ -5,8 +5,8 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
/**
|
||||
* Used in conjunction with GuiHandler. Implement in a TE to have it open its GUI/Container.
|
||||
@@ -15,6 +15,6 @@ public interface IInventoryGui {
|
||||
|
||||
Container createContainer(InventoryPlayer inventoryplayer, World world, BlockPos pos);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
GuiContainer createGui(InventoryPlayer inventoryplayer, World world, BlockPos pos);
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.INameable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
@@ -127,7 +128,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
}
|
||||
|
||||
public String getInventoryDisplayName() {
|
||||
IWorldNameable nameable = null;
|
||||
INameable nameable = null;
|
||||
if (itemHandler instanceof InvWrapper) {
|
||||
nameable = ((InvWrapper) itemHandler).getInv();
|
||||
// if the inventory doesn't have a name fall back to checking the tileentity
|
||||
@@ -135,12 +136,12 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
nameable = null;
|
||||
}
|
||||
}
|
||||
if(nameable == null && tile instanceof IWorldNameable) {
|
||||
nameable = (IWorldNameable) tile;
|
||||
if(nameable == null && tile instanceof INameable) {
|
||||
nameable = (INameable) tile;
|
||||
}
|
||||
if (nameable != null) {
|
||||
ITextComponent textName = nameable.getDisplayName();
|
||||
return textName != null ? textName.getFormattedText() : nameable.getName();
|
||||
return textName != null ? textName.getFormattedText() : nameable.getName().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -164,14 +165,14 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
|
||||
for(int row = 0; row < 3; row++) {
|
||||
for(int col = 0; col < 9; col++) {
|
||||
this.addSlotToContainer(new Slot(playerInventory, index, xCorner + col * 18, yCorner + row * 18));
|
||||
this.addSlot(new Slot(playerInventory, index, xCorner + col * 18, yCorner + row * 18));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
index = 0;
|
||||
for(int col = 0; col < 9; col++) {
|
||||
this.addSlotToContainer(new Slot(playerInventory, index, xCorner + col * 18, yCorner + 58));
|
||||
this.addSlot(new Slot(playerInventory, index, xCorner + col * 18, yCorner + 58));
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -180,11 +181,11 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected Slot addSlotToContainer(Slot slotIn) {
|
||||
protected Slot addSlot(Slot slotIn) {
|
||||
if(playerInventoryStart >= 0) {
|
||||
throw new SlimeknightException("BaseContainer: Player inventory has to be last slots. Add all slots before adding the player inventory.");
|
||||
}
|
||||
return super.addSlotToContainer(slotIn);
|
||||
return super.addSlot(slotIn);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -261,7 +262,6 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
|
||||
if(!itemstack1.isEmpty()
|
||||
&& itemstack1.getItem() == stack.getItem()
|
||||
&& (!stack.getHasSubtypes() || stack.getMetadata() == itemstack1.getMetadata())
|
||||
&& ItemStack.areItemStackTagsEqual(stack, itemstack1)
|
||||
&& this.canMergeSlot(stack, slot)) {
|
||||
int l = itemstack1.getCount() + stack.getCount();
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
int begin = inventorySlots.size();
|
||||
for(Object slot : subcontainer.inventorySlots) {
|
||||
SlotWrapper wrapper = new SlotWrapper((Slot) slot);
|
||||
addSlotToContainer(wrapper);
|
||||
addSlot(wrapper);
|
||||
slotContainerMap.put(wrapper.slotNumber, subcontainer);
|
||||
}
|
||||
int end = inventorySlots.size();
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ContainerSimpleChest extends BaseContainer<TileInventory> {
|
||||
break;
|
||||
}
|
||||
|
||||
this.addSlotToContainer(createSlot(tile, index, 8 + j * 18, 18 + i * 18));
|
||||
this.addSlot(createSlot(tile, index, 8 + j * 18, 18 + i * 18));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SlotCraftingCustom extends SlotCrafting {
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack onTake(EntityPlayer playerIn, @Nonnull ItemStack stack) {
|
||||
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
|
||||
net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, craftMatrix);
|
||||
this.onCrafting(stack);
|
||||
|
||||
callback.onCrafting(playerIn, stack, craftMatrix);
|
||||
|
||||
@@ -6,8 +6,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SlotWrapper extends Slot {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public String getSlotTexture() {
|
||||
return parent.getSlotTexture();
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class SlotWrapper extends Slot {
|
||||
parent.setBackgroundLocation(texture);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return parent.isEnabled();
|
||||
|
||||
@@ -2,25 +2,29 @@ package slimeknights.mantle.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.IArmorMaterial;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class ItemArmorTooltip extends ItemArmor {
|
||||
|
||||
public ItemArmorTooltip(ArmorMaterial armorMaterial, int renderIndex, EntityEquipmentSlot equipmentSlot) {
|
||||
super(armorMaterial, renderIndex, equipmentSlot);
|
||||
public ItemArmorTooltip(IArmorMaterial armorMaterial, EntityEquipmentSlot equipmentSlot, Item.Properties builder) {
|
||||
super(armorMaterial, equipmentSlot, builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||
ItemTooltip.addOptionalTooltip(stack, tooltip);
|
||||
super.addInformation(stack, worldIn, tooltip, flagIn);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import slimeknights.mantle.tileentity.MantleTileEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -20,6 +21,10 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
Block masterBlock;
|
||||
IBlockState state;
|
||||
|
||||
public MultiServantLogic(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
@@ -103,37 +108,37 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
public void readCustomNBT(NBTTagCompound tags) {
|
||||
this.hasMaster = tags.getBoolean("hasMaster");
|
||||
if(this.hasMaster) {
|
||||
int xCenter = tags.getInteger("xCenter");
|
||||
int yCenter = tags.getInteger("yCenter");
|
||||
int zCenter = tags.getInteger("zCenter");
|
||||
int xCenter = tags.getInt("xCenter");
|
||||
int yCenter = tags.getInt("yCenter");
|
||||
int zCenter = tags.getInt("zCenter");
|
||||
this.master = new BlockPos(xCenter, yCenter, zCenter);
|
||||
this.masterBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tags.getString("MasterBlockName")));
|
||||
this.state = Block.getStateById(tags.getInteger("masterState"));
|
||||
this.state = Block.getStateById(tags.getInt("masterState"));
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeCustomNBT(NBTTagCompound tags) {
|
||||
tags.setBoolean("hasMaster", this.hasMaster);
|
||||
tags.putBoolean("hasMaster", this.hasMaster);
|
||||
if(this.hasMaster) {
|
||||
tags.setInteger("xCenter", this.master.getX());
|
||||
tags.setInteger("yCenter", this.master.getY());
|
||||
tags.setInteger("zCenter", this.master.getZ());
|
||||
tags.setString("MasterBlockName", ForgeRegistries.BLOCKS.getKey(this.masterBlock).toString());
|
||||
tags.setInteger("masterState", Block.getStateId(this.state));
|
||||
tags.putInt("xCenter", this.master.getX());
|
||||
tags.putInt("yCenter", this.master.getY());
|
||||
tags.putInt("zCenter", this.master.getZ());
|
||||
tags.putString("MasterBlockName", ForgeRegistries.BLOCKS.getKey(this.masterBlock).toString());
|
||||
tags.putInt("masterState", Block.getStateId(this.state));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
public void read(NBTTagCompound tags) {
|
||||
super.read(tags);
|
||||
this.readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tags) {
|
||||
tags = super.writeToNBT(tags);
|
||||
public NBTTagCompound write(NBTTagCompound tags) {
|
||||
tags = super.write(tags);
|
||||
return this.writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class PropertyUnlistedDirection extends PropertyDirection implements IUnlistedProperty<EnumFacing> {
|
||||
public class PropertyUnlistedDirection extends DirectionProperty implements IUnlistedProperty<EnumFacing> {
|
||||
|
||||
public PropertyUnlistedDirection(String name, Collection<EnumFacing> values) {
|
||||
super(name, values);
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package slimeknights.mantle.pulsar.control;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLModContainer;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
import net.minecraftforge.eventbus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.CrashReportExtender;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLModContainer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -53,7 +54,7 @@ public class PulseManager {
|
||||
private static final Map<String, Map<Object, PulseMeta>> ALL_PULSES = new HashMap<>();
|
||||
private final Map<Object, PulseMeta> pulses = new LinkedHashMap<>();
|
||||
// Use the Google @Subscribe to avoid confusion/breaking changes.
|
||||
private final Flightpath flightpath = new Flightpath(new AnnotationLocator(Subscribe.class));
|
||||
private final Flightpath flightpath = new Flightpath(new AnnotationLocator(SubscribeEvent.class));
|
||||
|
||||
private boolean blockNewRegistrations = false;
|
||||
private boolean configLoaded = false;
|
||||
@@ -91,11 +92,11 @@ public class PulseManager {
|
||||
* Shared initialiser code between all the constructors.
|
||||
*/
|
||||
private void init() {
|
||||
String modId = Loader.instance().activeModContainer().getModId();
|
||||
String modId = ModLoadingContext.get().getActiveContainer().getNamespace();
|
||||
this.id = modId;
|
||||
log = LogManager.getLogger("Pulsar-" + modId);
|
||||
flightpath.setExceptionHandler(new BusExceptionHandler(modId));
|
||||
FMLCommonHandler.instance().registerCrashCallable(new CrashHandler(modId, this));
|
||||
CrashReportExtender.registerCrashCallable(new CrashHandler(modId, this));
|
||||
// regsister our pulse loader so it can be found by the static method
|
||||
ALL_PULSES.put(modId, pulses);
|
||||
// Attach us to the mods FML bus
|
||||
@@ -148,7 +149,7 @@ public class PulseManager {
|
||||
if (!deps.equals("")) {
|
||||
String[] parsedDeps = deps.split(";");
|
||||
for (String s : parsedDeps) {
|
||||
if (!Loader.isModLoaded(s)) {
|
||||
if (!ModList.get().isLoaded(s)) {
|
||||
log.info("Skipping Pulse " + id + "; missing dependency: " + s);
|
||||
missingDeps = true;
|
||||
enabled = false;
|
||||
@@ -164,8 +165,6 @@ public class PulseManager {
|
||||
if (meta.isEnabled()) {
|
||||
pulses.put(pulse, meta);
|
||||
flightpath.register(pulse);
|
||||
// Work around to catch the new registry events added from the registry rewrite.
|
||||
MinecraftForge.EVENT_BUS.register(pulse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +174,7 @@ public class PulseManager {
|
||||
* @param obj Object to register.
|
||||
*/
|
||||
private void attachToContainerEventBus(Object obj) {
|
||||
ModContainer cnt = Loader.instance().activeModContainer();
|
||||
ModContainer cnt = ModLoadingContext.get().getActiveContainer();
|
||||
log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]");
|
||||
try {
|
||||
FMLModContainer mc = (FMLModContainer)cnt;
|
||||
@@ -203,9 +202,9 @@ public class PulseManager {
|
||||
*
|
||||
* @param evt An event object.
|
||||
*/
|
||||
@Subscribe
|
||||
public void propagateEvent(Object evt) {
|
||||
if (evt instanceof FMLPreInitializationEvent) preInit((FMLPreInitializationEvent) evt);
|
||||
@SubscribeEvent
|
||||
public void propagateEvent(Event evt) {
|
||||
if (evt instanceof FMLCommonSetupEvent) preInit((FMLCommonSetupEvent) evt);
|
||||
// We use individual buses due to the EventBus class using a Set rather than a List, thus losing the ordering.
|
||||
// This trick is shamelessly borrowed from FML.
|
||||
flightpath.post(evt);
|
||||
@@ -217,7 +216,7 @@ public class PulseManager {
|
||||
return conf.isModuleEnabled(meta);
|
||||
}
|
||||
|
||||
private void preInit(FMLPreInitializationEvent evt) {
|
||||
private void preInit(FMLCommonSetupEvent evt) {
|
||||
if (!blockNewRegistrations) conf.flush(); // First init call, so flush config
|
||||
blockNewRegistrations = true;
|
||||
}
|
||||
@@ -257,9 +256,9 @@ public class PulseManager {
|
||||
*/
|
||||
public static boolean isPulseLoadedGlobal(String pulseId) {
|
||||
ResourceLocation loc = new ResourceLocation(pulseId);
|
||||
Map<Object, PulseMeta> pulses = ALL_PULSES.get(loc.getResourceDomain());
|
||||
Map<Object, PulseMeta> pulses = ALL_PULSES.get(loc.getNamespace());
|
||||
if(pulses != null) {
|
||||
return isPulseLoaded(pulses, loc.getResourcePath());
|
||||
return isPulseLoaded(pulses, loc.getPath());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package slimeknights.mantle.pulsar.debug;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -18,11 +19,16 @@ import slimeknights.mantle.pulsar.pulse.Pulse;
|
||||
@Pulse(id="EventSpy", description="we iz in ur buses, monitorin ur eventz", forced=true)
|
||||
public class EventSpy {
|
||||
|
||||
private final Logger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId());
|
||||
private final Logger log = LogManager.getLogger("EventSpy/" + ModLoadingContext.get().getActiveContainer().getNamespace());
|
||||
|
||||
@Subscribe
|
||||
public void receive(Object evt) {
|
||||
@SubscribeEvent
|
||||
public void receive(Event evt) {
|
||||
log.info("Received event: " + evt);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void preInit(final FMLCommonSetupEvent evt) {
|
||||
log.info("Example preInit hit");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,6 @@ import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
@@ -16,6 +14,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class Configuration implements IConfiguration {
|
||||
* @param logger The logger to send debug info to.
|
||||
*/
|
||||
public Configuration(String confName, Logger logger) {
|
||||
this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".json";
|
||||
this.confPath = Paths.get("config", confName+ ".json").toString();
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package slimeknights.mantle.tileentity;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
public class MantleTileEntity extends TileEntity {
|
||||
|
||||
public MantleTileEntity(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public boolean isClient() {
|
||||
return this.getWorld() != null && this.getWorld().isRemote;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.INameable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
@@ -17,6 +19,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import slimeknights.mantle.util.ItemStackList;
|
||||
|
||||
@@ -24,7 +27,7 @@ import slimeknights.mantle.util.ItemStackList;
|
||||
public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
|
||||
private NonNullList<ItemStack> inventory;
|
||||
protected String inventoryTitle;
|
||||
protected ITextComponent inventoryTitle;
|
||||
protected boolean hasCustomName;
|
||||
protected int stackSizeLimit;
|
||||
protected IItemHandlerModifiable itemHandler;
|
||||
@@ -32,14 +35,15 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
/**
|
||||
* @param name Localization String for the inventory title. Can be overridden through setCustomName
|
||||
*/
|
||||
public TileInventory(String name, int inventorySize) {
|
||||
this(name, inventorySize, 64);
|
||||
public TileInventory(TileEntityType<?> tileEntityTypeIn, ITextComponent name, int inventorySize) {
|
||||
this(tileEntityTypeIn, name, inventorySize, 64);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Localization String for the inventory title. Can be overridden through setCustomName
|
||||
*/
|
||||
public TileInventory(String name, int inventorySize, int maxStackSize) {
|
||||
public TileInventory(TileEntityType<?> tileEntityTypeIn, ITextComponent name, int inventorySize, int maxStackSize) {
|
||||
super(tileEntityTypeIn);
|
||||
this.inventory = NonNullList.<ItemStack> withSize(inventorySize, ItemStack.EMPTY);
|
||||
this.stackSizeLimit = maxStackSize;
|
||||
this.inventoryTitle = name;
|
||||
@@ -53,9 +57,9 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, EnumFacing facing) {
|
||||
public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(@Nonnull Capability<T> capability, EnumFacing facing) {
|
||||
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return (T) itemHandler;
|
||||
return itemHandler.cast();
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
@@ -185,7 +189,7 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
public ITextComponent getName() {
|
||||
return this.inventoryTitle;
|
||||
}
|
||||
|
||||
@@ -194,19 +198,25 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
return this.hasCustomName;
|
||||
}
|
||||
|
||||
public void setCustomName(String customName) {
|
||||
public void setCustomName(ITextComponent customName) {
|
||||
this.hasCustomName = true;
|
||||
this.inventoryTitle = customName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ITextComponent getCustomName() {
|
||||
return this.inventoryTitle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
if(hasCustomName()) {
|
||||
return new TextComponentString(getName());
|
||||
return new TextComponentString(getName().getFormattedText());
|
||||
}
|
||||
|
||||
return new TextComponentTranslation(getName());
|
||||
return new TextComponentTranslation(getName().getFormattedText());
|
||||
}
|
||||
|
||||
|
||||
@@ -235,28 +245,28 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
this.resizeInternal(tags.getInteger("InventorySize"));
|
||||
public void read(NBTTagCompound tags) {
|
||||
super.read(tags);
|
||||
this.resizeInternal(tags.getInt("InventorySize"));
|
||||
|
||||
readInventoryFromNBT(tags);
|
||||
|
||||
if(tags.hasKey("CustomName", 8)) {
|
||||
if(tags.contains("CustomName", 8)) {
|
||||
this.inventoryTitle = tags.getString("CustomName");
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
public NBTTagCompound write(NBTTagCompound tags) {
|
||||
super.write(tags);
|
||||
|
||||
tags.setInteger("InventorySize", inventory.size());
|
||||
tags.putInt("InventorySize", inventory.size());
|
||||
|
||||
writeInventoryToNBT(tags);
|
||||
|
||||
if(this.hasCustomName()) {
|
||||
tags.setString("CustomName", this.inventoryTitle);
|
||||
tags.putString("CustomName", this.inventoryTitle);
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
@@ -269,27 +279,27 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
for(int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if(!inventory.getStackInSlot(i).isEmpty()) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
itemTag.setByte("Slot", (byte) i);
|
||||
inventory.getStackInSlot(i).writeToNBT(itemTag);
|
||||
nbttaglist.appendTag(itemTag);
|
||||
itemTag.putByte("Slot", (byte) i);
|
||||
inventory.getStackInSlot(i).write(itemTag);
|
||||
nbttaglist.add(itemTag);
|
||||
}
|
||||
}
|
||||
|
||||
tag.setTag("Items", nbttaglist);
|
||||
tag.put("Items", nbttaglist);
|
||||
}
|
||||
|
||||
/** Reads a an inventory from the tag. Overwrites current content */
|
||||
public void readInventoryFromNBT(NBTTagCompound tag) {
|
||||
NBTTagList nbttaglist = tag.getTagList("Items", 10);
|
||||
NBTTagList nbttaglist = tag.getList("Items", 10);
|
||||
|
||||
int limit = getInventoryStackLimit();
|
||||
ItemStack stack;
|
||||
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound itemTag = nbttaglist.getCompoundTagAt(i);
|
||||
for(int i = 0; i < nbttaglist.size(); ++i) {
|
||||
NBTTagCompound itemTag = nbttaglist.getCompound(i);
|
||||
int slot = itemTag.getByte("Slot") & 255;
|
||||
|
||||
if(slot >= 0 && slot < inventory.size()) {
|
||||
stack = new ItemStack(itemTag);
|
||||
stack = ItemStack.read(itemTag);
|
||||
if(!stack.isEmpty() && stack.getCount() > limit) {
|
||||
stack.setCount(limit);
|
||||
}
|
||||
|
||||
@@ -15,27 +15,27 @@ public class TagHelper {
|
||||
|
||||
/* Generic Tag Operations */
|
||||
public static NBTTagCompound getTagSafe(ItemStack stack) {
|
||||
if(stack.isEmpty() || !stack.hasTagCompound()) {
|
||||
if(stack.isEmpty() || !stack.hasTag()) {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
return stack.getTagCompound();
|
||||
return stack.getTag();
|
||||
}
|
||||
|
||||
public static NBTTagCompound getTagSafe(NBTTagCompound tag, String key) {
|
||||
if(tag == null || !tag.hasKey(key)) {
|
||||
if(tag == null || !tag.contains(key)) {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
return tag.getCompoundTag(key);
|
||||
return tag.getCompound(key);
|
||||
}
|
||||
|
||||
public static NBTTagList getTagListSafe(NBTTagCompound tag, String key, int type) {
|
||||
if(tag == null || !tag.hasKey(key)) {
|
||||
if(tag == null || !tag.contains(key)) {
|
||||
return new NBTTagList();
|
||||
}
|
||||
|
||||
return tag.getTagList(key, type);
|
||||
return tag.getList(key, type);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user