mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Replaced some method calls
This commit is contained in:
parent
47568e5fbc
commit
8ba1d23eff
14 changed files with 31 additions and 57 deletions
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
|||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -53,7 +54,7 @@ public class BlockCoalGenerator extends BlockContainerBase{
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||
int meta = state.getBlock().getMetaFromState(state);
|
||||
int meta = PosUtil.getMetadata(state);
|
||||
|
||||
if(meta == 1){
|
||||
for(int i = 0; i < 5; i++){
|
||||
|
|
|
@ -68,7 +68,7 @@ public class BlockColoredLamp extends BlockBase{
|
|||
//Turning On
|
||||
if(player.isSneaking()){
|
||||
if(!world.isRemote){
|
||||
PosUtil.setBlock(pos, world, this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn, state.getBlock().getMetaFromState(state), 2);
|
||||
PosUtil.setBlock(pos, world, this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn, PosUtil.getMetadata(state), 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class BlockColoredLamp extends BlockBase{
|
|||
String name = OreDictionary.getOreName(oreID);
|
||||
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
|
||||
if(color != null){
|
||||
if(state.getBlock().getMetaFromState(state) != color.ordinal()){
|
||||
if(PosUtil.getMetadata(state) != color.ordinal()){
|
||||
if(!world.isRemote){
|
||||
PosUtil.setMetadata(pos, world, color.ordinal(), 2);
|
||||
if(!player.capabilities.isCreativeMode){
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BlockFurnaceDouble extends BlockContainerBase{
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||
int meta = state.getBlock().getMetaFromState(state);
|
||||
int meta = PosUtil.getMetadata(state);
|
||||
|
||||
if(meta > 3){
|
||||
float f = (float)pos.getX()+0.5F;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BlockGrinder extends BlockContainerBase{
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||
int meta = state.getBlock().getMetaFromState(state);
|
||||
int meta = PosUtil.getMetadata(state);
|
||||
|
||||
if(meta == 1){
|
||||
for(int i = 0; i < 5; i++){
|
||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
|||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -53,7 +54,7 @@ public class BlockOilGenerator extends BlockContainerBase{
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||
if(state.getBlock().getMetaFromState(state) == 1){
|
||||
if(PosUtil.getMetadata(state) == 1){
|
||||
for(int i = 0; i < 5; i++){
|
||||
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BlockWildPlant extends BlockBushBase{
|
|||
@Override
|
||||
public boolean canBlockStay(World world, BlockPos pos, IBlockState state){
|
||||
BlockPos offset = PosUtil.offset(pos, 0, -1, 0);
|
||||
return state.getBlock().getMetaFromState(state) == TheWildPlants.RICE.ordinal() ? PosUtil.getMaterial(offset, world) == Material.water : PosUtil.getBlock(offset, world).canSustainPlant(world, offset, EnumFacing.UP, this);
|
||||
return PosUtil.getMetadata(state) == TheWildPlants.RICE.ordinal() ? PosUtil.getMaterial(offset, world) == Material.water : PosUtil.getBlock(offset, world).canSustainPlant(world, offset, EnumFacing.UP, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public class BlockWildPlant extends BlockBushBase{
|
|||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
|
||||
int metadata = state.getBlock().getMetaFromState(state);
|
||||
int metadata = PosUtil.getMetadata(state);
|
||||
return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, pos, allWildPlants[metadata].wildVersionOf.getStateFromMeta(7), fortune);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockWall;
|
||||
|
@ -134,7 +135,7 @@ public class BlockWallAA extends BlockBase{
|
|||
}
|
||||
|
||||
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos){
|
||||
Block block = worldIn.getBlockState(pos).getBlock();
|
||||
Block block = PosUtil.getBlock(pos, worldIn);
|
||||
return block != Blocks.barrier && (!(block != this && !(block instanceof BlockFenceGate)) || ((block.getMaterial().isOpaque() && block.isFullCube()) && block.getMaterial() != Material.gourd));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,13 @@ import de.ellpeck.actuallyadditions.mod.booklet.button.IndexButton;
|
|||
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllSearch;
|
||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.*;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
@ -51,7 +55,7 @@ public class BookletUtils{
|
|||
public static void openBrowser(String url, String shiftUrl){
|
||||
try{
|
||||
if(Desktop.isDesktopSupported()){
|
||||
if(shiftUrl.equals(url) || KeyUtil.isShiftPressed()){
|
||||
if(shiftUrl.equals(url) || GuiScreen.isShiftKeyDown()){
|
||||
Desktop.getDesktop().browse(new URI(shiftUrl));
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -15,9 +15,9 @@ import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
|||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.KeyUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
@ -37,7 +37,7 @@ public class BookmarkButton extends GuiButton{
|
|||
|
||||
public void onPressed(){
|
||||
if(this.assignedEntry.entry != null){
|
||||
if(KeyUtil.isShiftPressed()){
|
||||
if(GuiScreen.isShiftKeyDown()){
|
||||
this.assignedEntry.removeEntry();
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
package de.ellpeck.actuallyadditions.mod.event;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.util.KeyUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
@ -35,7 +35,7 @@ public class TooltipEvent{
|
|||
//Advanced Item Info
|
||||
if(event.itemStack.getItem() != null){
|
||||
if(ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()){
|
||||
if(KeyUtil.isControlPressed()){
|
||||
if(GuiScreen.isCtrlKeyDown()){
|
||||
event.toolTip.add(EnumChatFormatting.DARK_GRAY+""+EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".extraInfo.desc")+":");
|
||||
|
||||
//OreDict Names
|
||||
|
@ -77,7 +77,7 @@ public class TooltipEvent{
|
|||
NBTTagCompound compound = event.itemStack.getTagCompound();
|
||||
if(compound != null && !compound.hasNoTags()){
|
||||
event.toolTip.add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".nbt.desc")+":");
|
||||
if(KeyUtil.isShiftPressed()){
|
||||
if(GuiScreen.isShiftKeyDown()){
|
||||
List<String> strgList = Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(compound.toString(), 200);
|
||||
for(String strg : strgList){
|
||||
event.toolTip.add(ADVANCED_INFO_TEXT_PRE+strg);
|
||||
|
|
|
@ -79,6 +79,7 @@ public class AssetUtil{
|
|||
Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(mc.fontRendererObj, stack, 0, 0, null);
|
||||
mc.fontRendererObj.setUnicodeFlag(flagBefore);
|
||||
|
||||
//TODO I don't think this is needed anymore, but I need to check that
|
||||
//GL+MC+NEI suck
|
||||
if(mc.currentScreen instanceof GuiBooklet || mc.currentScreen == null){
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
@ -115,7 +116,7 @@ public class AssetUtil{
|
|||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void renderNameTag(String tag, float x, float y, float z){
|
||||
public static void renderNameTag(String tag, double x, double y, double z){
|
||||
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
|
||||
float f = 1.6F;
|
||||
float f1 = 0.016666668F*f;
|
||||
|
@ -151,8 +152,4 @@ public class AssetUtil{
|
|||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static void renderNameTag(String tag, double x, double y, double z){
|
||||
renderNameTag(tag, (float)x, (float)y, (float)z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,10 +54,6 @@ public class ItemUtil{
|
|||
return stack1 != null && stack2 != null && (stack1.isItemEqual(stack2) || (checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD)));
|
||||
}
|
||||
|
||||
public static boolean areStacksEqualAndSameSize(ItemStack stack1, ItemStack stack2, boolean checkWildcard){
|
||||
return areItemsEqual(stack1, stack2, checkWildcard) && stack1.stackSize == stack2.stackSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if list contains stack or if both contain null
|
||||
*/
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* This file ("KeyUtil.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense/
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class KeyUtil{
|
||||
|
||||
public static boolean isShiftPressed(){
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
}
|
||||
|
||||
public static boolean isControlPressed(){
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
|
||||
}
|
||||
|
||||
public static boolean isAltPressed(){
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU);
|
||||
}
|
||||
}
|
|
@ -38,7 +38,12 @@ public class PosUtil{
|
|||
|
||||
public static int getMetadata(BlockPos pos, IBlockAccess world){
|
||||
Block block = getBlock(pos, world);
|
||||
return block != null ? getBlock(pos, world).getMetaFromState(world.getBlockState(pos)) : 0;
|
||||
return block != null ? block.getMetaFromState(world.getBlockState(pos)) : 0;
|
||||
}
|
||||
|
||||
public static int getMetadata(IBlockState state){
|
||||
Block block = state.getBlock();
|
||||
return block != null ? block.getMetaFromState(state) : 0;
|
||||
}
|
||||
|
||||
public static BlockPos offset(BlockPos pos, int x, int y, int z){
|
||||
|
|
Loading…
Reference in a new issue