Merge pull request #2 from Zixiken/1.10

1.10
This commit is contained in:
Mathijs Riezebos 2017-01-11 21:54:37 +01:00 committed by GitHub
commit db809a8219
14 changed files with 39 additions and 33 deletions

View file

@ -15,8 +15,6 @@ import static net.minecraft.item.Item.getItemFromBlock;
@SuppressWarnings({"MethodCallSideOnly", "NewExpressionSideOnly"}) @SuppressWarnings({"MethodCallSideOnly", "NewExpressionSideOnly"})
public class ModelManager { public class ModelManager {
private static final String ID = DimDoors.MODID;
public static void registerModels() { public static void registerModels() {
//ItemBlock registration //ItemBlock registration
register(getItemFromBlock(ModBlocks.blockDimWall)); register(getItemFromBlock(ModBlocks.blockDimWall));
@ -24,7 +22,6 @@ public class ModelManager {
register(getItemFromBlock(ModBlocks.blockDimWall), 2, "Altered"); register(getItemFromBlock(ModBlocks.blockDimWall), 2, "Altered");
register(getItemFromBlock(ModBlocks.blockRift)); register(getItemFromBlock(ModBlocks.blockRift));
register(getItemFromBlock(ModBlocks.blockDimDoorTransient));
register(getItemFromBlock(ModBlocks.blockDimHatch)); register(getItemFromBlock(ModBlocks.blockDimHatch));
//Item registration //Item registration
@ -41,19 +38,19 @@ public class ModelManager {
public static void registerModelVariants() { public static void registerModelVariants() {
ModelBakery.registerItemVariants(getItemFromBlock(ModBlocks.blockDimWall), ModelBakery.registerItemVariants(getItemFromBlock(ModBlocks.blockDimWall),
new ResourceLocation(ID + ":blockDimWall"), ModBlocks.blockDimWall.getRegistryName(),
new ResourceLocation(ID + ":blockDimWallAncient"), new ResourceLocation(ModBlocks.blockDimWall.getRegistryName() + "Ancient"),
new ResourceLocation(ID + ":blockDimWallAltered")); new ResourceLocation(ModBlocks.blockDimWall.getRegistryName() + "Altered"));
} }
private static void register(Item item) { private static void register(Item item) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
new ModelResourceLocation(ID + ':' + item.getUnlocalizedName().substring(5), "inventory")); new ModelResourceLocation(item.getRegistryName(), "inventory"));
} }
private static void register(Item item, int meta, String name) { private static void register(Item item, int meta, String name) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta,
new ModelResourceLocation(ID + ':' + item.getUnlocalizedName().substring(5) + name, "inventory")); new ModelResourceLocation(item.getRegistryName() + name, "inventory"));
} }
@SuppressWarnings("LocalVariableDeclarationSideOnly") @SuppressWarnings("LocalVariableDeclarationSideOnly")

View file

@ -27,6 +27,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@SuppressWarnings("deprecation")
public class BlockDimWall extends Block { public class BlockDimWall extends Block {
public static final String ID = "blockDimWall"; public static final String ID = "blockDimWall";
public static final PropertyInteger TYPE = PropertyInteger.create("type", 0, 2); public static final PropertyInteger TYPE = PropertyInteger.create("type", 0, 2);
@ -107,18 +108,15 @@ public class BlockDimWall extends Block {
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric //Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric
ItemStack playerEquip = player.getHeldItemMainhand(); if (heldItem != null && state.getValue(TYPE) != 1) {
if (playerEquip != null && state.getValue(TYPE) != 1) { Block block = Block.getBlockFromItem(heldItem.getItem());
Block block = Block.getBlockFromItem(playerEquip.getItem()); if (!state.isNormalCube() || block instanceof BlockContainer || block == this)
if (block != null) { return false;
if (!block.isNormalCube(state) || block instanceof BlockContainer || block == this) if (!world.isRemote) {
return false; if (!player.capabilities.isCreativeMode) heldItem.stackSize--;
if (!world.isRemote) { world.setBlockState(pos, state);
if (!player.capabilities.isCreativeMode) playerEquip.stackSize--; }
world.setBlockState(pos, block.getStateFromMeta(playerEquip.getItemDamage())); return true;
}
return true;
}
} }
return false; return false;
} }

View file

@ -30,6 +30,7 @@ import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@SuppressWarnings("deprecation")
public class BlockRift extends Block implements ITileEntityProvider { public class BlockRift extends Block implements ITileEntityProvider {
private static final float MIN_IMMUNE_RESISTANCE = 5000.0F; private static final float MIN_IMMUNE_RESISTANCE = 5000.0F;
public static final String ID = "blockRift"; public static final String ID = "blockRift";

View file

@ -15,6 +15,7 @@ public class ItemDimDoor extends ItemDoorBase {
public ItemDimDoor() { public ItemDimDoor() {
super(ModBlocks.blockDimDoor, (ItemDoor)Items.IRON_DOOR); super(ModBlocks.blockDimDoor, (ItemDoor)Items.IRON_DOOR);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
@Override @Override

View file

@ -13,6 +13,7 @@ public class ItemDimDoorGold extends ItemDoorBase {
public ItemDimDoorGold() { public ItemDimDoorGold() {
super(ModBlocks.blockDimDoorGold, ModItems.itemDoorGold); super(ModBlocks.blockDimDoorGold, ModItems.itemDoorGold);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {

View file

@ -13,6 +13,7 @@ public class ItemDimDoorPersonal extends ItemDoorBase {
public ItemDimDoorPersonal() { public ItemDimDoorPersonal() {
super(ModBlocks.blockDimDoorPersonal, ModItems.itemDoorQuartz); super(ModBlocks.blockDimDoorPersonal, ModItems.itemDoorQuartz);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
@Override @Override

View file

@ -13,6 +13,7 @@ public class ItemDimDoorUnstable extends ItemDoorBase {
public ItemDimDoorUnstable() { public ItemDimDoorUnstable() {
super(ModBlocks.blockDimDoorChaos, null); super(ModBlocks.blockDimDoorChaos, null);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
@Override @Override

View file

@ -16,6 +16,7 @@ public class ItemDimDoorWarp extends ItemDoorBase {
public ItemDimDoorWarp() { public ItemDimDoorWarp() {
super(ModBlocks.blockDimDoorWarp, (ItemDoor)Items.OAK_DOOR ); super(ModBlocks.blockDimDoorWarp, (ItemDoor)Items.OAK_DOOR );
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
@Override @Override

View file

@ -7,6 +7,7 @@ import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.blocks.BlockDimDoorBase; import com.zixiken.dimdoors.blocks.BlockDimDoorBase;
import com.zixiken.dimdoors.blocks.ModBlocks; import com.zixiken.dimdoors.blocks.ModBlocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -75,8 +76,8 @@ public abstract class ItemDoorBase extends ItemDoor {
ItemDoorBase mappedItem = doorItemMapping.get(stack.getItem()); ItemDoorBase mappedItem = doorItemMapping.get(stack.getItem());
if (mappedItem == null) return false; if (mappedItem == null) return false;
BlockDimDoorBase doorBlock = mappedItem.getDoorBlock(); BlockDimDoorBase doorBlock = mappedItem.getDoorBlock();
if (ItemDoorBase.placeDoorOnBlock(doorBlock, stack, player, world, pos, side)) return true; return ItemDoorBase.placeDoorOnBlock(doorBlock, stack, player, world, pos, side) ||
return ItemDoorBase.placeDoorOnRift(doorBlock, world, player, stack); ItemDoorBase.placeDoorOnRift(doorBlock, world, player, stack);
} }
/** /**
@ -143,9 +144,9 @@ public abstract class ItemDoorBase extends ItemDoor {
} }
public static boolean canPlace(World world, BlockPos pos) { public static boolean canPlace(World world, BlockPos pos) {
Block block = world.getBlockState(pos).getBlock(); IBlockState state = world.getBlockState(pos);
return (block == ModBlocks.blockRift || world.getBlockState(pos).equals(Blocks.AIR) || block.getMaterial(world.getBlockState(pos)).isReplaceable()); return (state.getBlock() == ModBlocks.blockRift || state.equals(Blocks.AIR) || state.getMaterial().isReplaceable());
} }
/** /**

View file

@ -10,5 +10,6 @@ public class ItemDoorGold extends ItemDoor {
super(ModBlocks.blockDoorGold); super(ModBlocks.blockDoorGold);
setMaxStackSize(16); setMaxStackSize(16);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
} }

View file

@ -9,5 +9,6 @@ public class ItemDoorQuartz extends ItemDoor {
public ItemDoorQuartz() { public ItemDoorQuartz() {
super(ModBlocks.blockDoorQuartz); super(ModBlocks.blockDoorQuartz);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
} }

View file

@ -10,5 +10,6 @@ public class ItemStableFabric extends Item {
super(); super();
setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
} }

View file

@ -10,5 +10,6 @@ public class ItemWorldThread extends Item {
super(); super();
setCreativeTab(DimDoors.dimDoorsCreativeTab); setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(ID);
} }
} }

View file

@ -17,15 +17,15 @@ public class ModItems {
public static ItemBlockDimWall itemBlockDimWall; public static ItemBlockDimWall itemBlockDimWall;
public static void registerItems() { public static void registerItems() {
GameRegistry.registerItem(itemDoorQuartz = new ItemDoorQuartz(), ItemDoorQuartz.ID); GameRegistry.register(itemDoorQuartz = new ItemDoorQuartz());
GameRegistry.registerItem(itemDimDoorPersonal = new ItemDimDoorPersonal(), ItemDimDoorPersonal.ID); GameRegistry.register(itemDimDoorPersonal = new ItemDimDoorPersonal());
GameRegistry.registerItem(itemDoorGold = new ItemDoorGold(), ItemDoorGold.ID); GameRegistry.register(itemDoorGold = new ItemDoorGold());
GameRegistry.registerItem(itemDimDoorGold = new ItemDimDoorGold(), ItemDimDoorGold.ID); GameRegistry.register(itemDimDoorGold = new ItemDimDoorGold());
GameRegistry.registerItem(itemDimDoor = new ItemDimDoor(), ItemDimDoor.ID); GameRegistry.register(itemDimDoor = new ItemDimDoor());
GameRegistry.registerItem(itemDimDoorWarp = new ItemDimDoorWarp(), ItemDimDoorWarp.ID); GameRegistry.register(itemDimDoorWarp = new ItemDimDoorWarp());
GameRegistry.registerItem(itemStableFabric = new ItemStableFabric(), ItemStableFabric.ID); GameRegistry.register(itemStableFabric = new ItemStableFabric());
GameRegistry.registerItem(itemDimDoorChaos = new ItemDimDoorUnstable(), ItemDimDoorUnstable.ID); GameRegistry.register(itemDimDoorChaos = new ItemDimDoorUnstable());
GameRegistry.registerItem(itemWorldThread = new ItemWorldThread(), ItemWorldThread.ID); GameRegistry.register(itemWorldThread = new ItemWorldThread());
//ItemBlocks //ItemBlocks
GameRegistry.register(itemBlockDimWall = new ItemBlockDimWall()); GameRegistry.register(itemBlockDimWall = new ItemBlockDimWall());