mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-28 07:35:44 +00:00
Begin updating Mantle to 1.14.2! Lots of things are broken again sadly :/
This commit is contained in:
1 parent
75faf82159
commit
e0b30fdf33
58 files changed
+436
-439
No files matched your search
@@ -3,10 +3,10 @@ package slimeknights.mantle.block;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
@@ -40,21 +40,21 @@ public class BlockConnectedTexture extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState updatePostPlacement(IBlockState stateIn, EnumFacing facing, IBlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
|
||||
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
|
||||
|
||||
// Creates the state to use for the block. This is where we check if every side is
|
||||
// connectable or not.
|
||||
|
||||
return stateIn.with(CONNECTED_DOWN, this.isSideConnectable(stateIn, worldIn, currentPos, EnumFacing.DOWN))
|
||||
.with(CONNECTED_EAST, this.isSideConnectable(stateIn, worldIn, currentPos, EnumFacing.EAST))
|
||||
.with(CONNECTED_NORTH, this.isSideConnectable(stateIn, worldIn, currentPos, EnumFacing.NORTH))
|
||||
.with(CONNECTED_SOUTH, this.isSideConnectable(stateIn, worldIn, currentPos, EnumFacing.SOUTH))
|
||||
.with(CONNECTED_UP, this.isSideConnectable(stateIn, worldIn, currentPos, EnumFacing.UP))
|
||||
.with(CONNECTED_WEST, this.isSideConnectable(stateIn, worldIn, currentPos, EnumFacing.WEST));
|
||||
return stateIn.with(CONNECTED_DOWN, this.isSideConnectable(stateIn, worldIn, currentPos, Direction.DOWN))
|
||||
.with(CONNECTED_EAST, this.isSideConnectable(stateIn, worldIn, currentPos, Direction.EAST))
|
||||
.with(CONNECTED_NORTH, this.isSideConnectable(stateIn, worldIn, currentPos, Direction.NORTH))
|
||||
.with(CONNECTED_SOUTH, this.isSideConnectable(stateIn, worldIn, currentPos, Direction.SOUTH))
|
||||
.with(CONNECTED_UP, this.isSideConnectable(stateIn, worldIn, currentPos, Direction.UP))
|
||||
.with(CONNECTED_WEST, this.isSideConnectable(stateIn, worldIn, currentPos, Direction.WEST));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(CONNECTED_DOWN, CONNECTED_UP, CONNECTED_NORTH, CONNECTED_SOUTH, CONNECTED_WEST, CONNECTED_EAST);
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public class BlockConnectedTexture extends Block {
|
||||
* @param side The side of the block to check.
|
||||
* @return Whether or not the side is connectable.
|
||||
*/
|
||||
private boolean isSideConnectable(IBlockState state, IWorld world, BlockPos pos, EnumFacing side) {
|
||||
final IBlockState connected = world.getBlockState(pos.offset(side));
|
||||
private boolean isSideConnectable(BlockState state, IWorld world, BlockPos pos, Direction side) {
|
||||
final BlockState connected = world.getBlockState(pos.offset(side));
|
||||
return connected != null && canConnect(state, connected);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class BlockConnectedTexture extends Block {
|
||||
* @param connected BlockState to check
|
||||
* @return True if the block is valid to connect
|
||||
*/
|
||||
protected boolean canConnect(@Nonnull IBlockState original, @Nonnull IBlockState connected) {
|
||||
protected boolean canConnect(@Nonnull BlockState original, @Nonnull BlockState connected) {
|
||||
return original.getBlock() == connected.getBlock();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package slimeknights.mantle.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ContainerBlock;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -22,7 +22,8 @@ import javax.annotation.Nonnull;
|
||||
import slimeknights.mantle.tileentity.TileInventory;
|
||||
|
||||
// Updated Version of InventoryBlock in Mantle
|
||||
public abstract class BlockInventory extends BlockContainer {
|
||||
public abstract class BlockInventory extends ContainerBlock
|
||||
{
|
||||
|
||||
protected BlockInventory(Block.Properties builder) {
|
||||
super(builder);
|
||||
@@ -30,34 +31,34 @@ public abstract class BlockInventory extends BlockContainer {
|
||||
|
||||
// inventories usually need a tileEntity
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract TileEntity createTileEntity(IBlockState state, IBlockReader world);
|
||||
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
||||
|
||||
/**
|
||||
* Called when the block is activated. Return true if a GUI is opened, false if the block has no GUI.
|
||||
*/
|
||||
protected abstract boolean openGui(EntityPlayer player, World world, BlockPos pos);
|
||||
protected abstract boolean openGui(PlayerEntity player, World world, BlockPos pos);
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) {
|
||||
if(player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!worldIn.isRemote) {
|
||||
return this.openGui(player, worldIn, pos);
|
||||
if(!world.isRemote) {
|
||||
return this.openGui(player, world, pos);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
|
||||
ItemStack stack) {
|
||||
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||
|
||||
@@ -72,7 +73,7 @@ public abstract class BlockInventory extends BlockContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(IBlockState state, World worldIn, BlockPos pos, IBlockState newState, boolean isMoving) {
|
||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
||||
|
||||
@@ -89,7 +90,7 @@ public abstract class BlockInventory extends BlockContainer {
|
||||
// we need model for standard forge rendering
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state) {
|
||||
return EnumBlockRenderType.MODEL;
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package slimeknights.mantle.block;
|
||||
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
|
||||
// Mojang made the constructor for stairs protected, so this class is basically a wrapper to change that and fix a lighting error
|
||||
public class BlockStairsBase extends BlockStairs {
|
||||
public class BlockStairsBase extends StairsBlock
|
||||
{
|
||||
|
||||
public BlockStairsBase(IBlockState modelState) {
|
||||
super(modelState);
|
||||
this.useNeighborBrightness = true;
|
||||
this.setCreativeTab(modelState.getBlock().displayOnCreativeTab);
|
||||
public BlockStairsBase(Block model) {
|
||||
super(model.getDefaultState(), Block.Properties.from(model));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package slimeknights.mantle.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
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.init.MobEffects;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
@@ -27,7 +27,7 @@ import slimeknights.mantle.Mantle;
|
||||
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 static final ResourceLocation ICON_VANILLA = AbstractGui.GUI_ICONS_LOCATION;
|
||||
|
||||
private final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
@@ -45,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.getInstance().ingameGUI.drawTexturedModalRect(x, y, textureX, textureY, width, height);
|
||||
Minecraft.getInstance().ingameGUI.blit(x, y, textureX, textureY, width, height);
|
||||
}
|
||||
|
||||
/* HUD */
|
||||
@@ -54,10 +54,10 @@ public class ExtraHeartRenderHandler {
|
||||
Entity renderViewEnity = this.mc.getRenderViewEntity();
|
||||
if(event.getType() != RenderGameOverlayEvent.ElementType.HEALTH
|
||||
|| event.isCanceled()
|
||||
|| !(renderViewEnity instanceof EntityPlayer)) {
|
||||
|| !(renderViewEnity instanceof PlayerEntity)) {
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity();
|
||||
PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity();
|
||||
|
||||
// extra setup stuff from us
|
||||
left_height = GuiIngameForge.left_height;
|
||||
@@ -115,7 +115,7 @@ public class ExtraHeartRenderHandler {
|
||||
if (rowHeight != 10) left_height += 10 - rowHeight;
|
||||
|
||||
regen = -1;
|
||||
if (player.isPotionActive(MobEffects.REGENERATION))
|
||||
if (player.isPotionActive(Effects.REGENERATION))
|
||||
{
|
||||
regen = updateCounter % 25;
|
||||
}
|
||||
@@ -123,8 +123,8 @@ public class ExtraHeartRenderHandler {
|
||||
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;
|
||||
else if (player.isPotionActive(MobEffects.WITHER)) MARGIN += 72;
|
||||
if (player.isPotionActive(Effects.POISON)) MARGIN += 36;
|
||||
else if (player.isPotionActive(Effects.WITHER)) MARGIN += 72;
|
||||
float absorbRemaining = absorb;
|
||||
|
||||
for (int i = MathHelper.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i)
|
||||
@@ -186,7 +186,7 @@ public class ExtraHeartRenderHandler {
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
private void renderExtraHearts(int xBasePos, int yBasePos, EntityPlayer player) {
|
||||
private void renderExtraHearts(int xBasePos, int yBasePos, PlayerEntity player) {
|
||||
int potionOffset = getPotionOffset(player);
|
||||
|
||||
// Extra hearts
|
||||
@@ -225,13 +225,13 @@ public class ExtraHeartRenderHandler {
|
||||
return i + offset == regen ? -2 : 0;
|
||||
}
|
||||
|
||||
private int getPotionOffset(EntityPlayer player) {
|
||||
private int getPotionOffset(PlayerEntity player) {
|
||||
int potionOffset = 0;
|
||||
PotionEffect potion = player.getActivePotionEffect(MobEffects.WITHER);
|
||||
EffectInstance potion = player.getActivePotionEffect(Effects.WITHER);
|
||||
if(potion != null) {
|
||||
potionOffset = 18;
|
||||
}
|
||||
potion = player.getActivePotionEffect(MobEffects.POISON);
|
||||
potion = player.getActivePotionEffect(Effects.POISON);
|
||||
if(potion != null) {
|
||||
potionOffset = 9;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class ExtraHeartRenderHandler {
|
||||
return potionOffset;
|
||||
}
|
||||
|
||||
private void renderExtraAbsorption(int xBasePos, int yBasePos, EntityPlayer player) {
|
||||
private void renderExtraAbsorption(int xBasePos, int yBasePos, PlayerEntity player) {
|
||||
int potionOffset = getPotionOffset(player);
|
||||
|
||||
// Extra hearts
|
||||
|
||||
@@ -2,8 +2,7 @@ package slimeknights.mantle.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
@@ -26,7 +25,7 @@ public class ModelHelper {
|
||||
public static final TRSRTransformation BLOCK_THIRD_PERSON_RIGHT;
|
||||
public static final TRSRTransformation BLOCK_THIRD_PERSON_LEFT;
|
||||
|
||||
public static TextureAtlasSprite getTextureFromBlockstate(IBlockState state) {
|
||||
public static TextureAtlasSprite getTextureFromBlockstate(BlockState state) {
|
||||
return Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -10,9 +10,9 @@ public class BookHelper {
|
||||
|
||||
public static String getSavedPage(ItemStack item) {
|
||||
if(!item.isEmpty() && item.hasTag()) {
|
||||
NBTTagCompound mantleBook = item.getTag().getCompound("mantle").getCompound("book");
|
||||
CompoundNBT mantleBook = item.getTag().getCompound("mantle").getCompound("book");
|
||||
|
||||
if(mantleBook.contains("page", Arrays.asList(INBTBase.NBT_TYPES).indexOf("STRING"))) {
|
||||
if(mantleBook.contains("page", Arrays.asList(INBT.NBT_TYPES).indexOf("STRING"))) {
|
||||
return mantleBook.getString("page");
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,14 @@ public class BookHelper {
|
||||
}
|
||||
|
||||
public static void writeSavedPage(ItemStack item, String page) {
|
||||
NBTTagCompound compound = item.getTag();
|
||||
CompoundNBT compound = item.getTag();
|
||||
|
||||
if(compound == null) {
|
||||
compound = new NBTTagCompound();
|
||||
compound = new CompoundNBT();
|
||||
}
|
||||
|
||||
NBTTagCompound mantle = compound.getCompound("mantle");
|
||||
NBTTagCompound book = mantle.getCompound("book");
|
||||
CompoundNBT mantle = compound.getCompound("mantle");
|
||||
CompoundNBT book = mantle.getCompound("book");
|
||||
|
||||
book.putString("page", page);
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package slimeknights.mantle.client.book;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
@@ -136,11 +136,11 @@ public class BookLoader implements IResourceManagerReloadListener {
|
||||
return info;
|
||||
}
|
||||
|
||||
public static void updateSavedPage(EntityPlayer player, ItemStack item, String page) {
|
||||
public static void updateSavedPage(PlayerEntity player, ItemStack item, String page) {
|
||||
if(player == null) {
|
||||
return;
|
||||
}
|
||||
if(player.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) {
|
||||
if(player.getHeldItem(Hand.MAIN_HAND).isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Fluids;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.EnumLightType;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
@@ -24,7 +24,7 @@ import javax.annotation.Nullable;
|
||||
public class StructureBlockAccess implements IWorldReader
|
||||
{
|
||||
private final StructureInfo data;
|
||||
private final IBlockState[][][] structure;
|
||||
private final BlockState[][][] structure;
|
||||
|
||||
public StructureBlockAccess(StructureInfo data) {
|
||||
this.data = data;
|
||||
@@ -44,12 +44,12 @@ public class StructureBlockAccess implements IWorldReader
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightFor(EnumLightType type, BlockPos pos) {
|
||||
public int getLightFor(LightType type, BlockPos pos) {
|
||||
return 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getBlockState(BlockPos pos) {
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
@@ -78,7 +78,7 @@ public class StructureBlockAccess implements IWorldReader
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongPower(BlockPos pos, EnumFacing direction) {
|
||||
public int getStrongPower(BlockPos pos, Direction direction) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class StructureBlockAccess implements IWorldReader
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getClosestPlayer(double x, double y, double z, double distance, Predicate<Entity> predicate) {
|
||||
public PlayerEntity getClosestPlayer(double x, double y, double z, double distance, Predicate<Entity> predicate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -13,7 +13,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import slimeknights.mantle.client.book.data.element.BlockData;
|
||||
|
||||
public class StructureInfo {
|
||||
public IBlockState[][][] data;
|
||||
public BlockState[][][] data;
|
||||
public int blockCount = 0;
|
||||
public int[] countPerLevel;
|
||||
public int structureHeight = 0;
|
||||
@@ -28,7 +28,7 @@ public class StructureInfo {
|
||||
this.structureWidth = width;
|
||||
this.structureHeight = height;
|
||||
this.structureLength = length;
|
||||
IBlockState[][][] states = new IBlockState[height][length][width];
|
||||
BlockState[][][] states = new BlockState[height][length][width];
|
||||
|
||||
for(int y = 0; y < height; y++) {
|
||||
for(int x = 0; x < length; x++) {
|
||||
@@ -47,12 +47,12 @@ public class StructureInfo {
|
||||
maxBlockIndex = blockIndex = structureHeight * structureLength * structureWidth;
|
||||
}
|
||||
|
||||
private IBlockState convert(BlockData data) {
|
||||
private BlockState convert(BlockData data) {
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(data.block));
|
||||
if(block == null) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
IBlockState state;
|
||||
BlockState state;
|
||||
if(data.state == null || data.state.isEmpty()) {
|
||||
state = block.getStateFromMeta(data.meta);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class StructureInfo {
|
||||
return state;
|
||||
}
|
||||
|
||||
private <T extends Comparable<T>> IBlockState setProperty(IBlockState state, IProperty<T> prop, String valueString) {
|
||||
private <T extends Comparable<T>> BlockState setProperty(BlockState state, IProperty<T> prop, String valueString) {
|
||||
java.util.Optional<T> value = prop.parseValue(valueString);
|
||||
if(value.isPresent()) {
|
||||
state = state.with(prop, value.get());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.client.book.data;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -150,7 +150,7 @@ public class PageData implements IDataItem {
|
||||
addSwap(DataLocation.class, new ValueHotswap<DataLocation>() {
|
||||
@Override
|
||||
public void swap(BookRepository source, DataLocation object) {
|
||||
object.location = object.file == "$BLOCK_ATLAS" ? TextureMap.LOCATION_BLOCKS_TEXTURE : source
|
||||
object.location = object.file == "$BLOCK_ATLAS" ? AtlasTexture.LOCATION_BLOCKS_TEXTURE : source
|
||||
.getResourceLocation(object.file, true);
|
||||
}
|
||||
}.getClass());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
|
||||
@@ -4,18 +4,17 @@ import com.google.gson.JsonObject;
|
||||
|
||||
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.block.Blocks;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
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;
|
||||
@@ -77,11 +76,11 @@ public class ItemStackData {
|
||||
}
|
||||
|
||||
if(isMissingItem) {
|
||||
NBTTagCompound display = itemStack.getOrCreateChildTag("display");
|
||||
CompoundNBT display = itemStack.getOrCreateChildTag("display");
|
||||
display.putString("Name", "\u00A7rUnknown Item");
|
||||
NBTTagList lore = new NBTTagList();
|
||||
lore.add(new NBTTagString("\u00A7r\u00A7eItem Name:"));
|
||||
lore.add(new NBTTagString("\u00A7r\u00A7e" + id));
|
||||
ListNBT lore = new ListNBT();
|
||||
lore.add(new StringNBT("\u00A7r\u00A7eItem Name:"));
|
||||
lore.add(new StringNBT("\u00A7r\u00A7e" + id));
|
||||
display.put("Lore", lore);
|
||||
}
|
||||
|
||||
@@ -97,7 +96,7 @@ public class ItemStackData {
|
||||
data.id = ForgeRegistries.ITEMS.getKey(stack.getItem()).toString();
|
||||
data.amount = (byte) stack.getCount();
|
||||
if(!ignoreNbt && stack.getTag() != null) {
|
||||
data.nbt = BookLoader.GSON.toJsonTree(stack.getTag(), NBTTagCompound.class).getAsJsonObject();
|
||||
data.nbt = BookLoader.GSON.toJsonTree(stack.getTag(), CompoundNBT.class).getAsJsonObject();
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class GuiElement {
|
||||
* @param yPos Y-Coordinate on the screen
|
||||
*/
|
||||
public int draw(int xPos, int yPos) {
|
||||
GuiScreen.drawModalRectWithCustomSizedTexture(xPos, yPos, x, y, w, h, texW, texH);
|
||||
Screen.blit(xPos, yPos, x, y, w, h, texW, texH);
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GuiElementScalable extends GuiElement {
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = width % w;
|
||||
if(remainder > 0) {
|
||||
GuiScreen.drawModalRectWithCustomSizedTexture(xPos + width - remainder, yPos, x, y, remainder, h, texW, texH);
|
||||
Screen.blit(xPos + width - remainder, yPos, x, y, remainder, h, texW, texH);
|
||||
}
|
||||
|
||||
return width;
|
||||
@@ -35,7 +35,7 @@ public class GuiElementScalable extends GuiElement {
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = height % h;
|
||||
if(remainder > 0) {
|
||||
GuiScreen.drawModalRectWithCustomSizedTexture(xPos, yPos + height - remainder, x, y, w, remainder, texW, texH);
|
||||
Screen.blit(xPos, yPos + height - remainder, x, y, w, remainder, texW, texH);
|
||||
}
|
||||
|
||||
return w;
|
||||
@@ -59,7 +59,7 @@ public class GuiElementScalable extends GuiElement {
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = width % w;
|
||||
if(remainder > 0) {
|
||||
GuiScreen.drawModalRectWithCustomSizedTexture(xPos + width - remainder, yPos, x, y, remainder, yRest, texW, texH);
|
||||
Screen.blit(xPos + width - remainder, yPos, x, y, remainder, yRest, texW, texH);
|
||||
}
|
||||
|
||||
return width;
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package slimeknights.mantle.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.renderer.Rectangle2d;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
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
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class GuiModule extends GuiContainer {
|
||||
public abstract class GuiModule extends ContainerScreen
|
||||
{
|
||||
|
||||
protected final GuiMultiModule parent;
|
||||
|
||||
|
||||
@@ -2,18 +2,16 @@ package slimeknights.mantle.client.gui;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.renderer.Rectangle2d;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,14 +23,15 @@ import slimeknights.mantle.inventory.ContainerMultiModule;
|
||||
import slimeknights.mantle.inventory.SlotWrapper;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiMultiModule extends GuiContainer {
|
||||
public class GuiMultiModule extends ContainerScreen
|
||||
{
|
||||
|
||||
// NEI-stuff >:(
|
||||
private static Field NEI_Manager;
|
||||
|
||||
static {
|
||||
try {
|
||||
NEI_Manager = GuiContainer.class.getDeclaredField("manager");
|
||||
NEI_Manager = ContainerScreen.class.getDeclaredField("manager");
|
||||
} catch(NoSuchFieldException e) {
|
||||
NEI_Manager = null;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package slimeknights.mantle.client.gui.book;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static slimeknights.mantle.client.gui.book.Textures.TEX_BOOK;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiArrow extends GuiButton {
|
||||
|
||||
public class GuiArrow extends Button
|
||||
{
|
||||
private static final int X = 412;
|
||||
|
||||
public static final int WIDTH = 18;
|
||||
@@ -38,16 +36,16 @@ public class GuiArrow extends GuiButton {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
minecraft.getTextureManager().bindTexture(TEX_BOOK);
|
||||
|
||||
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
|
||||
int color = this.hovered ? this.hoverColor : this.color;
|
||||
int color = this.isHovered ? this.hoverColor : this.color;
|
||||
|
||||
float r = ((color >> 16) & 0xff) / 255.F;
|
||||
float g = ((color >> 8) & 0xff) / 255.F;
|
||||
float b = (color & 0xff) / 255.F;
|
||||
|
||||
GlStateManager.color3f(r, g, b);
|
||||
Gui.drawScaledCustomSizeModalRect(x, y, arrowType.x, arrowType.y, width, height, width, height, 512, 512);
|
||||
AbstractGui.blit(x, y, arrowType.x, arrowType.y, width, height, width, height, 512, 512);
|
||||
this.renderBg(minecraft, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,21 @@ package slimeknights.mantle.client.gui.book;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementList;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.IProgressMeter;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientAdvancementManager;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
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.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -44,7 +36,8 @@ import static slimeknights.mantle.client.gui.book.Textures.TEX_BOOK;
|
||||
import static slimeknights.mantle.client.gui.book.Textures.TEX_BOOKFRONT;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiBook extends GuiScreen {
|
||||
public class GuiBook extends Screen
|
||||
{
|
||||
|
||||
public static boolean debug = false;
|
||||
|
||||
@@ -66,7 +59,7 @@ public class GuiBook extends GuiScreen {
|
||||
public static int PAGE_HEIGHT;
|
||||
|
||||
static{
|
||||
init(); // initializes page width and height
|
||||
initWidthsAndHeights(); // initializes page width and height
|
||||
}
|
||||
|
||||
private GuiArrow previousArrow, nextArrow, backArrow, indexArrow;
|
||||
@@ -81,7 +74,8 @@ public class GuiBook extends GuiScreen {
|
||||
|
||||
public AdvancementCache advancementCache;
|
||||
|
||||
public static void init() {
|
||||
//TODO: new name as vanilla now uses init
|
||||
public static void initWidthsAndHeights() {
|
||||
PAGE_WIDTH = (int) ((PAGE_WIDTH_UNSCALED - (PAGE_PADDING_LEFT + PAGE_PADDING_RIGHT + PAGE_MARGIN + PAGE_MARGIN)) / PAGE_SCALE);
|
||||
PAGE_HEIGHT = (int) ((PAGE_HEIGHT_UNSCALED - (PAGE_PADDING_TOP + PAGE_PADDING_BOT + PAGE_MARGIN + PAGE_MARGIN)) / PAGE_SCALE);
|
||||
}
|
||||
@@ -90,12 +84,12 @@ public class GuiBook extends GuiScreen {
|
||||
this.book = book;
|
||||
this.item = item;
|
||||
|
||||
this.mc = Minecraft.getInstance();
|
||||
this.fontRenderer = mc.fontRenderer;
|
||||
this.minecraft = Minecraft.getInstance();
|
||||
this.font = minecraft.fontRenderer;
|
||||
init();
|
||||
|
||||
advancementCache = new AdvancementCache();
|
||||
this.mc.player.connection.getAdvancementManager().setListener(advancementCache);
|
||||
this.minecraft.player.connection.getAdvancementManager().setListener(advancementCache);
|
||||
|
||||
openPage(book.findPageNumber(BookHelper.getSavedPage(item), advancementCache));
|
||||
}
|
||||
@@ -124,11 +118,11 @@ public class GuiBook extends GuiScreen {
|
||||
}
|
||||
|
||||
protected int getMouseX(boolean rightSide) {
|
||||
return (int) ((Minecraft.getInstance().mouseHelper.getMouseX() * this.width / this.mc.mainWindow.getFramebufferWidth() - leftOffset(rightSide)) / PAGE_SCALE);
|
||||
return (int) ((Minecraft.getInstance().mouseHelper.getMouseX() * this.width / this.minecraft.mainWindow.getFramebufferWidth() - leftOffset(rightSide)) / PAGE_SCALE);
|
||||
}
|
||||
|
||||
protected int getMouseY() {
|
||||
return (int) ((this.height - Minecraft.getInstance().mouseHelper.getMouseY() * this.height / this.mc.mainWindow.getFramebufferWidth() - 1 - topOffset()) / PAGE_SCALE);
|
||||
return (int) ((this.height - Minecraft.getInstance().mouseHelper.getMouseY() * this.height / this.minecraft.mainWindow.getFramebufferWidth() - 1 - topOffset()) / PAGE_SCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,11 +131,11 @@ public class GuiBook extends GuiScreen {
|
||||
init();
|
||||
FontRenderer fontRenderer = book.fontRenderer;
|
||||
if(fontRenderer == null) {
|
||||
fontRenderer = mc.fontRenderer;
|
||||
fontRenderer = minecraft.fontRenderer;
|
||||
}
|
||||
|
||||
if(debug) {
|
||||
drawRect(0, 0, fontRenderer.getStringWidth("DEBUG") + 4, fontRenderer.FONT_HEIGHT + 4, 0x55000000);
|
||||
fill(0, 0, fontRenderer.getStringWidth("DEBUG") + 4, fontRenderer.FONT_HEIGHT + 4, 0x55000000);
|
||||
fontRenderer.drawString("DEBUG", 2, 2, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
@@ -182,18 +176,18 @@ public class GuiBook extends GuiScreen {
|
||||
float coverG = ((book.appearance.coverColor >> 8) & 0xff) / 255.F;
|
||||
float coverB = (book.appearance.coverColor & 0xff) / 255.F;
|
||||
|
||||
TextureManager render = this.mc.textureManager;
|
||||
TextureManager render = this.minecraft.textureManager;
|
||||
|
||||
if(page == -1) {
|
||||
render.bindTexture(TEX_BOOKFRONT);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
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);
|
||||
blit(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.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);
|
||||
blit(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);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
@@ -217,12 +211,12 @@ public class GuiBook extends GuiScreen {
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GlStateManager.color3f(coverR, coverG, coverB);
|
||||
drawModalRectWithCustomSizedTexture(width / 2 - PAGE_WIDTH_UNSCALED, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED * 2, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
blit(width / 2 - PAGE_WIDTH_UNSCALED, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED * 2, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
|
||||
GlStateManager.color3f(1F, 1F, 1F);
|
||||
|
||||
if(page != 0) {
|
||||
drawModalRectWithCustomSizedTexture(width / 2 - PAGE_WIDTH_UNSCALED, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
blit(width / 2 - PAGE_WIDTH_UNSCALED, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
drawerTransform(false);
|
||||
@@ -264,7 +258,7 @@ public class GuiBook extends GuiScreen {
|
||||
|
||||
int fullPageCount = book.getFullPageCount(advancementCache);
|
||||
if(page < fullPageCount - 1 || book.getPageCount(advancementCache) % 2 != 0) {
|
||||
drawModalRectWithCustomSizedTexture(width / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
blit(width / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
drawerTransform(true);
|
||||
@@ -407,8 +401,8 @@ public class GuiBook extends GuiScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
// The books are unreadable at Gui Scale set to small, so we'll double the scale, and of course half the size so that all our code still works as it should
|
||||
/*
|
||||
@@ -635,8 +629,8 @@ public class GuiBook extends GuiScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if(mc.player == null) {
|
||||
public void removed() {
|
||||
if(minecraft.player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package slimeknights.mantle.client.gui.book;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import slimeknights.mantle.client.book.data.BookmarkData;
|
||||
|
||||
public class GuiBookmark extends GuiButton {
|
||||
public class GuiBookmark extends Button
|
||||
{
|
||||
|
||||
private static final ResourceLocation TEX_BOOK = new ResourceLocation("mantle:textures/gui/book.png");
|
||||
|
||||
@@ -44,7 +43,7 @@ public class GuiBookmark extends GuiButton {
|
||||
float b = (data.color & 0xff) / 255.F;
|
||||
|
||||
GlStateManager.color3f(r, g, b);
|
||||
Gui.drawScaledCustomSizeModalRect(x, y, TEX_X, tex_y, WIDTH, HEIGHT, width, height, 512, 512);
|
||||
AbstractGui.blit(x, y, TEX_X, tex_y, WIDTH, HEIGHT, width, height, 512, 512);
|
||||
|
||||
if(data.text != null && !data.text.isEmpty()) {
|
||||
TextDataRenderer
|
||||
@@ -54,7 +53,7 @@ public class GuiBookmark extends GuiButton {
|
||||
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);
|
||||
AbstractGui.blit(x + width / 2 - ADD_W / 2, y + height / 2 - ADD_H / 2, ADD_X, ADD_Y, ADD_W, ADD_H, 512, 512);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.gui.book;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
@@ -251,7 +251,7 @@ public class TextDataRenderer {
|
||||
float f5 = (float) (endColor >> 16 & 255) / 255.0F;
|
||||
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (endColor & 255) / 255.0F;
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableTexture();
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.blendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.shadeModel(7425);
|
||||
@@ -265,7 +265,7 @@ public class TextDataRenderer {
|
||||
tessellator.draw();
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableTexture();
|
||||
}
|
||||
//END METHODS FROM GUI
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@@ -20,7 +20,8 @@ import java.util.List;
|
||||
import slimeknights.mantle.client.gui.book.GuiBook;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class BookElement extends Gui {
|
||||
public abstract class BookElement extends AbstractGui
|
||||
{
|
||||
|
||||
public GuiBook parent;
|
||||
|
||||
@@ -108,17 +109,17 @@ public abstract class BookElement extends Gui {
|
||||
}
|
||||
|
||||
int l = -267386864;
|
||||
this.drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l);
|
||||
this.drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l);
|
||||
this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l);
|
||||
this.drawGradientRect(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, l, l);
|
||||
this.drawGradientRect(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, l, l);
|
||||
this.fillGradient(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l);
|
||||
this.fillGradient(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l);
|
||||
this.fillGradient(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l);
|
||||
this.fillGradient(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, l, l);
|
||||
this.fillGradient(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, l, l);
|
||||
int i1 = 1347420415;
|
||||
int j1 = (i1 & 16711422) >> 1 | i1 & -16777216;
|
||||
this.drawGradientRect(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, i1, j1);
|
||||
this.drawGradientRect(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, i1, j1);
|
||||
this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, i1, i1);
|
||||
this.drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1);
|
||||
this.fillGradient(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, i1, j1);
|
||||
this.fillGradient(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, i1, j1);
|
||||
this.fillGradient(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, i1, i1);
|
||||
this.fillGradient(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1);
|
||||
|
||||
for(int k1 = 0; k1 < textLines.size(); ++k1) {
|
||||
String s1 = textLines.get(k1);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -65,7 +65,7 @@ public class ElementImage extends SizedBookElement {
|
||||
if(image.item == null) {
|
||||
renderEngine.bindTexture(image.location);
|
||||
|
||||
drawScaledCustomSizeModalRect(x, y, image.u, image.v, image.uw, image.vh, width, height, image.texWidth, image.texHeight);
|
||||
blit(x, y, image.u, image.v, image.uw, image.vh, width, height, image.texWidth, image.texHeight);
|
||||
} else {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scalef(width, height, 1F);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import slimeknights.mantle.client.book.data.SectionData;
|
||||
@@ -34,7 +34,7 @@ public class ElementSection extends SizedBookElement {
|
||||
int iconX = x + WIDTH / 2 - IMG_SIZE / 2;
|
||||
int iconY = y + HEIGHT / 2 - IMG_SIZE / 2;
|
||||
if(hover) {
|
||||
drawRect(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, parent.book.appearance.hoverColor);
|
||||
fill(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, parent.book.appearance.hoverColor);
|
||||
}
|
||||
if(unlocked) {
|
||||
GlStateManager.color4f(1F, 1F, 1F, hover ? 1F : 0.5F);
|
||||
@@ -49,7 +49,7 @@ public class ElementSection extends SizedBookElement {
|
||||
if(section.icon.location != null) {
|
||||
renderEngine.bindTexture(section.icon.location);
|
||||
|
||||
drawScaledCustomSizeModalRect(iconX, iconY, section.icon.u, section.icon.v, section.icon.uw, section.icon.vh, IMG_SIZE, IMG_SIZE, section.icon.texWidth, section.icon.texHeight);
|
||||
blit(iconX, iconY, section.icon.u, section.icon.v, section.icon.uw, section.icon.vh, IMG_SIZE, IMG_SIZE, section.icon.texWidth, section.icon.texHeight);
|
||||
}
|
||||
} else {
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -220,18 +220,18 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa
|
||||
}
|
||||
int iterator = 0;
|
||||
|
||||
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
for(int h = 0; h < structureData.structureHeight; h++) {
|
||||
for(int l = 0; l < structureData.structureLength; l++) {
|
||||
for(int w = 0; w < structureData.structureWidth; w++) {
|
||||
BlockPos pos = new BlockPos(l, h, w);
|
||||
if(!blockAccess.isAirBlock(pos)) {
|
||||
IBlockState state = blockAccess.getBlockState(pos);
|
||||
BlockState state = blockAccess.getBlockState(pos);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
Random random = new Random();
|
||||
blockRender.renderBlock(state, pos, blockAccess, buffer, random);
|
||||
blockRender.renderBlock(state, pos, blockAccess, buffer, random, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE);
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -21,9 +21,9 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class BakedCompositeModel extends BakedWrapper {
|
||||
|
||||
protected final ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> parts;
|
||||
protected final ImmutableMap<Optional<Direction>, ImmutableList<BakedQuad>> parts;
|
||||
|
||||
public BakedCompositeModel(IBakedModel parent, ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> parts) {
|
||||
public BakedCompositeModel(IBakedModel parent, ImmutableMap<Optional<Direction>, ImmutableList<BakedQuad>> parts) {
|
||||
super(parent);
|
||||
|
||||
this.parts = parts;
|
||||
@@ -31,7 +31,7 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return parts.get(Optional.fromNullable(side));
|
||||
}
|
||||
|
||||
@@ -46,14 +46,14 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(IBakedModel model, IBlockState state, Random rand) {
|
||||
public void add(IBakedModel model, BlockState state, Random rand) {
|
||||
add(model, state, null, rand);
|
||||
for(EnumFacing side : EnumFacing.values()) {
|
||||
for(Direction side : Direction.values()) {
|
||||
add(model, state, side, rand);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(IBakedModel model, IBlockState state, EnumFacing side, Random rand) {
|
||||
public void add(IBakedModel model, BlockState state, Direction side, Random rand) {
|
||||
int index;
|
||||
if(side == null) {
|
||||
index = 6;
|
||||
@@ -66,10 +66,10 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
}
|
||||
|
||||
public BakedCompositeModel build(IBakedModel parent) {
|
||||
ImmutableMap.Builder<Optional<EnumFacing>, ImmutableList<BakedQuad>> map = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<Optional<Direction>, ImmutableList<BakedQuad>> map = ImmutableMap.builder();
|
||||
|
||||
map.put(Optional.<EnumFacing>absent(), builders[6].build());
|
||||
for(EnumFacing side : EnumFacing.values()) {
|
||||
map.put(Optional.<Direction>absent(), builders[6].build());
|
||||
for(Direction side : Direction.values()) {
|
||||
map.put(Optional.of(side), builders[side.getIndex()].build());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ package slimeknights.mantle.client.model;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
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.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class BakedSimple implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return quads;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ package slimeknights.mantle.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
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.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class BakedWrapper implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return parent.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package slimeknights.mantle.client.model;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
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.minecraft.util.Direction;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class BlockItemModelWrapper implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return parent.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
@@ -10,9 +10,9 @@ 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;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.client.model.pipeline.VertexTransformer;
|
||||
@@ -58,11 +58,11 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
}
|
||||
|
||||
/** Rotates around the Y axis and adjusts culling appropriately. South is default. */
|
||||
public TRSRBakedModel(IBakedModel original, EnumFacing facing) {
|
||||
public TRSRBakedModel(IBakedModel original, Direction facing) {
|
||||
this.original = original;
|
||||
this.override = new TRSROverride(this);
|
||||
|
||||
this.faceOffset = 4 + EnumFacing.NORTH.getHorizontalIndex() - facing.getHorizontalIndex();
|
||||
this.faceOffset = 4 + Direction.NORTH.getHorizontalIndex() - facing.getHorizontalIndex();
|
||||
|
||||
double r = Math.PI * (360 - facing.getOpposite().getHorizontalIndex() * 90)/180d;
|
||||
TRSRTransformation t = new TRSRTransformation(null, null, null, TRSRTransformation.quatFromXYZ(0, (float)r, 0));
|
||||
@@ -71,7 +71,7 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, Random rand) {
|
||||
public List<BakedQuad> getQuads(BlockState state, Direction 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.byHorizontalIndex((side.getHorizontalIndex() + faceOffset) % 4);
|
||||
side = Direction.byHorizontalIndex((side.getHorizontalIndex() + faceOffset) % 4);
|
||||
}
|
||||
for(BakedQuad quad : original.getQuads(state, side, rand)) {
|
||||
Transformer transformer = new Transformer(transformation, quad.getFormat());
|
||||
@@ -140,7 +140,7 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBakedModel getModelWithOverrides(@Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull EntityLivingBase entity) {
|
||||
public IBakedModel getModelWithOverrides(@Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull LivingEntity entity) {
|
||||
IBakedModel baked = model.original.getOverrides().getModelWithOverrides(originalModel, stack, world, entity);
|
||||
|
||||
return new TRSRBakedModel(baked, model.transformation);
|
||||
@@ -165,16 +165,16 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
|
||||
@Override
|
||||
public void put(int element, float... data) {
|
||||
VertexFormatElement.EnumUsage usage = parent.getVertexFormat().getElement(element).getUsage();
|
||||
VertexFormatElement.Usage usage = parent.getVertexFormat().getElement(element).getUsage();
|
||||
|
||||
// transform normals and position
|
||||
if(usage == VertexFormatElement.EnumUsage.POSITION && data.length >= 3) {
|
||||
if(usage == VertexFormatElement.Usage.POSITION && data.length >= 3) {
|
||||
Vector4f vec = new Vector4f(data[0], data[1], data[2], 1f);
|
||||
transformation.transform(vec);
|
||||
data = new float[4];
|
||||
vec.get(data);
|
||||
}
|
||||
else if(usage == VertexFormatElement.EnumUsage.NORMAL && data.length >= 3) {
|
||||
else if(usage == VertexFormatElement.Usage.NORMAL && data.length >= 3) {
|
||||
Vector3f vec = new Vector3f(data);
|
||||
normalTransformation.transform(vec);
|
||||
vec.normalize();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.common;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
public Object getServerGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if(te instanceof IInventoryGui) {
|
||||
return ((IInventoryGui) te).createContainer(player.inventory, world, new BlockPos(x, y, z));
|
||||
@@ -21,7 +21,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
public Object getClientGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if(te instanceof IInventoryGui) {
|
||||
return ((IInventoryGui) te).createGui(player.inventory, world, new BlockPos(x, y, z));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package slimeknights.mantle.common;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -13,8 +13,8 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
*/
|
||||
public interface IInventoryGui {
|
||||
|
||||
Container createContainer(InventoryPlayer inventoryplayer, World world, BlockPos pos);
|
||||
Container createContainer(PlayerInventory inventoryplayer, World world, BlockPos pos);
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
GuiContainer createGui(InventoryPlayer inventoryplayer, World world, BlockPos pos);
|
||||
ContainerScreen createGui(PlayerInventory inventoryplayer, World world, BlockPos pos);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package slimeknights.mantle.common;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
@@ -77,8 +77,8 @@ public interface IRegisterUtil {
|
||||
* @param block Block to get item block
|
||||
* @return Registered item block
|
||||
*/
|
||||
default ItemBlock registerItemBlock(IForgeRegistry<Item> registry, Block block) {
|
||||
ItemBlock itemBlock = new ItemBlock(block, new Item.Properties());
|
||||
default BlockItem registerItemBlock(IForgeRegistry<Item> registry, Block block) {
|
||||
BlockItem itemBlock = new BlockItem(block, new Item.Properties());
|
||||
return register(registry, itemBlock, block.getRegistryName());
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public interface IRegisterUtil {
|
||||
* @param group Group for the item block
|
||||
* @return Registered item block
|
||||
*/
|
||||
default ItemBlock registerItemBlock(IForgeRegistry<Item> registry, Block block, ItemGroup group) {
|
||||
ItemBlock itemBlock = new ItemBlock(block, new Item.Properties().group(group));
|
||||
default BlockItem registerItemBlock(IForgeRegistry<Item> registry, Block block, ItemGroup group) {
|
||||
BlockItem itemBlock = new BlockItem(block, new Item.Properties().group(group));
|
||||
return register(registry, itemBlock, block.getRegistryName());
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public interface IRegisterUtil {
|
||||
* @param itemBlock Item block instance to register
|
||||
* @return Registered item block
|
||||
*/
|
||||
default <T extends ItemBlock> T registerItemBlock(IForgeRegistry<Item> registry, T itemBlock) {
|
||||
default <T extends BlockItem> T registerItemBlock(IForgeRegistry<Item> registry, T itemBlock) {
|
||||
return register(registry, itemBlock, itemBlock.getBlock().getRegistryName());
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public interface IRegisterUtil {
|
||||
* @param blocks Blocks needing item blocks
|
||||
* @return Registered item blocks
|
||||
*/
|
||||
default List<ItemBlock> registerItemBlocks(IForgeRegistry<Item> registry, List<? extends Block> blocks) {
|
||||
default List<BlockItem> registerItemBlocks(IForgeRegistry<Item> registry, List<? extends Block> blocks) {
|
||||
return blocks.stream().map((block) -> {
|
||||
return registerItemBlock(registry, block);
|
||||
}).collect(Collectors.toList());
|
||||
@@ -159,7 +159,7 @@ public interface IRegisterUtil {
|
||||
* @param group Group for the item blocks
|
||||
* @return Registered item blocks
|
||||
*/
|
||||
default List<ItemBlock> registerItemBlocks(IForgeRegistry<Item> registry, List<? extends Block> blocks, ItemGroup group) {
|
||||
default List<BlockItem> registerItemBlocks(IForgeRegistry<Item> registry, List<? extends Block> blocks, ItemGroup group) {
|
||||
return blocks.stream().map((block) -> {
|
||||
return registerItemBlock(registry, block, group);
|
||||
}).collect(Collectors.toList());
|
||||
@@ -173,7 +173,7 @@ public interface IRegisterUtil {
|
||||
* @param constructor ItemBlock constructor
|
||||
* @return Registered item block
|
||||
*/
|
||||
default <T extends ItemBlock> List<T> registerItemBlocks(IForgeRegistry<Item> registry, List<? extends Block> blocks, Function<Block,T> constructor) {
|
||||
default <T extends BlockItem> List<T> registerItemBlocks(IForgeRegistry<Item> registry, List<? extends Block> blocks, Function<Block,T> constructor) {
|
||||
return blocks.stream().map((block) -> {
|
||||
return registerItemBlock(registry, constructor.apply(block));
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.google.common.reflect.TypeToken;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.config;
|
||||
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
||||
import net.minecraft.network.play.ServerPlayNetHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -20,13 +20,13 @@ public abstract class AbstractConfigSyncPacket extends AbstractPacket {
|
||||
protected abstract AbstractConfig getConfig();
|
||||
|
||||
@Override
|
||||
public IMessage handleClient(NetHandlerPlayClient netHandler) {
|
||||
public IMessage handleClient(ClientPlayNetHandler netHandler) {
|
||||
sync();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage handleServer(NetHandlerPlayServer netHandler) {
|
||||
public IMessage handleServer(ServerPlayNetHandler netHandler) {
|
||||
// We sync from server to client, not vice versa
|
||||
throw new UnsupportedOperationException("Trying to sync client configs to the server. You registered the packet for the wrong side.");
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package slimeknights.mantle.config;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||
@@ -23,7 +24,7 @@ public class BlockMeta {
|
||||
String val = configurationNode.getString();
|
||||
String[] parts = val.split(":");
|
||||
|
||||
Block block = Block.REGISTRY.getObject(new ResourceLocation(parts[0], parts[1]));
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(parts[0], parts[1]));
|
||||
if(block == Blocks.AIR) {
|
||||
return MISSING;
|
||||
}
|
||||
@@ -53,7 +54,7 @@ public class BlockMeta {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public static BlockMeta of(IBlockState state) {
|
||||
public static BlockMeta of(BlockState state) {
|
||||
return new BlockMeta(state.getBlock(), state.getBlock().getMetaFromState(state));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,101 +1,120 @@
|
||||
package slimeknights.mantle.config;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import slimeknights.mantle.network.NetworkWrapper;
|
||||
|
||||
class ExampleSync {
|
||||
class ExampleSync
|
||||
{
|
||||
|
||||
static NetworkWrapper networkWrapper;
|
||||
|
||||
static ExampleSync INSTANCE;
|
||||
|
||||
static void setup() {
|
||||
static void setup()
|
||||
{
|
||||
networkWrapper = new NetworkWrapper("mantle:example");
|
||||
networkWrapper.registerPacketClient(ExampleSyncPacketImpl.class);
|
||||
networkWrapper.registerPacket(ExampleSyncPacketImpl.class, ExampleSyncPacketImpl::encode, ExampleSyncPacketImpl::decode, ExampleSyncPacketImpl.Handler::handle);
|
||||
INSTANCE = new ExampleSync();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static boolean needsRestart;
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.SERVER)
|
||||
public void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if(event.player instanceof EntityPlayerMP && FMLCommonHandler.instance().getSide().isServer()) {
|
||||
@OnlyIn(Dist.DEDICATED_SERVER)
|
||||
public void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
if (event.getPlayer() instanceof ServerPlayerEntity && FMLEnvironment.dist.isDedicatedServer())
|
||||
{
|
||||
ExampleSyncPacketImpl packet = new ExampleSyncPacketImpl();
|
||||
networkWrapper.network.sendTo(packet, (EntityPlayerMP) event.player);
|
||||
networkWrapper.sendTo(packet, (ServerPlayerEntity) event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void playerJoinedWorld(TickEvent.ClientTickEvent event) {
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
if(needsRestart) {
|
||||
player.sendMessage(new TextComponentString("Configs synced with server. Configs require a restart"));
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void playerJoinedWorld(TickEvent.ClientTickEvent event)
|
||||
{
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
if (needsRestart)
|
||||
{
|
||||
player.sendMessage(new StringTextComponent("Configs synced with server. Configs require a restart"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(new TextComponentString("Configs synced with server."));
|
||||
else
|
||||
{
|
||||
player.sendMessage(new StringTextComponent("Configs synced with server."));
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
}
|
||||
|
||||
static class ExampleConfig extends AbstractConfig {
|
||||
static class ExampleConfig extends AbstractConfig
|
||||
{
|
||||
static ExampleConfig INSTANCE = new ExampleConfig();
|
||||
|
||||
ExampleConfigFile exampleConfigFile;
|
||||
|
||||
// call from preinit or something
|
||||
public void onPreInit(FMLPreInitializationEvent event) {
|
||||
exampleConfigFile = this.load(new ExampleConfigFile(event.getModConfigurationDirectory()), ExampleConfigFile.class);
|
||||
public void onPreInit(final FMLCommonSetupEvent event)
|
||||
{
|
||||
exampleConfigFile = this.load(new ExampleConfigFile(FMLPaths.CONFIGDIR.get().toFile()), ExampleConfigFile.class);
|
||||
|
||||
// register this serverside to sync
|
||||
if(event.getSide().isServer()) {
|
||||
if (FMLEnvironment.dist.isDedicatedServer())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class ExampleConfigFile extends AbstractConfigFile {
|
||||
static class ExampleConfigFile extends AbstractConfigFile
|
||||
{
|
||||
|
||||
public ExampleConfigFile(File configFolder) {
|
||||
public ExampleConfigFile(File configFolder)
|
||||
{
|
||||
super(configFolder, "exampleconfigfile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertDefaults() {
|
||||
public void insertDefaults()
|
||||
{
|
||||
// no default values that need to initialized dynamically
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getConfigVersion() {
|
||||
protected int getConfigVersion()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static class ExampleSyncPacketImpl extends AbstractConfigSyncPacket {
|
||||
static class ExampleSyncPacketImpl extends AbstractConfigSyncPacket
|
||||
{
|
||||
|
||||
@Override
|
||||
protected AbstractConfig getConfig() {
|
||||
protected static AbstractConfig getConfig()
|
||||
{
|
||||
return ExampleConfig.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean sync() {
|
||||
if(super.sync()) {
|
||||
protected boolean sync()
|
||||
{
|
||||
if (super.sync())
|
||||
{
|
||||
// clientside register only
|
||||
MinecraftForge.EVENT_BUS.register(INSTANCE);
|
||||
return true;
|
||||
|
||||
@@ -3,21 +3,21 @@ package slimeknights.mantle.inventory;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.INameable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -46,7 +46,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
this(tile, null);
|
||||
}
|
||||
|
||||
public BaseContainer(T tile, EnumFacing invDir) {
|
||||
public BaseContainer(T tile, Direction invDir) {
|
||||
this.tile = tile;
|
||||
|
||||
if(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, invDir).isPresent()) {
|
||||
@@ -61,10 +61,10 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
this.originalBlock = world.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
public void syncOnOpen(EntityPlayerMP playerOpened) {
|
||||
public void syncOnOpen(ServerPlayerEntity playerOpened) {
|
||||
// find another player that already has the gui for this tile open
|
||||
WorldServer server = playerOpened.getServerWorld();
|
||||
for(EntityPlayer player : server.playerEntities) {
|
||||
ServerWorld server = playerOpened.getServerWorld();
|
||||
for(PlayerEntity player : server.playerEntities) {
|
||||
if(player == playerOpened) {
|
||||
continue;
|
||||
}
|
||||
@@ -92,14 +92,14 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
* Called when the container is opened and another player already has a container for this tile open
|
||||
* Sync to the same state here.
|
||||
*/
|
||||
protected void syncWithOtherContainer(BaseContainer<T> otherContainer, EntityPlayerMP player) {
|
||||
protected void syncWithOtherContainer(BaseContainer<T> otherContainer, ServerPlayerEntity player) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the container is opened and no other player has it open.
|
||||
* Set the default state here.
|
||||
*/
|
||||
protected void syncNewContainer(EntityPlayerMP player) {
|
||||
protected void syncNewContainer(ServerPlayerEntity player) {
|
||||
}
|
||||
|
||||
public boolean sameGui(BaseContainer otherContainer) {
|
||||
@@ -107,7 +107,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull EntityPlayer playerIn) {
|
||||
public boolean canInteractWith(@Nonnull PlayerEntity playerIn) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
// does the block we interacted with still exist?
|
||||
if(block == Blocks.AIR || block != originalBlock) {
|
||||
@@ -158,7 +158,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
* @param xCorner Default Value: 8
|
||||
* @param yCorner Default Value: (rows - 4) * 18 + 103
|
||||
*/
|
||||
protected void addPlayerInventory(InventoryPlayer playerInventory, int xCorner, int yCorner) {
|
||||
protected void addPlayerInventory(PlayerInventory playerInventory, int xCorner, int yCorner) {
|
||||
int index = 9;
|
||||
|
||||
int start = this.inventorySlots.size();
|
||||
@@ -190,7 +190,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
|
||||
// we can only support inventory <-> playerInventory
|
||||
if(playerInventoryStart < 0) {
|
||||
// so we don't do anything if no player inventory is present because we don't know what to do
|
||||
|
||||
@@ -4,11 +4,11 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -88,7 +88,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull EntityPlayer playerIn) {
|
||||
public boolean canInteractWith(@Nonnull PlayerEntity playerIn) {
|
||||
// check if subcontainers are valid
|
||||
for(Container sub : subContainers) {
|
||||
if(!sub.canInteractWith(playerIn)) {
|
||||
@@ -101,7 +101,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer playerIn) {
|
||||
public void onContainerClosed(PlayerEntity playerIn) {
|
||||
for(Container sub : subContainers) {
|
||||
sub.onContainerClosed(playerIn);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int dragType, ClickType type, EntityPlayer player) {
|
||||
public ItemStack slotClick(int slotId, int dragType, ClickType type, PlayerEntity player) {
|
||||
if(slotId == -999 && type == ClickType.QUICK_CRAFT) {
|
||||
for(Container container : subContainers) {
|
||||
container.slotClick(slotId, dragType, type, player);
|
||||
@@ -125,7 +125,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
// Takes submodules into account when shiftclicking!
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if(slot == null || !slot.getHasStack()) {
|
||||
@@ -178,7 +178,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected ItemStack notifySlotAfterTransfer(EntityPlayer player, @Nonnull ItemStack stack, @Nonnull ItemStack original, Slot slot) {
|
||||
protected ItemStack notifySlotAfterTransfer(PlayerEntity player, @Nonnull ItemStack stack, @Nonnull ItemStack original, Slot slot) {
|
||||
// notify slot
|
||||
slot.onSlotChange(stack, original);
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package slimeknights.mantle.inventory;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
|
||||
import slimeknights.mantle.tileentity.TileInventory;
|
||||
|
||||
public class ContainerSimpleChest extends BaseContainer<TileInventory> {
|
||||
|
||||
public ContainerSimpleChest(TileInventory tile, int rows, int columns, InventoryPlayer playerInventory) {
|
||||
public ContainerSimpleChest(TileInventory tile, int rows, int columns, PlayerInventory playerInventory) {
|
||||
super(tile);
|
||||
|
||||
int index = 0;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package slimeknights.mantle.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IContainerCraftingCustom {
|
||||
|
||||
void onCrafting(EntityPlayer player, ItemStack output, IInventory craftMatrix);
|
||||
void onCrafting(PlayerEntity player, ItemStack output, IInventory craftMatrix);
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
package slimeknights.mantle.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.container.CraftingResultSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SlotCraftingCustom extends SlotCrafting {
|
||||
public class SlotCraftingCustom extends CraftingResultSlot
|
||||
{
|
||||
|
||||
private final InventoryCrafting craftMatrix;
|
||||
private final CraftingInventory craftMatrix;
|
||||
private final IContainerCraftingCustom callback;
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ public class SlotCraftingCustom extends SlotCrafting {
|
||||
* @param craftingInventory Inventory where the ingredients are taken from
|
||||
* @param craftResult Inventory where the result is put
|
||||
*/
|
||||
public SlotCraftingCustom(IContainerCraftingCustom callback, EntityPlayer player, InventoryCrafting craftingInventory, IInventory craftResult, int slotIndex, int xPosition, int yPosition) {
|
||||
public SlotCraftingCustom(IContainerCraftingCustom callback, PlayerEntity player, CraftingInventory craftingInventory, IInventory craftResult, int slotIndex, int xPosition, int yPosition) {
|
||||
super(player, craftingInventory, craftResult, slotIndex, xPosition, yPosition);
|
||||
|
||||
this.craftMatrix = craftingInventory;
|
||||
@@ -28,7 +29,7 @@ public class SlotCraftingCustom extends SlotCrafting {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack onTake(EntityPlayer playerIn, @Nonnull ItemStack stack) {
|
||||
public ItemStack onTake(PlayerEntity playerIn, @Nonnull ItemStack stack) {
|
||||
net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, craftMatrix);
|
||||
this.onCrafting(stack);
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package slimeknights.mantle.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/** Slot that can only be taken out of */
|
||||
public class SlotOut extends Slot {
|
||||
public class SlotOut extends Slot
|
||||
{
|
||||
|
||||
public SlotOut(IInventory inventoryIn, int index, int xPosition, int yPosition) {
|
||||
super(inventoryIn, index, xPosition, yPosition);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package slimeknights.mantle.inventory;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -39,7 +39,7 @@ public class SlotWrapper extends Slot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer playerIn) {
|
||||
public boolean canTakeStack(PlayerEntity playerIn) {
|
||||
return parent.canTakeStack(playerIn);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SlotWrapper extends Slot {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
|
||||
public ItemStack onTake(PlayerEntity playerIn, ItemStack stack) {
|
||||
parent.onTake(playerIn, stack);
|
||||
|
||||
return stack;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package slimeknights.mantle.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
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;
|
||||
@@ -16,9 +16,10 @@ import javax.annotation.Nullable;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class ItemArmorTooltip extends ItemArmor {
|
||||
public class ItemArmorTooltip extends ArmorItem
|
||||
{
|
||||
|
||||
public ItemArmorTooltip(IArmorMaterial armorMaterial, EntityEquipmentSlot equipmentSlot, Item.Properties builder) {
|
||||
public ItemArmorTooltip(IArmorMaterial armorMaterial, EquipmentSlotType equipmentSlot, Item.Properties builder) {
|
||||
super(armorMaterial, equipmentSlot, builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package slimeknights.mantle.multiblock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -19,7 +19,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
boolean hasMaster;
|
||||
BlockPos master;
|
||||
Block masterBlock;
|
||||
IBlockState state;
|
||||
BlockState state;
|
||||
|
||||
public MultiServantLogic(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
@@ -105,7 +105,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
}
|
||||
}
|
||||
|
||||
public void readCustomNBT(NBTTagCompound tags) {
|
||||
public void readCustomNBT(CompoundNBT tags) {
|
||||
this.hasMaster = tags.getBoolean("hasMaster");
|
||||
if(this.hasMaster) {
|
||||
int xCenter = tags.getInt("xCenter");
|
||||
@@ -117,7 +117,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeCustomNBT(NBTTagCompound tags) {
|
||||
public CompoundNBT writeCustomNBT(CompoundNBT tags) {
|
||||
tags.putBoolean("hasMaster", this.hasMaster);
|
||||
if(this.hasMaster) {
|
||||
tags.putInt("xCenter", this.master.getX());
|
||||
@@ -130,14 +130,14 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tags) {
|
||||
public void read(CompoundNBT tags) {
|
||||
super.read(tags);
|
||||
this.readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tags) {
|
||||
public CompoundNBT write(CompoundNBT tags) {
|
||||
tags = super.write(tags);
|
||||
return this.writeCustomNBT(tags);
|
||||
}
|
||||
@@ -145,17 +145,17 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
/* Packets */
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
public CompoundNBT getUpdateTag() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
this.writeCustomNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) {
|
||||
this.readCustomNBT(packet.getNbtCompound());
|
||||
this.world.notifyLightSet(this.pos);
|
||||
IBlockState state = world.getBlockState(this.pos);
|
||||
BlockState state = world.getBlockState(this.pos);
|
||||
this.world.notifyBlockUpdate(this.pos, state, state, 3);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.network;
|
||||
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
||||
import net.minecraft.network.play.ServerPlayNetHandler;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
@@ -9,9 +9,9 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public abstract class AbstractPacket implements IMessage {
|
||||
|
||||
public abstract IMessage handleClient(NetHandlerPlayClient netHandler);
|
||||
public abstract IMessage handleClient(ClientPlayNetHandler netHandler);
|
||||
|
||||
public abstract IMessage handleServer(NetHandlerPlayServer netHandler);
|
||||
public abstract IMessage handleServer(ServerPlayNetHandler netHandler);
|
||||
|
||||
protected void writePos(BlockPos pos, ByteBuf buf) {
|
||||
buf.writeInt(pos.getX());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package slimeknights.mantle.network;
|
||||
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
||||
import net.minecraft.network.play.ServerPlayNetHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
public abstract class AbstractPacketThreadsafe extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public final IMessage handleClient(final NetHandlerPlayClient netHandler) {
|
||||
public final IMessage handleClient(final ClientPlayNetHandler netHandler) {
|
||||
FMLCommonHandler.instance().getWorldThread(netHandler).addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -24,7 +24,7 @@ public abstract class AbstractPacketThreadsafe extends AbstractPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IMessage handleServer(final NetHandlerPlayServer netHandler) {
|
||||
public final IMessage handleServer(final ServerPlayNetHandler netHandler) {
|
||||
FMLCommonHandler.instance().getWorldThread(netHandler).addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -34,7 +34,7 @@ public abstract class AbstractPacketThreadsafe extends AbstractPacket {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void handleClientSafe(NetHandlerPlayClient netHandler);
|
||||
public abstract void handleClientSafe(ClientPlayNetHandler netHandler);
|
||||
|
||||
public abstract void handleServerSafe(NetHandlerPlayServer netHandler);
|
||||
public abstract void handleServerSafe(ServerPlayNetHandler netHandler);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
@@ -39,7 +39,7 @@ public class NetworkWrapper {
|
||||
network.sendToServer(msg);
|
||||
}
|
||||
|
||||
public void sendTo(Object msg, EntityPlayerMP player) {
|
||||
public void sendTo(Object msg, ServerPlayerEntity player) {
|
||||
if(!(player instanceof FakePlayer)) {
|
||||
network.sendTo(msg, player.connection.netManager, NetworkDirection.PLAY_TO_CLIENT);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package slimeknights.mantle.network.book;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import slimeknights.mantle.client.book.BookHelper;
|
||||
@@ -34,9 +34,9 @@ public class PacketUpdateSavedPage {
|
||||
public static void handle(final PacketUpdateSavedPage pkt, final Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if(ctx.get().getSender() != null && pkt.pageName != null) {
|
||||
EntityPlayer player = ctx.get().getSender();
|
||||
PlayerEntity player = ctx.get().getSender();
|
||||
|
||||
ItemStack is = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
ItemStack is = player.getHeldItem(Hand.MAIN_HAND);
|
||||
|
||||
if(!is.isEmpty()) {
|
||||
BookHelper.writeSavedPage(is, pkt.pageName);
|
||||
|
||||
@@ -5,33 +5,33 @@ import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class PropertyUnlistedDirection extends DirectionProperty implements IUnlistedProperty<EnumFacing> {
|
||||
public class PropertyUnlistedDirection extends DirectionProperty implements IUnlistedProperty<Direction> {
|
||||
|
||||
public PropertyUnlistedDirection(String name, Collection<EnumFacing> values) {
|
||||
public PropertyUnlistedDirection(String name, Collection<Direction> values) {
|
||||
super(name, values);
|
||||
}
|
||||
|
||||
public PropertyUnlistedDirection(String name, Predicate<EnumFacing> filter) {
|
||||
this(name, Collections2.filter(Lists.newArrayList(EnumFacing.values()), filter));
|
||||
public PropertyUnlistedDirection(String name, Predicate<Direction> filter) {
|
||||
this(name, Collections2.filter(Lists.newArrayList(Direction.values()), filter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(EnumFacing value) {
|
||||
public boolean isValid(Direction value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EnumFacing> getType() {
|
||||
public Class<Direction> getType() {
|
||||
return this.getValueClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(EnumFacing value) {
|
||||
public String valueToString(Direction value) {
|
||||
return getName(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package slimeknights.mantle.tileentity;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.INameable;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
@@ -55,7 +54,7 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(@Nonnull Capability<T> capability, EnumFacing facing) {
|
||||
public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(@Nonnull Capability<T> capability, Direction facing) {
|
||||
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return itemHandlerCap.cast();
|
||||
}
|
||||
@@ -211,16 +210,16 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
if(hasCustomName()) {
|
||||
return new TextComponentString(getName().getFormattedText());
|
||||
return new StringTextComponent(getName().getFormattedText());
|
||||
}
|
||||
|
||||
return new TextComponentTranslation(getName().getFormattedText());
|
||||
return new TranslationTextComponent(getName().getFormattedText());
|
||||
}
|
||||
|
||||
|
||||
/* Supporting methods */
|
||||
@Override
|
||||
public boolean isUsableByPlayer(@Nonnull EntityPlayer entityplayer) {
|
||||
public boolean isUsableByPlayer(@Nonnull PlayerEntity entityplayer) {
|
||||
// block changed/got broken?
|
||||
if(world.getTileEntity(pos) != this || world.getBlockState(pos).getBlock() == Blocks.AIR) {
|
||||
return false;
|
||||
@@ -232,18 +231,18 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(@Nonnull EntityPlayer player) {
|
||||
public void openInventory(@Nonnull PlayerEntity player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(@Nonnull EntityPlayer player) {
|
||||
public void closeInventory(@Nonnull PlayerEntity player) {
|
||||
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void read(NBTTagCompound tags) {
|
||||
public void read(CompoundNBT tags) {
|
||||
super.read(tags);
|
||||
this.resizeInternal(tags.getInt("InventorySize"));
|
||||
|
||||
@@ -256,7 +255,7 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tags) {
|
||||
public CompoundNBT write(CompoundNBT tags) {
|
||||
super.write(tags);
|
||||
|
||||
tags.putInt("InventorySize", inventory.size());
|
||||
@@ -270,13 +269,13 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
}
|
||||
|
||||
/** Writes the contents of the inventory to the tag */
|
||||
public void writeInventoryToNBT(NBTTagCompound tag) {
|
||||
public void writeInventoryToNBT(CompoundNBT tag) {
|
||||
IInventory inventory = this;
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
ListNBT nbttaglist = new ListNBT();
|
||||
|
||||
for(int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if(!inventory.getStackInSlot(i).isEmpty()) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
CompoundNBT itemTag = new CompoundNBT();
|
||||
itemTag.putByte("Slot", (byte) i);
|
||||
inventory.getStackInSlot(i).write(itemTag);
|
||||
nbttaglist.add(itemTag);
|
||||
@@ -287,13 +286,13 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
}
|
||||
|
||||
/** Reads a an inventory from the tag. Overwrites current content */
|
||||
public void readInventoryFromNBT(NBTTagCompound tag) {
|
||||
NBTTagList nbttaglist = tag.getList("Items", 10);
|
||||
public void readInventoryFromNBT(CompoundNBT tag) {
|
||||
ListNBT nbttaglist = tag.getList("Items", 10);
|
||||
|
||||
int limit = getInventoryStackLimit();
|
||||
ItemStack stack;
|
||||
for(int i = 0; i < nbttaglist.size(); ++i) {
|
||||
NBTTagCompound itemTag = nbttaglist.getCompound(i);
|
||||
CompoundNBT itemTag = nbttaglist.getCompound(i);
|
||||
int slot = itemTag.getByte("Slot") & 255;
|
||||
|
||||
if(slot >= 0 && slot < inventory.size()) {
|
||||
@@ -312,21 +311,6 @@ public class TileInventory extends MantleTileEntity implements IInventory {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (ItemStack itemstack : this.inventory) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package slimeknights.mantle.util;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -33,11 +33,11 @@ public abstract class LocUtils {
|
||||
int k;
|
||||
while((k = text.indexOf("\\n", j)) >= 0)
|
||||
{
|
||||
list.add(new TextComponentString(text.substring(j, k)));
|
||||
list.add(new StringTextComponent(text.substring(j, k)));
|
||||
j = k+2;
|
||||
}
|
||||
|
||||
list.add(new TextComponentString(text.substring(j, text.length())));
|
||||
list.add(new StringTextComponent(text.substring(j, text.length())));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
package slimeknights.mantle.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
|
||||
public class TagHelper {
|
||||
|
||||
public static int TAG_TYPE_STRING = (new NBTTagString()).getId();
|
||||
public static int TAG_TYPE_COMPOUND = (new NBTTagCompound()).getId();
|
||||
public static int TAG_TYPE_STRING = (new StringNBT()).getId();
|
||||
public static int TAG_TYPE_COMPOUND = (new CompoundNBT()).getId();
|
||||
|
||||
private TagHelper() {
|
||||
}
|
||||
|
||||
/* Generic Tag Operations */
|
||||
public static NBTTagCompound getTagSafe(ItemStack stack) {
|
||||
public static CompoundNBT getTagSafe(ItemStack stack) {
|
||||
if(stack.isEmpty() || !stack.hasTag()) {
|
||||
return new NBTTagCompound();
|
||||
return new CompoundNBT();
|
||||
}
|
||||
|
||||
return stack.getTag();
|
||||
}
|
||||
|
||||
public static NBTTagCompound getTagSafe(NBTTagCompound tag, String key) {
|
||||
public static CompoundNBT getTagSafe(CompoundNBT tag, String key) {
|
||||
if(tag == null || !tag.contains(key)) {
|
||||
return new NBTTagCompound();
|
||||
return new CompoundNBT();
|
||||
}
|
||||
|
||||
return tag.getCompound(key);
|
||||
}
|
||||
|
||||
public static NBTTagList getTagListSafe(NBTTagCompound tag, String key, int type) {
|
||||
public static ListNBT getTagListSafe(CompoundNBT tag, String key, int type) {
|
||||
if(tag == null || !tag.contains(key)) {
|
||||
return new NBTTagList();
|
||||
return new ListNBT();
|
||||
}
|
||||
|
||||
return tag.getList(key, type);
|
||||
|
||||
@@ -3,15 +3,16 @@ package slimeknights.mantle.util;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.entity.IMerchant;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityVillager.PriceInfo;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.entity.merchant.IMerchant;
|
||||
import net.minecraft.entity.merchant.villager.VillagerEntity;
|
||||
import net.minecraft.entity.merchant.villager.VillagerEntity.PriceInfo;
|
||||
import net.minecraft.entity.merchant.villager.VillagerTrades;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
|
||||
public class TradeGeneric implements EntityVillager.ITradeList {
|
||||
public class TradeGeneric implements VillagerTrades.ITrade {
|
||||
private ItemStack input, input2, output;
|
||||
private PriceInfo inputPrice, input2Price, outputPrice;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager.PriceInfo;
|
||||
import net.minecraft.entity.merchant.villager.VillagerEntity.PriceInfo;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TradeRandom extends TradeGeneric {
|
||||
|
||||
Reference in new issue
Block a user