mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-23 01:47:38 +00:00
ComputerCraft 1.80pr0
Updated the source code to the version shipped as the 1.80pr0 alpha release. Also removed some unnecessary files from the LuaJ subfolder which were bulking up the repository.
This commit is contained in:
@@ -53,7 +53,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
@@ -122,8 +123,6 @@ public class ComputerCraft
|
||||
public static int computerSpaceLimit = 1000 * 1000;
|
||||
public static int floppySpaceLimit = 125 * 1000;
|
||||
|
||||
public static int treasureDiskLootFrequency = 1;
|
||||
|
||||
// Blocks and Items
|
||||
public static class Blocks
|
||||
{
|
||||
@@ -198,71 +197,67 @@ public class ComputerCraft
|
||||
// Setup general
|
||||
|
||||
Property prop = config.get(Configuration.CATEGORY_GENERAL, "http_enable", http_enable);
|
||||
prop.comment = "Enable the \"http\" API on Computers (see \"http_whitelist\" for more fine grained control than this)";
|
||||
prop.setComment( "Enable the \"http\" API on Computers (see \"http_whitelist\" for more fine grained control than this)" );
|
||||
http_enable = prop.getBoolean(http_enable);
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "http_whitelist", http_whitelist );
|
||||
prop.comment = "A semicolon limited list of wildcards for domains that can be accessed through the \"http\" API on Computers. Set this to \"*\" to access to the entire internet. Example: \"*.pastebin.com;*.github.com;*.computercraft.info\" will restrict access to just those 3 domains.";
|
||||
prop.setComment( "A semicolon limited list of wildcards for domains that can be accessed through the \"http\" API on Computers. Set this to \"*\" to access to the entire internet. Example: \"*.pastebin.com;*.github.com;*.computercraft.info\" will restrict access to just those 3 domains." );
|
||||
http_whitelist = prop.getString();
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "disable_lua51_features", disable_lua51_features );
|
||||
prop.comment = "Set this to true to disable Lua 5.1 functions that will be removed in a future update. Useful for ensuring forward compatibility of your programs now.";
|
||||
prop.setComment( "Set this to true to disable Lua 5.1 functions that will be removed in a future update. Useful for ensuring forward compatibility of your programs now." );
|
||||
disable_lua51_features = prop.getBoolean( disable_lua51_features );
|
||||
|
||||
prop = config.get( Configuration.CATEGORY_GENERAL, "default_computer_settings", default_computer_settings );
|
||||
prop.comment = "A comma seperated list of default system settings to set on new computers. Example: \"shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false\" will disable all autocompletion";
|
||||
prop.setComment( "A comma seperated list of default system settings to set on new computers. Example: \"shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false\" will disable all autocompletion" );
|
||||
default_computer_settings = prop.getString();
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "enableCommandBlock", enableCommandBlock);
|
||||
prop.comment = "Enable Command Block peripheral support";
|
||||
prop.setComment( "Enable Command Block peripheral support" );
|
||||
enableCommandBlock = prop.getBoolean(enableCommandBlock);
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "modem_range", modem_range);
|
||||
prop.comment = "The range of Wireless Modems at low altitude in clear weather, in meters";
|
||||
prop.setComment( "The range of Wireless Modems at low altitude in clear weather, in meters" );
|
||||
modem_range = Math.min( prop.getInt(), 100000 );
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "modem_highAltitudeRange", modem_highAltitudeRange);
|
||||
prop.comment = "The range of Wireless Modems at maximum altitude in clear weather, in meters";
|
||||
prop.setComment( "The range of Wireless Modems at maximum altitude in clear weather, in meters" );
|
||||
modem_highAltitudeRange = Math.min( prop.getInt(), 100000 );
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "modem_rangeDuringStorm", modem_rangeDuringStorm);
|
||||
prop.comment = "The range of Wireless Modems at low altitude in stormy weather, in meters";
|
||||
prop.setComment( "The range of Wireless Modems at low altitude in stormy weather, in meters" );
|
||||
modem_rangeDuringStorm = Math.min( prop.getInt(), 100000 );
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "modem_highAltitudeRangeDuringStorm", modem_highAltitudeRangeDuringStorm);
|
||||
prop.comment = "The range of Wireless Modems at maximum altitude in stormy weather, in meters";
|
||||
prop.setComment( "The range of Wireless Modems at maximum altitude in stormy weather, in meters" );
|
||||
modem_highAltitudeRangeDuringStorm = Math.min( prop.getInt(), 100000 );
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "computerSpaceLimit", computerSpaceLimit);
|
||||
prop.comment = "The disk space limit for computers and turtles, in bytes";
|
||||
prop.setComment( "The disk space limit for computers and turtles, in bytes" );
|
||||
computerSpaceLimit = prop.getInt();
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "floppySpaceLimit", floppySpaceLimit);
|
||||
prop.comment = "The disk space limit for floppy disks, in bytes";
|
||||
prop.setComment( "The disk space limit for floppy disks, in bytes" );
|
||||
floppySpaceLimit = prop.getInt();
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "treasureDiskLootFrequency", treasureDiskLootFrequency);
|
||||
prop.comment = "The frequency that treasure disks will be found in dungeon chests, from 0 to 100. Increase this value if running a modpack with lots of mods that add dungeon loot, or you just want more treasure disks. Set to 0 to disable treasure disks.";
|
||||
treasureDiskLootFrequency = prop.getInt();
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "turtlesNeedFuel", turtlesNeedFuel);
|
||||
prop.comment = "Set whether Turtles require fuel to move";
|
||||
prop.setComment( "Set whether Turtles require fuel to move" );
|
||||
turtlesNeedFuel = prop.getBoolean( turtlesNeedFuel );
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "turtleFuelLimit", turtleFuelLimit);
|
||||
prop.comment = "The fuel limit for Turtles";
|
||||
prop.setComment( "The fuel limit for Turtles" );
|
||||
turtleFuelLimit = prop.getInt( turtleFuelLimit );
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "advancedTurtleFuelLimit", advancedTurtleFuelLimit);
|
||||
prop.comment = "The fuel limit for Advanced Turtles";
|
||||
prop.setComment( "The fuel limit for Advanced Turtles" );
|
||||
advancedTurtleFuelLimit = prop.getInt(advancedTurtleFuelLimit);
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "turtlesObeyBlockProtection", turtlesObeyBlockProtection);
|
||||
prop.comment = "If set to true, Turtles will be unable to build, dig, or enter protected areas (such as near the server spawn point)";
|
||||
prop.setComment( "If set to true, Turtles will be unable to build, dig, or enter protected areas (such as near the server spawn point)" );
|
||||
turtlesObeyBlockProtection = prop.getBoolean( turtlesObeyBlockProtection );
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "turtlesCanPush", turtlesCanPush);
|
||||
prop.comment = "If set to true, Turtles will push entities out of the way instead of stopping if there is space to do so";
|
||||
prop.setComment( "If set to true, Turtles will push entities out of the way instead of stopping if there is space to do so" );
|
||||
turtlesCanPush = prop.getBoolean(turtlesCanPush);
|
||||
|
||||
config.save();
|
||||
@@ -285,7 +280,6 @@ public class ComputerCraft
|
||||
@Mod.EventHandler
|
||||
public void onServerStarting( FMLServerStartingEvent event )
|
||||
{
|
||||
ItemTreasureDisk.registerDungeonLoot();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
@@ -338,7 +332,7 @@ public class ComputerCraft
|
||||
return proxy.getFixedWidthFontRenderer();
|
||||
}
|
||||
|
||||
public static void playRecord( String record, String recordInfo, World world, BlockPos pos )
|
||||
public static void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
||||
{
|
||||
proxy.playRecord( record, recordInfo, world, pos );
|
||||
}
|
||||
@@ -426,20 +420,20 @@ public class ComputerCraft
|
||||
|
||||
public static boolean canPlayerUseCommands( EntityPlayer player )
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
MinecraftServer server = player.getServer();
|
||||
if( server != null )
|
||||
{
|
||||
return server.getConfigurationManager().canSendCommands( player.getGameProfile() );
|
||||
return server.getPlayerList().canSendCommands( player.getGameProfile() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPlayerOpped( EntityPlayer player )
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
MinecraftServer server = player.getServer();
|
||||
if( server != null )
|
||||
{
|
||||
return server.getConfigurationManager().getOppedPlayers().getEntry( player.getGameProfile() ) != null;
|
||||
return server.getPlayerList().getOppedPlayers().getEntry( player.getGameProfile() ) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -454,7 +448,7 @@ public class ComputerCraft
|
||||
|
||||
public static boolean isBlockEnterable( World world, BlockPos pos, EntityPlayer player )
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
MinecraftServer server = player.getServer();
|
||||
if( server != null && !world.isRemote )
|
||||
{
|
||||
if( server.isBlockProtected( world, pos, player ) )
|
||||
@@ -476,7 +470,7 @@ public class ComputerCraft
|
||||
|
||||
public static boolean isBlockEditable( World world, BlockPos pos, EntityPlayer player )
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
MinecraftServer server = player.getServer();
|
||||
if( server != null && !world.isRemote )
|
||||
{
|
||||
if( server.isBlockProtected( world, pos, player ) )
|
||||
|
@@ -13,7 +13,7 @@ import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import dan200.computercraft.api.permissions.ITurtlePermissionProvider;
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -8,6 +8,7 @@ package dan200.computercraft.api.media;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
@@ -43,7 +44,7 @@ public interface IMedia
|
||||
* @param stack The itemstack to inspect.
|
||||
* @return The name, or null if this item does not represent an item with audio.
|
||||
*/
|
||||
public String getAudioRecordName( ItemStack stack );
|
||||
public SoundEvent getAudio( ItemStack stack );
|
||||
|
||||
/**
|
||||
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will be mounted onto the filesystem of the computercraft while the media is in the disk drive.
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
package dan200.computercraft.api.permissions;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
package dan200.computercraft.api.redstone;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -11,9 +11,9 @@ import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ public interface ITurtleAccess
|
||||
* @param f The subframe fraction
|
||||
* @return a vector containing the floating point co-ordinates at which the turtle resides.
|
||||
*/
|
||||
public Vec3 getVisualPosition( float f );
|
||||
public Vec3d getVisualPosition( float f );
|
||||
|
||||
/**
|
||||
* TODO: Document me
|
||||
|
@@ -7,7 +7,7 @@
|
||||
package dan200.computercraft.api.turtle;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@@ -9,7 +9,7 @@ package dan200.computercraft.client.gui;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -30,7 +30,7 @@ public class FixedWidthFontRenderer
|
||||
m_textureManager = textureManager;
|
||||
}
|
||||
|
||||
private void drawChar( WorldRenderer renderer, double x, double y, int index, int color )
|
||||
private void drawChar( VertexBuffer renderer, double x, double y, int index, int color )
|
||||
{
|
||||
int column = index % 16;
|
||||
int row = index / 16;
|
||||
@@ -41,7 +41,7 @@ public class FixedWidthFontRenderer
|
||||
renderer.pos( x, y, 0.0 ).tex( (double) (column * FONT_WIDTH) / 256.0, (double) (row * FONT_HEIGHT ) / 256.0 ).color( colour.getR(), colour.getG(), colour.getB(), 1.0f ).endVertex();
|
||||
}
|
||||
|
||||
private void drawQuad( WorldRenderer renderer, double x, double y, int color, double width )
|
||||
private void drawQuad( VertexBuffer renderer, double x, double y, int color, double width )
|
||||
{
|
||||
Colour colour = Colour.values()[ 15 - color ];
|
||||
renderer.pos( x, y + FONT_HEIGHT, 0.0 ).tex( 0.0, 1.0 ).color( colour.getR(), colour.getG(), colour.getB(), 1.0f ).endVertex();
|
||||
@@ -59,7 +59,7 @@ public class FixedWidthFontRenderer
|
||||
{
|
||||
// Draw the quads
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR );
|
||||
if( leftMarginSize > 0.0 )
|
||||
{
|
||||
@@ -95,7 +95,7 @@ public class FixedWidthFontRenderer
|
||||
{
|
||||
// Draw the quads
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR );
|
||||
for( int i = 0; i < s.length(); i++ )
|
||||
{
|
||||
|
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
public class MousePos
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public MousePos( int x, int y )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
@@ -6,16 +6,16 @@
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
import dan200.computercraftedu.client.gui.widgets.MousePos;
|
||||
import dan200.computercraftedu.client.gui.widgets.WidgetContainer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -177,11 +177,11 @@ public abstract class Widget extends Gui
|
||||
protected void drawFullImage( int x, int y, int w, int h )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
tessellator.getWorldRenderer().begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX );
|
||||
tessellator.getWorldRenderer().pos( (double) ( x + 0 ), (double) ( y + h ), (double) this.zLevel ).tex( 0.0, 1.0 ).endVertex();
|
||||
tessellator.getWorldRenderer().pos( (double) ( x + w ), (double) ( y + h ), (double) this.zLevel ).tex( 1.0, 1.0 ).endVertex();
|
||||
tessellator.getWorldRenderer().pos( (double) ( x + w ), (double) ( y + 0 ), (double) this.zLevel ).tex( 1.0, 0.0 ).endVertex();
|
||||
tessellator.getWorldRenderer().pos( (double) ( x + 0 ), (double) ( y + 0 ), (double) this.zLevel ).tex( 0.0, 0.0 ).endVertex();
|
||||
tessellator.getBuffer().begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX );
|
||||
tessellator.getBuffer().pos( (double) ( x + 0 ), (double) ( y + h ), (double) this.zLevel ).tex( 0.0, 1.0 ).endVertex();
|
||||
tessellator.getBuffer().pos( (double) ( x + w ), (double) ( y + h ), (double) this.zLevel ).tex( 1.0, 1.0 ).endVertex();
|
||||
tessellator.getBuffer().pos( (double) ( x + w ), (double) ( y + 0 ), (double) this.zLevel ).tex( 1.0, 0.0 ).endVertex();
|
||||
tessellator.getBuffer().pos( (double) ( x + 0 ), (double) ( y + 0 ), (double) this.zLevel ).tex( 0.0, 0.0 ).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
@@ -381,6 +381,6 @@ public abstract class Widget extends Gui
|
||||
protected void playClickSound()
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.getSoundHandler().playSound( PositionedSoundRecord.create( new ResourceLocation( "gui.button.press" ), 1.0F ) );
|
||||
mc.getSoundHandler().playSound( PositionedSoundRecord.getMasterRecord( SoundEvents.UI_BUTTON_CLICK, 1.0F ) );
|
||||
}
|
||||
}
|
||||
|
@@ -1,344 +0,0 @@
|
||||
/**
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
import dan200.computercraft.client.gui.widgets.Widget;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class WidgetContainer extends Widget
|
||||
{
|
||||
private ArrayList<Widget> m_widgets;
|
||||
private Widget m_modalWidget;
|
||||
|
||||
public WidgetContainer( int x, int y, int w, int h )
|
||||
{
|
||||
super( x, y, w, h );
|
||||
m_widgets = new ArrayList<Widget>();
|
||||
m_modalWidget = null;
|
||||
}
|
||||
|
||||
public void addWidget( Widget widget )
|
||||
{
|
||||
m_widgets.add( widget );
|
||||
widget.setParent( this );
|
||||
}
|
||||
|
||||
public void setModalWidget( Widget widget )
|
||||
{
|
||||
m_modalWidget = widget;
|
||||
if( widget != null )
|
||||
{
|
||||
widget.setParent( this );
|
||||
}
|
||||
}
|
||||
|
||||
public Widget getModalWidget()
|
||||
{
|
||||
return m_modalWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
m_widgets.get( i ).update();
|
||||
}
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
m_modalWidget.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.draw(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
try
|
||||
{
|
||||
GlStateManager.translate( 0.0f, 0.0f, 200.0f );
|
||||
m_modalWidget.draw(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.drawForeground(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
try
|
||||
{
|
||||
GlStateManager.translate( 0.0f, 0.0f, 200.0f );
|
||||
m_modalWidget.drawForeground(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMousePosition( MousePos pos )
|
||||
{
|
||||
pos.x -= getXPosition();
|
||||
pos.y -= getYPosition();
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.modifyMousePosition( pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.modifyMousePosition( pos );
|
||||
}
|
||||
}
|
||||
pos.x += getXPosition();
|
||||
pos.y += getYPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean suppressItemTooltips( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressItemTooltips(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() && m_modalWidget.suppressItemTooltips(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean suppressKeyPress( char c, int k )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressKeyPress( c, k ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
if( m_modalWidget.suppressKeyPress( c, k ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput( int mouseX, int mouseY )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleMouseInput(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.handleMouseInput(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleKeyboardInput()
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked( int mouseX, int mouseY, int mouseButton )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.mouseClicked(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition(),
|
||||
mouseButton
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.mouseClicked(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition(),
|
||||
mouseButton
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped( char c, int k )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.keyTyped( c, k );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.keyTyped( c, k );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -16,20 +16,20 @@ import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ISmartItemModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -89,10 +89,12 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
|
||||
private void registerItemModel( Item item, ItemMeshDefinition definition, String[] names )
|
||||
{
|
||||
ResourceLocation[] resources = new ResourceLocation[names.length];
|
||||
for( int i=0; i<names.length; ++i )
|
||||
{
|
||||
ModelBakery.addVariantName( item, "computercraft:" + names[ i ] );
|
||||
resources[i] = new ResourceLocation( "computercraft:" + names[i] );
|
||||
}
|
||||
ModelBakery.registerItemVariants( item, resources );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, definition );
|
||||
}
|
||||
|
||||
@@ -129,7 +131,7 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
@SubscribeEvent
|
||||
public void onTextureStitchEvent( TextureStitchEvent.Pre event )
|
||||
{
|
||||
event.map.registerSprite( new ResourceLocation( "computercraft", "blocks/craftyUpgrade" ) );
|
||||
event.getMap().registerSprite( new ResourceLocation( "computercraft", "blocks/craftyUpgrade" ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -150,38 +152,30 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
|
||||
private void loadModel( ModelBakeEvent event, String name )
|
||||
{
|
||||
try
|
||||
{
|
||||
IModel model = event.modelLoader.getModel(
|
||||
new ResourceLocation( "computercraft", "block/" + name )
|
||||
);
|
||||
IBakedModel bakedModel = model.bake(
|
||||
model.getDefaultState(),
|
||||
DefaultVertexFormats.ITEM,
|
||||
new Function<ResourceLocation, TextureAtlasSprite>()
|
||||
IModel model = ModelLoaderRegistry.getModelOrMissing(
|
||||
new ResourceLocation( "computercraft", "block/" + name )
|
||||
);
|
||||
IBakedModel bakedModel = model.bake(
|
||||
model.getDefaultState(),
|
||||
DefaultVertexFormats.ITEM,
|
||||
new Function<ResourceLocation, TextureAtlasSprite>()
|
||||
{
|
||||
@Override
|
||||
public TextureAtlasSprite apply( ResourceLocation location )
|
||||
{
|
||||
@Override
|
||||
public TextureAtlasSprite apply( ResourceLocation location )
|
||||
{
|
||||
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( location.toString() );
|
||||
}
|
||||
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( location.toString() );
|
||||
}
|
||||
);
|
||||
event.modelRegistry.putObject(
|
||||
new ModelResourceLocation( "computercraft:" + name, "inventory" ),
|
||||
bakedModel
|
||||
);
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
System.out.println( "Could not load model: name" );
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
);
|
||||
event.getModelRegistry().putObject(
|
||||
new ModelResourceLocation( "computercraft:" + name, "inventory" ),
|
||||
bakedModel
|
||||
);
|
||||
}
|
||||
|
||||
private void loadSmartModel( ModelBakeEvent event, String name, ISmartItemModel smartModel )
|
||||
private void loadSmartModel( ModelBakeEvent event, String name, IBakedModel smartModel )
|
||||
{
|
||||
event.modelRegistry.putObject(
|
||||
event.getModelRegistry().putObject(
|
||||
new ModelResourceLocation( "computercraft:" + name, "inventory" ),
|
||||
smartModel
|
||||
);
|
||||
|
@@ -26,14 +26,16 @@ import dan200.computercraft.shared.turtle.entity.TurtleVisionCamera;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
@@ -184,9 +186,8 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
|
||||
private void registerItemModel( Item item, int damage, String name )
|
||||
{
|
||||
name = "computercraft:" + name;
|
||||
ModelResourceLocation res = new ModelResourceLocation( name, "inventory" );
|
||||
ModelBakery.addVariantName( item, name );
|
||||
ModelResourceLocation res = new ModelResourceLocation( "computercraft:" + name, "inventory" );
|
||||
ModelBakery.registerItemVariants( item, new ResourceLocation( "computercraft", name ) );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, damage, res );
|
||||
}
|
||||
|
||||
@@ -197,9 +198,8 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
|
||||
private void registerItemModel( Item item, String name )
|
||||
{
|
||||
name = "computercraft:" + name;
|
||||
final ModelResourceLocation res = new ModelResourceLocation( name, "inventory" );
|
||||
ModelBakery.addVariantName( item, name );
|
||||
final ModelResourceLocation res = new ModelResourceLocation( "computercraft:" + name, "inventory" );
|
||||
ModelBakery.registerItemVariants( item, new ResourceLocation( "computercraft", name ) );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, new ItemMeshDefinition()
|
||||
{
|
||||
@Override
|
||||
@@ -217,10 +217,12 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
|
||||
private void registerItemModel( Item item, ItemMeshDefinition definition, String[] names )
|
||||
{
|
||||
for( int i=0; i<names.length; ++i )
|
||||
ResourceLocation[] resources = new ResourceLocation[names.length];
|
||||
for( int i=0; i<resources.length; ++i )
|
||||
{
|
||||
ModelBakery.addVariantName( item, "computercraft:" + names[i] );
|
||||
resources[i] = new ResourceLocation( "computercraft", names[i] );
|
||||
}
|
||||
ModelBakery.registerItemVariants( item, resources );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, definition );
|
||||
}
|
||||
|
||||
@@ -267,7 +269,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playRecord( String record, String recordInfo, World world, BlockPos pos )
|
||||
public void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
||||
{
|
||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
world.playRecord( pos, record );
|
||||
@@ -326,7 +328,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
@Override
|
||||
public File getWorldDir( World world )
|
||||
{
|
||||
return new File( ComputerCraft.getBaseDir(), "saves/" + world.getSaveHandler().getWorldDirectoryName() );
|
||||
return world.getSaveHandler().getWorldDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -425,10 +427,10 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
public void onRenderPlayer( RenderPlayerEvent.Pre event )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if( event.entityPlayer.isUser() && mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
||||
if( event.getEntityPlayer().isUser() && mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
||||
{
|
||||
// HACK: Force the 'livingPlayer' variable to the player, this ensures the entity is drawn
|
||||
event.renderer.getRenderManager().livingPlayer = event.entityPlayer;
|
||||
//event.getRenderer().getRenderManager().livingPlayer = event.getEntityPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,10 +438,10 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
public void onRenderPlayer( RenderPlayerEvent.Post event )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if( event.entityPlayer.isUser() && mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
||||
if( event.getEntityPlayer().isUser() && mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
||||
{
|
||||
// HACK: Restore the 'livingPlayer' variable to what it was before the RenderPlayerEvent.Pre hack
|
||||
event.renderer.getRenderManager().livingPlayer = mc.getRenderViewEntity();
|
||||
//event.getRenderer().getRenderManager().livingPlayer = mc.getRenderViewEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +451,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if( mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
||||
{
|
||||
switch( event.type )
|
||||
switch( event.getType() )
|
||||
{
|
||||
case HELMET:
|
||||
case PORTAL:
|
||||
|
@@ -18,11 +18,11 @@ import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
@@ -94,7 +94,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
// Get renderers
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
|
||||
// Get terminal
|
||||
ClientTerminal clientTerminal = (ClientTerminal)origin.getTerminal();
|
||||
|
@@ -15,23 +15,25 @@ import dan200.computercraft.shared.turtle.entity.TurtleVisionCamera;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.IFlexibleBakedModel;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -166,11 +168,12 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
|
||||
private void renderTurtleAt( TileTurtle turtle, double posX, double posY, double posZ, float f, int i )
|
||||
{
|
||||
IBlockState state = turtle.getWorld().getBlockState( turtle.getPos() );
|
||||
GlStateManager.pushMatrix();
|
||||
try
|
||||
{
|
||||
// Setup the transform
|
||||
Vec3 offset;
|
||||
Vec3d offset;
|
||||
float yaw;
|
||||
if( turtle != null )
|
||||
{
|
||||
@@ -179,7 +182,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = new Vec3( 0.0, 0.0, 0.0 );
|
||||
offset = new Vec3d( 0.0, 0.0, 0.0 );
|
||||
yaw = 0.0f;
|
||||
}
|
||||
GlStateManager.translate( posX + offset.xCoord, posY + offset.yCoord, posZ + offset.zCoord );
|
||||
@@ -213,7 +216,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
family = ComputerFamily.Normal;
|
||||
overlay = null;
|
||||
}
|
||||
renderModel( getTurtleModel( family, colour ) );
|
||||
renderModel( state, getTurtleModel( family, colour ) );
|
||||
|
||||
// Render the overlay
|
||||
ModelResourceLocation overlayModel = getTurtleOverlayModel(
|
||||
@@ -228,7 +231,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
GlStateManager.blendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
|
||||
try
|
||||
{
|
||||
renderModel( overlayModel );
|
||||
renderModel( state, overlayModel );
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -240,8 +243,8 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
// Render the upgrades
|
||||
if( turtle != null )
|
||||
{
|
||||
renderUpgrade( turtle, TurtleSide.Left, f );
|
||||
renderUpgrade( turtle, TurtleSide.Right, f );
|
||||
renderUpgrade( state, turtle, TurtleSide.Left, f );
|
||||
renderUpgrade( state, turtle, TurtleSide.Right, f );
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -250,7 +253,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUpgrade( TileTurtle turtle, TurtleSide side, float f )
|
||||
private void renderUpgrade( IBlockState state, TileTurtle turtle, TurtleSide side, float f )
|
||||
{
|
||||
ITurtleUpgrade upgrade = turtle.getUpgrade( side );
|
||||
if( upgrade != null )
|
||||
@@ -272,7 +275,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
}
|
||||
if( pair.getLeft() != null )
|
||||
{
|
||||
renderModel( pair.getLeft() );
|
||||
renderModel( state, pair.getLeft() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,56 +286,52 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
}
|
||||
}
|
||||
|
||||
private void renderModel( ModelResourceLocation modelLocation )
|
||||
private void renderModel( IBlockState state, ModelResourceLocation modelLocation )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ModelManager modelManager = mc.getRenderItem().getItemModelMesher().getModelManager();
|
||||
renderModel( modelManager.getModel( modelLocation ) );
|
||||
renderModel( state, modelManager.getModel( modelLocation ) );
|
||||
}
|
||||
|
||||
private void renderModel( IBakedModel model )
|
||||
{
|
||||
if( model instanceof IFlexibleBakedModel )
|
||||
{
|
||||
renderModel( (IFlexibleBakedModel) model );
|
||||
}
|
||||
else
|
||||
{
|
||||
renderModel( new IFlexibleBakedModel.Wrapper( model, DefaultVertexFormats.ITEM ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void renderModel( IFlexibleBakedModel model )
|
||||
private void renderModel( IBlockState state, IBakedModel model )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||
mc.getTextureManager().bindTexture( TextureMap.locationBlocksTexture );
|
||||
renderer.begin( GL11.GL_QUADS, model.getFormat() );
|
||||
mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
|
||||
renderQuads( tessellator, model.getQuads( state, null, 0 ) );
|
||||
for( EnumFacing facing : EnumFacing.VALUES )
|
||||
{
|
||||
renderQuads( renderer, model.getFaceQuads( facing ) );
|
||||
renderQuads( tessellator, model.getQuads( state, facing, 0 ) );
|
||||
}
|
||||
renderQuads( renderer, model.getGeneralQuads() );
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
private void renderQuads( WorldRenderer renderer, List quads )
|
||||
private void renderQuads( Tessellator tessellator, List quads )
|
||||
{
|
||||
int color = 0xFFFFFFFF;
|
||||
Iterator it = quads.iterator();
|
||||
VertexBuffer buffer = tessellator.getBuffer();
|
||||
VertexFormat format = DefaultVertexFormats.ITEM;
|
||||
buffer.begin( GL11.GL_QUADS, format );
|
||||
while( it.hasNext() )
|
||||
{
|
||||
BakedQuad quad = (BakedQuad)it.next();
|
||||
net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor( renderer, quad, color );
|
||||
VertexFormat quadFormat = quad.getFormat();
|
||||
if( quadFormat != format )
|
||||
{
|
||||
tessellator.draw();
|
||||
format = quadFormat;
|
||||
buffer.begin( GL11.GL_QUADS, format );
|
||||
}
|
||||
net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor( buffer, quad, color );
|
||||
}
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
private void renderLabel( BlockPos position, String label )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
MovingObjectPosition mop = mc.objectMouseOver;
|
||||
if( mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mop.getBlockPos().equals( position ) )
|
||||
RayTraceResult mop = mc.objectMouseOver;
|
||||
if( mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK && mop.getBlockPos().equals( position ) )
|
||||
{
|
||||
RenderManager renderManager = mc.getRenderManager();
|
||||
FontRenderer fontrenderer = renderManager.getFontRenderer();
|
||||
@@ -362,7 +361,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
try
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR );
|
||||
renderer.pos( (double) ( -xOffset - 1 ), (double) ( -1 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
|
||||
renderer.pos( (double) ( -xOffset - 1 ), (double) ( 8 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
|
||||
|
@@ -1,85 +1,92 @@
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.IFlexibleBakedModel;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Point3f;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Dictionary;
|
||||
import java.util.List;
|
||||
|
||||
public class TurtleMultiModel implements IFlexibleBakedModel
|
||||
public class TurtleMultiModel implements IBakedModel
|
||||
{
|
||||
private IFlexibleBakedModel m_baseModel;
|
||||
private IFlexibleBakedModel m_overlayModel;
|
||||
private IFlexibleBakedModel m_leftUpgradeModel;
|
||||
private IFlexibleBakedModel m_rightUpgradeModel;
|
||||
|
||||
private IBakedModel m_baseModel;
|
||||
private IBakedModel m_overlayModel;
|
||||
private IBakedModel m_leftUpgradeModel;
|
||||
private Matrix4f m_leftUpgradeTransform;
|
||||
private IBakedModel m_rightUpgradeModel;
|
||||
private Matrix4f m_rightUpgradeTransform;
|
||||
private List<BakedQuad> m_generalQuads;
|
||||
private List<BakedQuad>[] m_faceQuads;
|
||||
private List<BakedQuad> m_faceQuads[];
|
||||
|
||||
public TurtleMultiModel( IBakedModel baseModel, IBakedModel overlayModel, IBakedModel leftUpgradeModel, Matrix4f leftUpgradeTransform, IBakedModel rightUpgradeModel, Matrix4f rightUpgradeTransform )
|
||||
{
|
||||
// Get the models
|
||||
m_baseModel = makeFlexible( baseModel );
|
||||
m_overlayModel = makeFlexible( overlayModel );
|
||||
m_leftUpgradeModel = makeFlexible( leftUpgradeModel );
|
||||
m_rightUpgradeModel = makeFlexible( rightUpgradeModel );
|
||||
|
||||
// Bake the quads
|
||||
m_generalQuads = new ArrayList<BakedQuad>();
|
||||
m_generalQuads.addAll( m_baseModel.getGeneralQuads() );
|
||||
if( m_overlayModel != null )
|
||||
{
|
||||
m_generalQuads.addAll( m_overlayModel.getGeneralQuads() );
|
||||
}
|
||||
if( m_leftUpgradeModel != null )
|
||||
{
|
||||
m_generalQuads.addAll( transformQuads( m_leftUpgradeModel.getFormat(), m_leftUpgradeModel.getGeneralQuads(), leftUpgradeTransform ) );
|
||||
}
|
||||
if( m_rightUpgradeModel != null )
|
||||
{
|
||||
m_generalQuads.addAll( transformQuads( m_rightUpgradeModel.getFormat(), m_rightUpgradeModel.getGeneralQuads(), rightUpgradeTransform ) );
|
||||
}
|
||||
|
||||
m_faceQuads = new List[ EnumFacing.VALUES.length ];
|
||||
for( EnumFacing facing : EnumFacing.VALUES )
|
||||
{
|
||||
List<BakedQuad> faces = new ArrayList<BakedQuad>();
|
||||
faces.addAll( m_baseModel.getFaceQuads( facing ) );
|
||||
if( m_overlayModel != null )
|
||||
{
|
||||
faces.addAll( m_overlayModel.getFaceQuads( facing ) );
|
||||
}
|
||||
if( m_leftUpgradeModel != null )
|
||||
{
|
||||
faces.addAll( transformQuads( m_leftUpgradeModel.getFormat(), m_leftUpgradeModel.getFaceQuads( facing ), leftUpgradeTransform ) );
|
||||
}
|
||||
if( m_rightUpgradeModel != null )
|
||||
{
|
||||
faces.addAll( transformQuads( m_rightUpgradeModel.getFormat(), m_rightUpgradeModel.getFaceQuads( facing ), rightUpgradeTransform ) );
|
||||
}
|
||||
m_faceQuads[ facing.getIndex() ] = faces;
|
||||
}
|
||||
m_baseModel = baseModel;
|
||||
m_overlayModel = overlayModel;
|
||||
m_leftUpgradeModel = leftUpgradeModel;
|
||||
m_leftUpgradeTransform = leftUpgradeTransform;
|
||||
m_rightUpgradeModel = rightUpgradeModel;
|
||||
m_rightUpgradeTransform = rightUpgradeTransform;
|
||||
m_generalQuads = null;
|
||||
m_faceQuads = new List[6];
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getFaceQuads( EnumFacing side )
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return m_faceQuads[ side.getIndex() ];
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads()
|
||||
{
|
||||
return m_generalQuads;
|
||||
if( side != null )
|
||||
{
|
||||
if( m_faceQuads[ side.ordinal() ] == null )
|
||||
{
|
||||
List<BakedQuad> quads = new ArrayList<BakedQuad>();
|
||||
if( m_overlayModel != null )
|
||||
{
|
||||
quads.addAll( m_overlayModel.getQuads( state, side, rand ) );
|
||||
}
|
||||
if( m_leftUpgradeModel != null )
|
||||
{
|
||||
quads.addAll( transformQuads( m_leftUpgradeModel.getQuads( state, side, rand ), m_leftUpgradeTransform ) );
|
||||
}
|
||||
if( m_rightUpgradeModel != null )
|
||||
{
|
||||
quads.addAll( transformQuads( m_rightUpgradeModel.getQuads( state, side, rand ), m_rightUpgradeTransform ) );
|
||||
}
|
||||
m_faceQuads[ side.ordinal() ] = quads;
|
||||
}
|
||||
return m_faceQuads[ side.ordinal() ];
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_generalQuads == null )
|
||||
{
|
||||
m_generalQuads = new ArrayList<BakedQuad>();
|
||||
m_generalQuads.addAll( m_baseModel.getQuads( state, side, rand ) );
|
||||
if( m_overlayModel != null )
|
||||
{
|
||||
m_generalQuads.addAll( m_overlayModel.getQuads( state, side, rand ) );
|
||||
}
|
||||
if( m_leftUpgradeModel != null )
|
||||
{
|
||||
m_generalQuads.addAll( transformQuads( m_leftUpgradeModel.getQuads( state, side, rand ), m_leftUpgradeTransform ) );
|
||||
}
|
||||
if( m_rightUpgradeModel != null )
|
||||
{
|
||||
m_generalQuads.addAll( transformQuads( m_rightUpgradeModel.getQuads( state, side, rand ), m_rightUpgradeTransform ) );
|
||||
}
|
||||
}
|
||||
return m_generalQuads;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,12 +120,12 @@ public class TurtleMultiModel implements IFlexibleBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getFormat()
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return m_baseModel.getFormat();
|
||||
return ItemOverrideList.NONE;
|
||||
}
|
||||
|
||||
private List<BakedQuad> transformQuads( VertexFormat format, List<BakedQuad> input, Matrix4f transform )
|
||||
private List<BakedQuad> transformQuads( List<BakedQuad> input, Matrix4f transform )
|
||||
{
|
||||
if( transform == null || input.size() == 0 )
|
||||
{
|
||||
@@ -130,17 +137,18 @@ public class TurtleMultiModel implements IFlexibleBakedModel
|
||||
for( int i=0; i<input.size(); ++i )
|
||||
{
|
||||
BakedQuad quad = input.get( i );
|
||||
output.add( transformQuad( format, quad, transform ) );
|
||||
output.add( transformQuad( quad, transform ) );
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
private BakedQuad transformQuad( VertexFormat format, BakedQuad quad, Matrix4f transform )
|
||||
private BakedQuad transformQuad( BakedQuad quad, Matrix4f transform )
|
||||
{
|
||||
int[] vertexData = quad.getVertexData().clone();
|
||||
BakedQuad copy = new BakedQuad( vertexData, quad.getTintIndex(), quad.getFace() );
|
||||
int offset = 0;
|
||||
BakedQuad copy = new BakedQuad( vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat() );
|
||||
VertexFormat format = copy.getFormat();
|
||||
for( int i=0; i<format.getElementCount(); ++i ) // For each vertex element
|
||||
{
|
||||
VertexFormatElement element = format.getElement( i );
|
||||
@@ -176,20 +184,4 @@ public class TurtleMultiModel implements IFlexibleBakedModel
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
private IFlexibleBakedModel makeFlexible( IBakedModel model )
|
||||
{
|
||||
if( model == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if( model instanceof IFlexibleBakedModel )
|
||||
{
|
||||
return (IFlexibleBakedModel)model;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new IFlexibleBakedModel.Wrapper( model, DefaultVertexFormats.ITEM );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,25 +15,27 @@ import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ISmartItemModel;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ISmartVariant;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class TurtleSmartItemModel implements ISmartItemModel, IResourceManagerReloadListener
|
||||
public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReloadListener
|
||||
{
|
||||
private static class TurtleModelCombination
|
||||
{
|
||||
@@ -92,11 +94,43 @@ public class TurtleSmartItemModel implements ISmartItemModel, IResourceManagerRe
|
||||
|
||||
private ItemStack m_defaultItem;
|
||||
private HashMap<TurtleModelCombination, IBakedModel> m_cachedModels;
|
||||
private ItemOverrideList m_overrides;
|
||||
|
||||
public TurtleSmartItemModel()
|
||||
{
|
||||
m_defaultItem = TurtleItemFactory.create( -1, null, null, ComputerFamily.Normal, null, null, 0, null );
|
||||
m_cachedModels = new HashMap<TurtleModelCombination, IBakedModel>();
|
||||
m_overrides = new ItemOverrideList( new ArrayList<ItemOverride>() )
|
||||
{
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
{
|
||||
ItemTurtleBase turtle = (ItemTurtleBase) stack.getItem();
|
||||
ComputerFamily family = turtle.getFamily( stack );
|
||||
Colour colour = turtle.getColour( stack );
|
||||
ITurtleUpgrade leftUpgrade = turtle.getUpgrade( stack, TurtleSide.Left );
|
||||
ITurtleUpgrade rightUpgrade = turtle.getUpgrade( stack, TurtleSide.Right );
|
||||
ResourceLocation overlay = turtle.getOverlay( stack );
|
||||
boolean christmas = HolidayUtil.getCurrentHoliday() == Holiday.Christmas;
|
||||
TurtleModelCombination combo = new TurtleModelCombination( family, colour, leftUpgrade, rightUpgrade, overlay, christmas );
|
||||
if( m_cachedModels.containsKey( combo ) )
|
||||
{
|
||||
return m_cachedModels.get( combo );
|
||||
}
|
||||
else
|
||||
{
|
||||
IBakedModel model = buildModel( combo );
|
||||
m_cachedModels.put( combo, model );
|
||||
return model;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return m_overrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,29 +139,6 @@ public class TurtleSmartItemModel implements ISmartItemModel, IResourceManagerRe
|
||||
m_cachedModels.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState( ItemStack stack )
|
||||
{
|
||||
ItemTurtleBase turtle = (ItemTurtleBase) stack.getItem();
|
||||
ComputerFamily family = turtle.getFamily( stack );
|
||||
Colour colour = turtle.getColour( stack );
|
||||
ITurtleUpgrade leftUpgrade = turtle.getUpgrade( stack, TurtleSide.Left );
|
||||
ITurtleUpgrade rightUpgrade = turtle.getUpgrade( stack, TurtleSide.Right );
|
||||
ResourceLocation overlay = turtle.getOverlay( stack );
|
||||
boolean christmas = HolidayUtil.getCurrentHoliday() == Holiday.Christmas;
|
||||
TurtleModelCombination combo = new TurtleModelCombination( family, colour, leftUpgrade, rightUpgrade, overlay, christmas );
|
||||
if( m_cachedModels.containsKey( combo ) )
|
||||
{
|
||||
return m_cachedModels.get( combo );
|
||||
}
|
||||
else
|
||||
{
|
||||
IBakedModel model = buildModel( combo );
|
||||
m_cachedModels.put( combo, model );
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
private IBakedModel buildModel( TurtleModelCombination combo )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -163,15 +174,9 @@ public class TurtleSmartItemModel implements ISmartItemModel, IResourceManagerRe
|
||||
// These should not be called:
|
||||
|
||||
@Override
|
||||
public List getFaceQuads( EnumFacing facing )
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing facing, long rand )
|
||||
{
|
||||
return getDefaultModel().getFaceQuads( facing );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getGeneralQuads()
|
||||
{
|
||||
return getDefaultModel().getGeneralQuads();
|
||||
return getDefaultModel().getQuads( state, facing, rand );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,6 +211,6 @@ public class TurtleSmartItemModel implements ISmartItemModel, IResourceManagerRe
|
||||
|
||||
private IBakedModel getDefaultModel()
|
||||
{
|
||||
return handleItemState( m_defaultItem );
|
||||
return m_overrides.handleItemState( this, m_defaultItem, null, null );
|
||||
}
|
||||
}
|
||||
|
@@ -302,7 +302,7 @@ public class Terminal
|
||||
m_changed = false;
|
||||
}
|
||||
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
nbttagcompound.setInteger( "term_cursorX", m_cursorX );
|
||||
nbttagcompound.setInteger( "term_cursorY", m_cursorY );
|
||||
@@ -315,6 +315,7 @@ public class Terminal
|
||||
nbttagcompound.setString( "term_textColour_" + n, m_textColour[n].toString() );
|
||||
nbttagcompound.setString( "term_textBgColour_" + n, m_backgroundColour[ n ].toString() );
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
|
@@ -13,7 +13,8 @@ import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
@@ -64,7 +65,7 @@ public class ComputerCraftProxyServer extends ComputerCraftProxyCommon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playRecord( String record, String recordInfo, World world, BlockPos pos )
|
||||
public void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -101,6 +102,6 @@ public class ComputerCraftProxyServer extends ComputerCraftProxyCommon
|
||||
@Override
|
||||
public File getWorldDir( World world )
|
||||
{
|
||||
return new File( ComputerCraft.getBaseDir(), DimensionManager.getWorld(0).getSaveHandler().getWorldDirectoryName() );
|
||||
return DimensionManager.getWorld( 0 ).getSaveHandler().getWorldDirectory();
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@@ -16,10 +16,11 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -54,7 +55,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
{
|
||||
TileGeneric generic = (TileGeneric)tile;
|
||||
generic.getDroppedItems( drops, fortune, false, false );
|
||||
generic.getDroppedItems( drops, false );
|
||||
}
|
||||
return drops;
|
||||
}
|
||||
@@ -66,22 +67,20 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean removedByPlayer( World world, BlockPos pos, EntityPlayer player, boolean willHarvest )
|
||||
public final boolean removedByPlayer( IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
// Drop items
|
||||
int fortune = EnchantmentHelper.getFortuneModifier( player );
|
||||
boolean creative = player.capabilities.isCreativeMode;
|
||||
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier( player );
|
||||
dropAllItems( world, pos, fortune, creative, silkTouch );
|
||||
dropAllItems( world, pos, creative );
|
||||
}
|
||||
|
||||
// Remove block
|
||||
return super.removedByPlayer( world, pos, player, willHarvest );
|
||||
return super.removedByPlayer( state, world, pos, player, willHarvest );
|
||||
}
|
||||
|
||||
public final void dropAllItems( World world, BlockPos pos, int fortune, boolean creative, boolean silkTouch )
|
||||
public final void dropAllItems( World world, BlockPos pos, boolean creative )
|
||||
{
|
||||
// Get items to drop
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>( 1 );
|
||||
@@ -89,7 +88,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
{
|
||||
TileGeneric generic = (TileGeneric)tile;
|
||||
generic.getDroppedItems( drops, fortune, creative, silkTouch );
|
||||
generic.getDroppedItems( drops, creative );
|
||||
}
|
||||
|
||||
// Drop items
|
||||
@@ -123,7 +122,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ItemStack getPickBlock( MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player )
|
||||
public final ItemStack getPickBlock( IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@@ -141,7 +140,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
public final boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@@ -153,7 +152,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onNeighborBlockChange( World world, BlockPos pos, IBlockState state, Block neighbour )
|
||||
public final void onNeighborChange( IBlockAccess world, BlockPos pos, BlockPos neighborPos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@@ -164,7 +163,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSideSolid( IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
public final boolean isSideSolid( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@@ -176,7 +175,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canBeReplacedByLeaves( IBlockAccess world, BlockPos pos )
|
||||
public final boolean canBeReplacedByLeaves( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
return false; // Generify me if anyone ever feels the need to change this
|
||||
}
|
||||
@@ -196,37 +195,56 @@ public abstract class BlockGeneric extends Block implements
|
||||
return super.getExplosionResistance( exploder );
|
||||
}
|
||||
|
||||
private void setBlockBounds( AxisAlignedBB bounds )
|
||||
{
|
||||
setBlockBounds(
|
||||
(float)bounds.minX, (float)bounds.minY, (float)bounds.minZ,
|
||||
(float)bounds.maxX, (float)bounds.maxY, (float)bounds.maxZ
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setBlockBoundsBasedOnState( IBlockAccess world, BlockPos pos )
|
||||
public final AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
|
||||
{
|
||||
TileGeneric generic = (TileGeneric)tile;
|
||||
setBlockBounds( generic.getBounds() );
|
||||
return generic.getBounds();
|
||||
}
|
||||
return NULL_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AxisAlignedBB getCollisionBoundingBox( World world, BlockPos pos, IBlockState state )
|
||||
public final AxisAlignedBB getSelectedBoundingBox( IBlockState state, World world, BlockPos pos )
|
||||
{
|
||||
setBlockBoundsBasedOnState( world, pos );
|
||||
return super.getCollisionBoundingBox( world, pos, state );
|
||||
return getBoundingBox( state, world, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addCollisionBoxesToList( World world, BlockPos pos, IBlockState state, AxisAlignedBB bigBox, List list, Entity entity )
|
||||
public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, World world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
|
||||
{
|
||||
TileGeneric generic = (TileGeneric)tile;
|
||||
|
||||
// Get collision bounds
|
||||
List<AxisAlignedBB> collision = new ArrayList<AxisAlignedBB>( 1 );
|
||||
generic.getCollisionBounds( collision );
|
||||
|
||||
// Return the union of the collision bounds
|
||||
if( collision.size() > 0 )
|
||||
{
|
||||
AxisAlignedBB aabb = collision.get( 0 );
|
||||
for (int i=1; i<collision.size(); ++i )
|
||||
{
|
||||
AxisAlignedBB other = collision.get( 1 );
|
||||
aabb = aabb.union( other );
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
}
|
||||
return NULL_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addCollisionBoxToList( IBlockState state, World world, BlockPos pos, AxisAlignedBB bigBox, List<AxisAlignedBB> list, Entity entity )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
|
||||
{
|
||||
TileGeneric generic = (TileGeneric)tile;
|
||||
|
||||
@@ -241,26 +259,20 @@ public abstract class BlockGeneric extends Block implements
|
||||
while( it.hasNext() )
|
||||
{
|
||||
AxisAlignedBB localBounds = it.next();
|
||||
setBlockBounds( localBounds );
|
||||
|
||||
AxisAlignedBB bounds = super.getCollisionBoundingBox( world, pos, state );
|
||||
if( bounds != null && bigBox.intersectsWith(bounds) )
|
||||
{
|
||||
list.add( bounds );
|
||||
}
|
||||
addCollisionBoxToList( pos, bigBox, list, localBounds );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canProvidePower()
|
||||
public final boolean canProvidePower( IBlockState state )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canConnectRedstone( IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
public final boolean canConnectRedstone( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@@ -272,7 +284,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getStrongPower( IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing oppositeSide )
|
||||
public final int getStrongPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
|
||||
@@ -284,9 +296,9 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getWeakPower( IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing oppositeSide )
|
||||
public final int getWeakPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
|
||||
{
|
||||
return getStrongPower( world, pos, state, oppositeSide );
|
||||
return getStrongPower( state, world, pos, oppositeSide );
|
||||
}
|
||||
|
||||
public boolean getBundledRedstoneConnectivity( World world, BlockPos pos, EnumFacing side )
|
||||
@@ -312,7 +324,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived( World world, BlockPos pos, IBlockState state, int eventID, int eventParameter )
|
||||
public boolean eventReceived( IBlockState state, World world, BlockPos pos, int eventID, int eventParameter )
|
||||
{
|
||||
if( world.isRemote )
|
||||
{
|
||||
|
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -16,10 +16,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -65,8 +65,9 @@ public abstract class TileGeneric extends TileEntity
|
||||
|
||||
public final void updateBlock()
|
||||
{
|
||||
worldObj.markBlockForUpdate( getPos() );
|
||||
worldObj.markChunkDirty( getPos(), this );
|
||||
BlockPos pos = getPos();
|
||||
worldObj.markBlockRangeForRenderUpdate( pos, pos );
|
||||
worldObj.markChunkDirty( pos, this );
|
||||
}
|
||||
|
||||
protected final void setBlockState( IBlockState newState )
|
||||
@@ -74,7 +75,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
worldObj.setBlockState( getPos(), newState, 3 );
|
||||
}
|
||||
|
||||
public void getDroppedItems( List<ItemStack> drops, int fortune, boolean creative, boolean silkTouch )
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -185,16 +186,16 @@ public abstract class TileGeneric extends TileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Packet getDescriptionPacket()
|
||||
public final SPacketUpdateTileEntity getUpdatePacket()
|
||||
{
|
||||
// Communicate properties
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeDescription( nbttagcompound );
|
||||
return new S35PacketUpdateTileEntity( getPos(), 0, nbttagcompound );
|
||||
return new SPacketUpdateTileEntity( getPos(), 0, nbttagcompound );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onDataPacket( NetworkManager net, S35PacketUpdateTileEntity packet )
|
||||
public final void onDataPacket( NetworkManager net, SPacketUpdateTileEntity packet )
|
||||
{
|
||||
switch( packet.getTileEntityType() )
|
||||
{
|
||||
|
@@ -20,7 +20,7 @@ import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandManager;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -83,7 +83,7 @@ public class CommandAPI implements ILuaAPI
|
||||
|
||||
private Object[] doCommand( String command )
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
MinecraftServer server = m_computer.getWorld().getMinecraftServer();
|
||||
if( server != null && server.isCommandBlockEnabled() )
|
||||
{
|
||||
ICommandManager commandManager = server.getCommandManager();
|
||||
@@ -111,7 +111,7 @@ public class CommandAPI implements ILuaAPI
|
||||
// Get the details of the block
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
String name = ((ResourceLocation)Block.blockRegistry.getNameForObject( block )).toString();
|
||||
String name = ((ResourceLocation)Block.REGISTRY.getNameForObject( block )).toString();
|
||||
int metadata = block.getMetaFromState( state );
|
||||
|
||||
Map<Object, Object> table = new HashMap<Object, Object>();
|
||||
@@ -188,7 +188,7 @@ public class CommandAPI implements ILuaAPI
|
||||
{
|
||||
int i = 1;
|
||||
Map<Object, Object> result = new HashMap<Object, Object>();
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
MinecraftServer server = m_computer.getWorld().getMinecraftServer();
|
||||
if( server != null )
|
||||
{
|
||||
ICommandManager commandManager = server.getCommandManager();
|
||||
@@ -201,7 +201,7 @@ public class CommandAPI implements ILuaAPI
|
||||
ICommand command = (ICommand)entry.getValue();
|
||||
try
|
||||
{
|
||||
if( command.canCommandSenderUseCommand( commmandSender ) )
|
||||
if( command.checkPermission( server, commmandSender ) )
|
||||
{
|
||||
result.put( i++, name );
|
||||
}
|
||||
|
@@ -15,12 +15,12 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -32,14 +32,14 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
public static final PropertyEnum STATE = PropertyEnum.create("state", ComputerState.class);
|
||||
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class);
|
||||
}
|
||||
|
||||
// Members
|
||||
|
||||
public BlockCommandComputer()
|
||||
{
|
||||
super( Material.iron );
|
||||
super( Material.IRON );
|
||||
setBlockUnbreakable();
|
||||
setResistance( 6000000.0F );
|
||||
setUnlocalizedName( "computercraft:command_computer" );
|
||||
@@ -51,9 +51,9 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] {
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.STATE
|
||||
});
|
||||
|
@@ -16,13 +16,13 @@ import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -34,14 +34,14 @@ public class BlockComputer extends BlockComputerBase
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
public static final PropertyBool ADVANCED = PropertyBool.create("advanced");
|
||||
public static final PropertyEnum STATE = PropertyEnum.create("state", ComputerState.class);
|
||||
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class);
|
||||
}
|
||||
|
||||
// Members
|
||||
|
||||
public BlockComputer()
|
||||
{
|
||||
super( Material.rock );
|
||||
super( Material.ROCK );
|
||||
setHardness( 2.0f );
|
||||
setUnlocalizedName( "computercraft:computer" );
|
||||
setCreativeTab( ComputerCraft.mainCreativeTab );
|
||||
@@ -53,9 +53,9 @@ public class BlockComputer extends BlockComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] {
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.ADVANCED,
|
||||
Properties.STATE
|
||||
|
@@ -13,7 +13,7 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@@ -12,19 +12,22 @@ import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.command.server.CommandBlockLogic;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.CommandBlockBaseLogic;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TileCommandComputer extends TileComputer
|
||||
{
|
||||
public class CommandSender extends CommandBlockLogic
|
||||
public class CommandSender extends CommandBlockBaseLogic
|
||||
{
|
||||
private Map<Integer, String> m_outputTable;
|
||||
|
||||
@@ -51,7 +54,7 @@ public class TileCommandComputer extends TileComputer
|
||||
// ICommandSender
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
IComputer computer = TileCommandComputer.this.getComputer();
|
||||
if( computer != null )
|
||||
@@ -59,14 +62,14 @@ public class TileCommandComputer extends TileComputer
|
||||
String label = computer.getLabel();
|
||||
if( label != null )
|
||||
{
|
||||
return new ChatComponentText( computer.getLabel() );
|
||||
return new TextComponentString( computer.getLabel() );
|
||||
}
|
||||
}
|
||||
return new ChatComponentText( "@" );
|
||||
return new TextComponentString( "@" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChatMessage( IChatComponent chatComponent )
|
||||
public void addChatMessage( ITextComponent chatComponent )
|
||||
{
|
||||
m_outputTable.put( m_outputTable.size() + 1, chatComponent.getUnformattedText() );
|
||||
}
|
||||
@@ -84,16 +87,22 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getPositionVector()
|
||||
public Vec3d getPositionVector()
|
||||
{
|
||||
BlockPos pos = getPosition();
|
||||
return new Vec3( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getEntityWorld()
|
||||
{
|
||||
return TileCommandComputer.this.worldObj;
|
||||
return TileCommandComputer.this.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftServer getServer()
|
||||
{
|
||||
return TileCommandComputer.this.getWorld().getMinecraftServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,13 +120,13 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
@Override
|
||||
public int func_145751_f()
|
||||
public int getCommandBlockType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_145757_a( ByteBuf p_145757_1_ )
|
||||
public void fillInInfo( ByteBuf buf )
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -163,10 +172,10 @@ public class TileCommandComputer extends TileComputer
|
||||
@Override
|
||||
public boolean isUsable( EntityPlayer player, boolean ignoreRange )
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
MinecraftServer server = player.getServer();
|
||||
if( server == null || !server.isCommandBlockEnabled() )
|
||||
{
|
||||
player.addChatMessage( new ChatComponentTranslation( "advMode.notEnabled" ) );
|
||||
player.addChatMessage( new TextComponentTranslation( "advMode.notEnabled" ) );
|
||||
return false;
|
||||
}
|
||||
else if( ComputerCraft.canPlayerUseCommands( player ) && player.capabilities.isCreativeMode )
|
||||
@@ -175,7 +184,7 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addChatMessage( new ChatComponentTranslation( "advMode.notAllowed" ) );
|
||||
player.addChatMessage( new TextComponentTranslation( "advMode.notAllowed" ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ public class TileComputer extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, int fortune, boolean creative, boolean silkTouch )
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
IComputer computer = getComputer();
|
||||
if( !creative || (computer != null && computer.getLabel() != null) )
|
||||
|
@@ -22,8 +22,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public abstract class TileComputerBase extends TileGeneric
|
||||
@@ -113,8 +114,8 @@ public abstract class TileComputerBase extends TileGeneric
|
||||
@Override
|
||||
public boolean onActivate( EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
if( currentItem != null && currentItem.getItem() == Items.name_tag && canNameWithTag( player ) )
|
||||
ItemStack currentItem = player.getHeldItem( EnumHand.MAIN_HAND );
|
||||
if( currentItem != null && currentItem.getItem() == Items.NAME_TAG && canNameWithTag( player ) )
|
||||
{
|
||||
// Label to rename computer
|
||||
if( !worldObj.isRemote )
|
||||
@@ -232,9 +233,9 @@ public abstract class TileComputerBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
|
||||
// Save ID, label and power state
|
||||
if( m_computerID >= 0 )
|
||||
@@ -246,6 +247,7 @@ public abstract class TileComputerBase extends TileGeneric
|
||||
nbttagcompound.setString( "label", m_label );
|
||||
}
|
||||
nbttagcompound.setBoolean( "on", m_on );
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -21,7 +21,7 @@ import dan200.computercraft.shared.network.INetworkedThing;
|
||||
import dan200.computercraft.shared.util.NBTUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -15,6 +15,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
@@ -92,7 +93,7 @@ public abstract class ItemComputerBase extends ItemBlock implements IComputerIte
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAudioRecordName( ItemStack stack )
|
||||
public SoundEvent getAudio( ItemStack stack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@@ -15,7 +15,9 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
@@ -122,7 +124,7 @@ public class ItemDiskLegacy extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAudioRecordName( ItemStack stack )
|
||||
public SoundEvent getAudio( ItemStack stack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -139,19 +141,13 @@ public class ItemDiskLegacy extends Item
|
||||
return ComputerCraftAPI.createSaveDirMount( world, "computer/disk/" + diskID, ComputerCraft.floppySpaceLimit );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack( ItemStack stack, int layer )
|
||||
{
|
||||
return layer == 0 ? 0xffffff : getColor(stack);
|
||||
}
|
||||
|
||||
public int getColor( ItemStack stack )
|
||||
{
|
||||
return Colour.Blue.getHex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( World world, BlockPos pos, EntityPlayer player )
|
||||
public boolean doesSneakBypassUse( ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -12,6 +12,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
@@ -78,13 +81,14 @@ public class ItemPrintout extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player )
|
||||
public ActionResult<ItemStack> onItemRightClick( ItemStack stack, World world, EntityPlayer player, EnumHand hand )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
ComputerCraft.openPrintoutGUI( player );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, stack );
|
||||
}
|
||||
return stack;
|
||||
return new ActionResult<ItemStack>( EnumActionResult.PASS, stack );
|
||||
}
|
||||
|
||||
private static ItemStack createFromTitleAndText( Type type, String title, String[] text, String[] colours )
|
||||
|
@@ -16,10 +16,10 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -30,8 +30,6 @@ import java.util.Random;
|
||||
public class ItemTreasureDisk extends Item
|
||||
implements IMedia
|
||||
{
|
||||
private static ItemStack[] s_treasureItems = null;
|
||||
|
||||
public ItemTreasureDisk()
|
||||
{
|
||||
setMaxStackSize( 1 );
|
||||
@@ -42,10 +40,6 @@ public class ItemTreasureDisk extends Item
|
||||
@Override
|
||||
public void getSubItems( Item itemID, CreativeTabs tabs, List list )
|
||||
{
|
||||
if( s_treasureItems != null )
|
||||
{
|
||||
Collections.addAll( list, s_treasureItems );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,15 +51,9 @@ public class ItemTreasureDisk extends Item
|
||||
list.add( label );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack( ItemStack stack, int pass )
|
||||
{
|
||||
return pass == 0 ? 0xffffff : getColour(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( World world, BlockPos pos, EntityPlayer player )
|
||||
public boolean doesSneakBypassUse( ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -91,7 +79,7 @@ public class ItemTreasureDisk extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAudioRecordName( ItemStack stack )
|
||||
public SoundEvent getAudio( ItemStack stack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -145,91 +133,11 @@ public class ItemTreasureDisk extends Item
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void registerDungeonLoot()
|
||||
{
|
||||
if( s_treasureItems == null )
|
||||
{
|
||||
// Get the list of all programs
|
||||
List<String> paths = new ArrayList<String>();
|
||||
try
|
||||
{
|
||||
IMount treasure = getTreasureMount();
|
||||
if( treasure != null )
|
||||
{
|
||||
List<String> authors = new ArrayList<String>();
|
||||
treasure.list( "", authors );
|
||||
for( String author : authors )
|
||||
{
|
||||
if( treasure.isDirectory( author ) && !author.equals( "deprecated" ) )
|
||||
{
|
||||
List<String> titles = new ArrayList<String>();
|
||||
treasure.list( author, titles );
|
||||
for( String title : titles )
|
||||
{
|
||||
String path = author + "/" + title;
|
||||
if( treasure.isDirectory( path ) )
|
||||
{
|
||||
paths.add( path );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( java.io.IOException e )
|
||||
{
|
||||
// no items for us
|
||||
}
|
||||
|
||||
// Build creative tab
|
||||
List<ItemStack> allTreasure = new ArrayList<ItemStack>();
|
||||
for( String path : paths )
|
||||
{
|
||||
ItemStack stack = create( path, 4 );
|
||||
allTreasure.add( stack );
|
||||
}
|
||||
s_treasureItems = allTreasure.toArray( new ItemStack[ allTreasure.size() ] );
|
||||
|
||||
// Register the loot
|
||||
int n=0;
|
||||
Random random = new Random();
|
||||
WeightedRandomChestContent[] content = new WeightedRandomChestContent[ paths.size() * ComputerCraft.treasureDiskLootFrequency ];
|
||||
WeightedRandomChestContent[] commonContent = new WeightedRandomChestContent[ paths.size() * ComputerCraft.treasureDiskLootFrequency ];
|
||||
for( String path : paths )
|
||||
{
|
||||
// Don't use all the random colours
|
||||
// We don't want to overload the probability matrix
|
||||
for( int i=0; i<ComputerCraft.treasureDiskLootFrequency; ++i )
|
||||
{
|
||||
ItemStack stack = create( path, random.nextInt( 16 ) );
|
||||
content[ n ] = new WeightedRandomChestContent( stack, 1, 1, 1 );
|
||||
commonContent[ n ] = new WeightedRandomChestContent( stack, 1, 1, 2 );
|
||||
n++;
|
||||
}
|
||||
}
|
||||
registerLoot( ChestGenHooks.DUNGEON_CHEST, content );
|
||||
registerLoot( ChestGenHooks.MINESHAFT_CORRIDOR, content );
|
||||
registerLoot( ChestGenHooks.STRONGHOLD_CORRIDOR, content );
|
||||
registerLoot( ChestGenHooks.STRONGHOLD_CROSSING, content );
|
||||
registerLoot( ChestGenHooks.STRONGHOLD_LIBRARY, commonContent );
|
||||
registerLoot( ChestGenHooks.PYRAMID_DESERT_CHEST, content );
|
||||
registerLoot( ChestGenHooks.PYRAMID_JUNGLE_CHEST, content );
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerLoot( String category, WeightedRandomChestContent[] content )
|
||||
{
|
||||
for( int i=0; i<content.length; ++i )
|
||||
{
|
||||
ChestGenHooks.getInfo( category ).addItem( content[i] );
|
||||
}
|
||||
}
|
||||
|
||||
private static IMount getTreasureMount()
|
||||
{
|
||||
return ComputerCraft.createResourceMount( ComputerCraft.class, "computercraft", "lua/treasure" );
|
||||
}
|
||||
|
||||
|
||||
// private stuff
|
||||
|
||||
public String getTitle( ItemStack stack )
|
||||
|
@@ -11,6 +11,7 @@ import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import net.minecraft.item.ItemRecord;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
// An implementation of IMedia for ItemRecord's
|
||||
@@ -39,10 +40,10 @@ public class RecordMedia implements IMedia
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAudioRecordName( ItemStack stack )
|
||||
public SoundEvent getAudio( ItemStack stack )
|
||||
{
|
||||
ItemRecord itemRecord = (ItemRecord)stack.getItem();
|
||||
return "records." + itemRecord.recordName;
|
||||
return itemRecord.getSound();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -43,11 +43,11 @@ public class DiskRecipe implements IRecipe
|
||||
|
||||
diskFound = true;
|
||||
}
|
||||
else if( var6.getItem() == Items.dye )
|
||||
else if( var6.getItem() == Items.DYE )
|
||||
{
|
||||
dyeFound = true;
|
||||
}
|
||||
else if( var6.getItem() == Items.paper )
|
||||
else if( var6.getItem() == Items.PAPER )
|
||||
{
|
||||
if(paperFound || diskFound)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ public class DiskRecipe implements IRecipe
|
||||
}
|
||||
paperFound = true;
|
||||
}
|
||||
else if (var6.getItem() == Items.redstone)
|
||||
else if (var6.getItem() == Items.REDSTONE)
|
||||
{
|
||||
if (redstoneFound || diskFound)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ public class DiskRecipe implements IRecipe
|
||||
diskID = var6.getDiskID( var8 );
|
||||
diskLabel = var6.getLabel( var8 );
|
||||
}
|
||||
else if (var8.getItem() == Items.dye)
|
||||
else if (var8.getItem() == Items.DYE)
|
||||
{
|
||||
dyeFound = true;
|
||||
float[] var14 = Colour.values()[ var8.getItemDamage() & 0xf ].getRGB();
|
||||
@@ -116,7 +116,7 @@ public class DiskRecipe implements IRecipe
|
||||
var3[2] += var17;
|
||||
++var5;
|
||||
}
|
||||
else if (!(var8.getItem() != Items.paper || var8.getItem() != Items.redstone))
|
||||
else if (!(var8.getItem() != Items.PAPER || var8.getItem() != Items.REDSTONE))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ public class PrintoutRecipe implements IRecipe
|
||||
numPrintouts++;
|
||||
printoutFound = true;
|
||||
}
|
||||
else if( item == Items.paper )
|
||||
else if( item == Items.PAPER )
|
||||
{
|
||||
if( printouts == null )
|
||||
{
|
||||
@@ -77,11 +77,11 @@ public class PrintoutRecipe implements IRecipe
|
||||
numPages++;
|
||||
numPrintouts++;
|
||||
}
|
||||
else if( item == Items.string && !stringFound )
|
||||
else if( item == Items.STRING && !stringFound )
|
||||
{
|
||||
stringFound = true;
|
||||
}
|
||||
else if( item == Items.leather && !leatherFound )
|
||||
else if( item == Items.LEATHER && !leatherFound )
|
||||
{
|
||||
leatherFound = true;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ public class PacketHandler
|
||||
try
|
||||
{
|
||||
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||||
packet.fromBytes( event.packet.payload() );
|
||||
packet.fromBytes( event.getPacket().payload() );
|
||||
ComputerCraft.handlePacket( packet, null );
|
||||
}
|
||||
catch( Exception e )
|
||||
@@ -34,8 +34,8 @@ public class PacketHandler
|
||||
try
|
||||
{
|
||||
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||||
packet.fromBytes( event.packet.payload() );
|
||||
ComputerCraft.handlePacket( packet, ((NetHandlerPlayServer)event.handler).playerEntity );
|
||||
packet.fromBytes( event.getPacket().payload() );
|
||||
ComputerCraft.handlePacket( packet, ((NetHandlerPlayServer)event.getHandler()).playerEntity );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
|
@@ -12,6 +12,7 @@ import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class CommandBlockPeripheral implements IPeripheral
|
||||
{
|
||||
@@ -73,8 +74,9 @@ public class CommandBlockPeripheral implements IPeripheral
|
||||
@Override
|
||||
public Object[] execute() throws LuaException
|
||||
{
|
||||
BlockPos pos = m_commandBlock.getPos();
|
||||
m_commandBlock.getCommandBlockLogic().setCommand( command );
|
||||
m_commandBlock.getWorld().markBlockForUpdate( m_commandBlock.getPos() );
|
||||
m_commandBlock.getWorld().markBlockRangeForRenderUpdate( pos, pos );
|
||||
return null;
|
||||
}
|
||||
} );
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -13,11 +13,11 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class BlockCable extends BlockPeripheralBase
|
||||
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyEnum MODEM = PropertyEnum.create( "modem", BlockCableModemVariant.class );
|
||||
public static final PropertyEnum<BlockCableModemVariant> MODEM = PropertyEnum.<BlockCableModemVariant>create( "modem", BlockCableModemVariant.class );
|
||||
public static final PropertyBool CABLE = PropertyBool.create( "cable" );
|
||||
public static final PropertyBool NORTH = PropertyBool.create( "north" );
|
||||
public static final PropertyBool SOUTH = PropertyBool.create( "south" );
|
||||
@@ -74,9 +74,9 @@ public class BlockCable extends BlockPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] {
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.MODEM,
|
||||
Properties.CABLE,
|
||||
Properties.NORTH,
|
||||
@@ -209,7 +209,7 @@ public class BlockCable extends BlockPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered( IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
public boolean shouldSideBeRendered( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -16,15 +16,15 @@ import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -34,8 +34,8 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
{
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create( "facing",EnumFacing.Plane.HORIZONTAL );
|
||||
public static final PropertyEnum VARIANT = PropertyEnum.create( "variant", BlockPeripheralVariant.class );
|
||||
public static final PropertyDirection FACING = PropertyDirection.create( "facing", EnumFacing.Plane.HORIZONTAL );
|
||||
public static final PropertyEnum<BlockPeripheralVariant> VARIANT = PropertyEnum.<BlockPeripheralVariant>create( "variant", BlockPeripheralVariant.class );
|
||||
}
|
||||
|
||||
public BlockPeripheral()
|
||||
@@ -50,15 +50,15 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT)
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
public BlockRenderLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] {
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.VARIANT
|
||||
});
|
||||
|
@@ -12,7 +12,7 @@ import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -21,7 +21,7 @@ public abstract class BlockPeripheralBase extends BlockDirectional
|
||||
{
|
||||
public BlockPeripheralBase()
|
||||
{
|
||||
super( Material.rock );
|
||||
super( Material.ROCK );
|
||||
}
|
||||
|
||||
protected abstract IBlockState getDefaultBlockState( PeripheralType type, EnumFacing placedSide );
|
||||
@@ -30,13 +30,13 @@ public abstract class BlockPeripheralBase extends BlockDirectional
|
||||
protected abstract TilePeripheralBase createTile( PeripheralType type );
|
||||
|
||||
@Override
|
||||
public final boolean isOpaqueCube()
|
||||
public final boolean isOpaqueCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isFullCube()
|
||||
public final boolean isFullCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import dan200.computercraft.shared.computer.blocks.ComputerPeripheral;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputerBase;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -17,7 +17,10 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -67,11 +70,11 @@ public class ItemCable extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float fx, float fy, float fz )
|
||||
public EnumActionResult onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float fx, float fy, float fz )
|
||||
{
|
||||
if( !canPlaceBlockOnSide( world, pos, side, player, stack ) )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
// Try to add a cable to a modem
|
||||
@@ -86,7 +89,7 @@ public class ItemCable extends ItemPeripheralBase
|
||||
if( stack.stackSize > 0 )
|
||||
{
|
||||
world.setBlockState( pos, existingState.withProperty( BlockCable.Properties.CABLE, true ), 3 );
|
||||
world.playSoundEffect( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, ComputerCraft.Blocks.cable.stepSound.getBreakSound(), (ComputerCraft.Blocks.cable.stepSound.getVolume() + 1.0F) / 2.0F, ComputerCraft.Blocks.cable.stepSound.getFrequency() * 0.8F);
|
||||
world.playSound( null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, ComputerCraft.Blocks.cable.getSoundType().getBreakSound(), SoundCategory.BLOCKS, (ComputerCraft.Blocks.cable.getSoundType().getVolume() + 1.0F ) / 2.0F, ComputerCraft.Blocks.cable.getSoundType().getPitch() * 0.8F);
|
||||
stack.stackSize--;
|
||||
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
@@ -95,14 +98,14 @@ public class ItemCable extends ItemPeripheralBase
|
||||
TileCable cable = (TileCable)tile;
|
||||
cable.networkChanged();
|
||||
}
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to add on the side of something
|
||||
if( existing != Blocks.air && (type == PeripheralType.Cable || existing.isSideSolid( world, pos, side )) )
|
||||
if( !existing.isAir( existingState, world, pos ) && (type == PeripheralType.Cable || existing.isSideSolid( existingState, world, pos, side )) )
|
||||
{
|
||||
BlockPos offset = pos.offset( side );
|
||||
Block offsetExisting = world.getBlockState( offset ).getBlock();
|
||||
@@ -116,7 +119,7 @@ public class ItemCable extends ItemPeripheralBase
|
||||
if( stack.stackSize > 0 )
|
||||
{
|
||||
world.setBlockState( offset, offsetExistingState.withProperty( BlockCable.Properties.MODEM, BlockCableModemVariant.fromFacing( side.getOpposite() ) ), 3 );
|
||||
world.playSoundEffect( offset.getX() + 0.5, offset.getY() + 0.5, offset.getZ() + 0.5, ComputerCraft.Blocks.cable.stepSound.getBreakSound(), (ComputerCraft.Blocks.cable.stepSound.getVolume() + 1.0F) / 2.0F, ComputerCraft.Blocks.cable.stepSound.getFrequency() * 0.8F);
|
||||
world.playSound( null, offset.getX() + 0.5, offset.getY() + 0.5, offset.getZ() + 0.5, ComputerCraft.Blocks.cable.getSoundType().getBreakSound(), SoundCategory.BLOCKS, (ComputerCraft.Blocks.cable.getSoundType().getVolume() + 1.0F ) / 2.0F, ComputerCraft.Blocks.cable.getSoundType().getPitch() * 0.8F);
|
||||
stack.stackSize--;
|
||||
|
||||
TileEntity tile = world.getTileEntity( offset );
|
||||
@@ -125,9 +128,9 @@ public class ItemCable extends ItemPeripheralBase
|
||||
TileCable cable = (TileCable)tile;
|
||||
cable.networkChanged();
|
||||
}
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
// Try to add a cable to a modem
|
||||
@@ -136,7 +139,7 @@ public class ItemCable extends ItemPeripheralBase
|
||||
if( stack.stackSize > 0 )
|
||||
{
|
||||
world.setBlockState( offset, offsetExistingState.withProperty( BlockCable.Properties.CABLE, true ), 3 );
|
||||
world.playSoundEffect( offset.getX() + 0.5, offset.getY() + 0.5, offset.getZ() + 0.5, ComputerCraft.Blocks.cable.stepSound.getBreakSound(), (ComputerCraft.Blocks.cable.stepSound.getVolume() + 1.0F) / 2.0F, ComputerCraft.Blocks.cable.stepSound.getFrequency() * 0.8F);
|
||||
world.playSound( null, offset.getX() + 0.5, offset.getY() + 0.5, offset.getZ() + 0.5, ComputerCraft.Blocks.cable.getSoundType().getBreakSound(), SoundCategory.BLOCKS, (ComputerCraft.Blocks.cable.getSoundType().getVolume() + 1.0F ) / 2.0F, ComputerCraft.Blocks.cable.getSoundType().getPitch() * 0.8F);
|
||||
stack.stackSize--;
|
||||
|
||||
TileEntity tile = world.getTileEntity( offset );
|
||||
@@ -145,14 +148,14 @@ public class ItemCable extends ItemPeripheralBase
|
||||
TileCable cable = (TileCable)tile;
|
||||
cable.networkChanged();
|
||||
}
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemUse( stack, player, world, pos, side, fx, fy, fz );
|
||||
return super.onItemUse( stack, player, world, pos, hand, side, fx, fy, fz );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -11,7 +11,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -45,7 +45,7 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, int fortune, boolean creative, boolean silkTouch )
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
if( !creative )
|
||||
{
|
||||
@@ -150,16 +150,17 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
// Write properties
|
||||
super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound.setInteger( "dir", m_dir.getIndex() );
|
||||
nbttagcompound.setInteger( "anim", m_anim );
|
||||
if( m_label != null )
|
||||
{
|
||||
nbttagcompound.setString( "label", m_label );
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -118,7 +118,7 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
IMedia media = m_diskDrive.getDiskMedia();
|
||||
if( media != null )
|
||||
{
|
||||
return new Object[] { media.getAudioRecordName( m_diskDrive.getDiskStack() ) != null };
|
||||
return new Object[] { media.getAudio( m_diskDrive.getDiskStack() ) != null };
|
||||
}
|
||||
return new Object[] { false };
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.audio.Sound;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -24,6 +25,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -89,13 +92,13 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
// Try to put a disk into the drive
|
||||
if( !worldObj.isRemote )
|
||||
{
|
||||
ItemStack disk = player.getCurrentEquippedItem();
|
||||
ItemStack disk = player.getHeldItem( EnumHand.MAIN_HAND );
|
||||
if( disk != null && getStackInSlot(0) == null )
|
||||
{
|
||||
if( ComputerCraft.getMedia( disk ) != null )
|
||||
{
|
||||
setInventorySlotContents( 0, disk );
|
||||
player.destroyCurrentEquippedItem();
|
||||
player.setHeldItem( EnumHand.MAIN_HAND, null );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -143,15 +146,16 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
if( m_diskStack != null )
|
||||
{
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
m_diskStack.writeToNBT( item );
|
||||
nbttagcompound.setTag( "item", item );
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,7 +182,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
if( m_recordQueued )
|
||||
{
|
||||
IMedia contents = getDiskMedia();
|
||||
String record = (contents != null) ? contents.getAudioRecordName( m_diskStack ) : null;
|
||||
SoundEvent record = (contents != null) ? contents.getAudio( m_diskStack ) : null;
|
||||
if( record != null )
|
||||
{
|
||||
m_recordPlaying = true;
|
||||
@@ -331,15 +335,15 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
if( hasCustomName() )
|
||||
{
|
||||
return new ChatComponentText( getName() );
|
||||
return new TextComponentString( getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ChatComponentTranslation( getName() );
|
||||
return new TextComponentTranslation( getName() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,7 +607,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
worldObj.spawnEntityInWorld(entityitem);
|
||||
if( !destroyed )
|
||||
{
|
||||
worldObj.playAuxSFX(1000, getPos(), 0);
|
||||
worldObj.playBroadcastSound(1000, getPos(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -665,7 +669,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
private void playRecord()
|
||||
{
|
||||
IMedia contents = getDiskMedia();
|
||||
String record = (contents != null) ? contents.getAudioRecordName( m_diskStack ) : null;
|
||||
SoundEvent record = (contents != null) ? contents.getAudio( m_diskStack ) : null;
|
||||
if( record != null )
|
||||
{
|
||||
ComputerCraft.playRecord( record, contents.getAudioTitle( m_diskStack ), worldObj, getPos() );
|
||||
|
@@ -13,12 +13,12 @@ import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -43,9 +43,9 @@ public class BlockAdvancedModem extends BlockPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] {
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.ON
|
||||
});
|
||||
|
@@ -6,13 +6,13 @@
|
||||
|
||||
package dan200.computercraft.shared.peripheral.modem;
|
||||
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface INetwork
|
||||
{
|
||||
public void addReceiver( IReceiver receiver );
|
||||
public void removeReceiver( IReceiver receiver );
|
||||
public void transmit( int channel, int replyChannel, Object payload, World world, Vec3 pos, double range, boolean interdimensional, Object senderObject );
|
||||
public void transmit( int channel, int replyChannel, Object payload, World world, Vec3d pos, double range, boolean interdimensional, Object senderObject );
|
||||
public boolean isWireless();
|
||||
}
|
||||
|
@@ -5,14 +5,14 @@
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.peripheral.modem;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IReceiver
|
||||
{
|
||||
public int getChannel();
|
||||
public World getWorld();
|
||||
public Vec3 getWorldPosition();
|
||||
public Vec3d getWorldPosition();
|
||||
public boolean isInterdimensional();
|
||||
public double getReceiveRange();
|
||||
public void receiveSameDimension( int replyChannel, Object payload, double distance, Object senderObject );
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -46,7 +46,7 @@ public abstract class ModemPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getWorldPosition()
|
||||
public Vec3d getWorldPosition()
|
||||
{
|
||||
return m_owner.getWorldPosition();
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public abstract class ModemPeripheral
|
||||
|
||||
protected abstract World getWorld();
|
||||
|
||||
protected abstract Vec3 getPosition();
|
||||
protected abstract Vec3d getPosition();
|
||||
|
||||
public synchronized void destroy()
|
||||
{
|
||||
@@ -163,7 +163,7 @@ public abstract class ModemPeripheral
|
||||
return (m_computer != null) && m_open;
|
||||
}
|
||||
|
||||
public synchronized Vec3 getWorldPosition()
|
||||
public synchronized Vec3d getWorldPosition()
|
||||
{
|
||||
return getPosition();
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public abstract class ModemPeripheral
|
||||
synchronized( this )
|
||||
{
|
||||
World world = getWorld();
|
||||
Vec3 position = getPosition();
|
||||
Vec3d position = getPosition();
|
||||
if( world != null && position != null && m_network != null)
|
||||
{
|
||||
m_network.transmit( channel, replyChannel, payload, world, position, getTransmitRange(), isInterdimensional(), this );
|
||||
|
@@ -9,9 +9,9 @@ package dan200.computercraft.shared.peripheral.modem;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileAdvancedModem extends TileModemBase
|
||||
@@ -35,10 +35,10 @@ public class TileAdvancedModem extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3 getPosition()
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
BlockPos pos = m_entity.getPos().offset( m_entity.getDirection() );
|
||||
return new Vec3( (double)pos.getX(), (double)pos.getY(), (double)pos.getZ() );
|
||||
return new Vec3d( (double)pos.getX(), (double)pos.getY(), (double)pos.getZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +64,7 @@ public class TileAdvancedModem extends TileModemBase
|
||||
{
|
||||
// Wireless Modem
|
||||
IBlockState state = getBlockState();
|
||||
return (EnumFacing)state.getValue( BlockPeripheral.Properties.FACING );
|
||||
return (EnumFacing)state.getValue( BlockAdvancedModem.Properties.FACING );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +72,7 @@ public class TileAdvancedModem extends TileModemBase
|
||||
{
|
||||
// Wireless Modem
|
||||
setBlockState( getBlockState()
|
||||
.withProperty( BlockPeripheral.Properties.FACING, dir )
|
||||
.withProperty( BlockAdvancedModem.Properties.FACING, dir )
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.io.File;
|
||||
@@ -71,11 +73,11 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3 getPosition()
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
EnumFacing direction = m_entity.getDirection();
|
||||
BlockPos pos = m_entity.getPos().offset( direction );
|
||||
return new Vec3( (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5 );
|
||||
return new Vec3d( (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -287,7 +289,7 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, int fortune, boolean creative, boolean silkTouch )
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
if( !creative )
|
||||
{
|
||||
@@ -337,7 +339,7 @@ public class TileCable extends TileModemBase
|
||||
case WiredModem:
|
||||
{
|
||||
// Drop everything and remove block
|
||||
((BlockGeneric)getBlockType()).dropAllItems( worldObj, getPos(), 0, false, false );
|
||||
((BlockGeneric)getBlockType()).dropAllItems( worldObj, getPos(), false );
|
||||
worldObj.setBlockToAir( getPos() );
|
||||
break;
|
||||
}
|
||||
@@ -456,13 +458,13 @@ public class TileCable extends TileModemBase
|
||||
if( oldPeriphName != null )
|
||||
{
|
||||
player.addChatMessage(
|
||||
new ChatComponentTranslation( "gui.computercraft:wired_modem.peripheral_disconnected", oldPeriphName )
|
||||
new TextComponentTranslation( "gui.computercraft:wired_modem.peripheral_disconnected", oldPeriphName )
|
||||
);
|
||||
}
|
||||
if( periphName != null )
|
||||
{
|
||||
player.addChatMessage(
|
||||
new ChatComponentTranslation( "gui.computercraft:wired_modem.peripheral_connected", periphName )
|
||||
new TextComponentTranslation( "gui.computercraft:wired_modem.peripheral_connected", periphName )
|
||||
);
|
||||
}
|
||||
return true;
|
||||
@@ -488,12 +490,13 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
// Write properties
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setBoolean( "peripheralAccess", m_peripheralAccessAllowed );
|
||||
nbttagcompound.setInteger( "peripheralID", m_attachedPeripheralID );
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -590,7 +593,7 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transmit( int channel, int replyChannel, Object payload, World world, Vec3 pos, double range, boolean interdimensional, Object senderObject )
|
||||
public void transmit( int channel, int replyChannel, Object payload, World world, Vec3d pos, double range, boolean interdimensional, Object senderObject )
|
||||
{
|
||||
Packet p = new Packet();
|
||||
p.channel = channel;
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public abstract class TileModemBase extends TilePeripheralBase
|
||||
@@ -50,7 +50,7 @@ public abstract class TileModemBase extends TilePeripheralBase
|
||||
) )
|
||||
{
|
||||
// Drop everything and remove block
|
||||
((BlockGeneric)getBlockType()).dropAllItems( worldObj, getPos(), 0, false, false );
|
||||
((BlockGeneric)getBlockType()).dropAllItems( worldObj, getPos(), false );
|
||||
worldObj.setBlockToAir( getPos() );
|
||||
}
|
||||
}
|
||||
|
@@ -12,9 +12,9 @@ import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheralVariant;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileWirelessModem extends TileModemBase
|
||||
@@ -38,10 +38,10 @@ public class TileWirelessModem extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3 getPosition()
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
BlockPos pos = m_entity.getPos().offset( m_entity.getDirection() );
|
||||
return new Vec3( (double)pos.getX(), (double)pos.getY(), (double)pos.getZ() );
|
||||
return new Vec3d( (double)pos.getX(), (double)pos.getY(), (double)pos.getZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -7,7 +7,7 @@
|
||||
package dan200.computercraft.shared.peripheral.modem;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class WirelessModemPeripheral extends ModemPeripheral
|
||||
@@ -37,7 +37,7 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral
|
||||
World world = getWorld();
|
||||
if( world != null )
|
||||
{
|
||||
Vec3 position = getPosition();
|
||||
Vec3d position = getPosition();
|
||||
double minRange = (double) ComputerCraft.modem_range;
|
||||
double maxRange = (double) ComputerCraft.modem_highAltitudeRange;
|
||||
if( world.isRaining() && world.isThundering() )
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
package dan200.computercraft.shared.peripheral.modem;
|
||||
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.*;
|
||||
@@ -61,7 +61,7 @@ public class WirelessNetwork implements INetwork
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void transmit( int channel, int replyChannel, Object payload, World world, Vec3 pos, double range, boolean interdimensional, Object senderObject )
|
||||
public synchronized void transmit( int channel, int replyChannel, Object payload, World world, Vec3d pos, double range, boolean interdimensional, Object senderObject )
|
||||
{
|
||||
Set<IReceiver> receivers = m_receivers.get( channel );
|
||||
if( receivers != null )
|
||||
@@ -75,11 +75,11 @@ public class WirelessNetwork implements INetwork
|
||||
}
|
||||
}
|
||||
|
||||
private void tryTransmit( IReceiver receiver, int replyChannel, Object payload, World world, Vec3 pos, double range, boolean interdimensional, Object senderObject )
|
||||
private void tryTransmit( IReceiver receiver, int replyChannel, Object payload, World world, Vec3d pos, double range, boolean interdimensional, Object senderObject )
|
||||
{
|
||||
if( receiver.getWorld() == world )
|
||||
{
|
||||
Vec3 position = receiver.getWorldPosition();
|
||||
Vec3d position = receiver.getWorldPosition();
|
||||
double receiveRange = Math.max( range, receiver.getReceiveRange() ); // Ensure range is symmetrical
|
||||
double distanceSq = position.squareDistanceTo( pos );
|
||||
if( interdimensional || receiver.isInterdimensional() || distanceSq <= ( receiveRange * receiveRange ) )
|
||||
|
@@ -20,8 +20,8 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -112,14 +112,15 @@ public class TileMonitor extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound);
|
||||
nbttagcompound.setInteger( "xIndex", m_xIndex );
|
||||
nbttagcompound.setInteger( "yIndex", m_yIndex );
|
||||
nbttagcompound.setInteger( "width", m_width );
|
||||
nbttagcompound.setInteger( "height", m_height );
|
||||
nbttagcompound.setInteger( "dir", m_dir );
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.peripheral.printer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -61,10 +61,10 @@ public class ContainerPrinter extends Container
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftGuiOpened( ICrafting crafting )
|
||||
public void addListener( IContainerListener crafting )
|
||||
{
|
||||
super.onCraftGuiOpened( crafting );
|
||||
crafting.sendProgressBarUpdate( this, 0, m_printer.isPrinting() ? 1 : 0 );
|
||||
super.addListener( crafting );
|
||||
crafting.sendProgressBarUpdate( this, 0, m_printer.isPrinting() ? 1 : 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,9 +75,9 @@ public class ContainerPrinter extends Container
|
||||
if( !m_printer.getWorld().isRemote )
|
||||
{
|
||||
boolean printing = m_printer.isPrinting();
|
||||
for (int i=0; i<crafters.size(); ++i)
|
||||
for (int i=0; i<listeners.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting)crafters.get(i);
|
||||
IContainerListener icrafting = (IContainerListener)listeners.get(i);
|
||||
if( printing != m_lastPrinting )
|
||||
{
|
||||
icrafting.sendProgressBarUpdate( this, 0, printing ? 1 : 0 );
|
||||
@@ -122,7 +122,7 @@ public class ContainerPrinter extends Container
|
||||
else
|
||||
{
|
||||
// Transfer from inventory to printer
|
||||
if( itemstack1.getItem() == Items.dye )
|
||||
if( itemstack1.getItem() == Items.DYE )
|
||||
{
|
||||
if( !mergeItemStack(itemstack1, 0, 1, false) )
|
||||
{
|
||||
|
@@ -24,6 +24,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
@@ -101,9 +103,9 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
|
||||
// Write page
|
||||
synchronized( m_page )
|
||||
@@ -129,6 +131,8 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
}
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -254,15 +258,15 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
if( hasCustomName() )
|
||||
{
|
||||
return new ChatComponentText( getName() );
|
||||
return new TextComponentString( getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ChatComponentTranslation( getName() );
|
||||
return new TextComponentTranslation( getName() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,13 +428,13 @@ public class TilePrinter extends TilePeripheralBase
|
||||
|
||||
private boolean isInk( ItemStack stack )
|
||||
{
|
||||
return (stack.getItem() == Items.dye);
|
||||
return (stack.getItem() == Items.DYE);
|
||||
}
|
||||
|
||||
private boolean isPaper( ItemStack stack )
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
return ( item == Items.paper || (item instanceof ItemPrintout && ItemPrintout.getType( stack ) == ItemPrintout.Type.Single) );
|
||||
return ( item == Items.PAPER || (item instanceof ItemPrintout && ItemPrintout.getType( stack ) == ItemPrintout.Type.Single) );
|
||||
}
|
||||
|
||||
private boolean canInputPage()
|
||||
|
@@ -26,7 +26,11 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.text.translation.I18n;;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
@@ -156,7 +160,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player )
|
||||
public ActionResult<ItemStack> onItemRightClick( ItemStack stack, World world, EntityPlayer player, EnumHand hand )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
@@ -166,8 +170,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
computer.turnOn();
|
||||
}
|
||||
ComputerCraft.openPocketComputerGUI( player );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, stack );
|
||||
}
|
||||
return stack;
|
||||
return new ActionResult<ItemStack>( EnumActionResult.PASS, stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,14 +199,14 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
boolean modem = getHasModem( stack );
|
||||
if( modem )
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(
|
||||
return I18n.translateToLocalFormatted(
|
||||
baseString + ".upgraded.name",
|
||||
StatCollector.translateToLocal( "upgrade.computercraft:wireless_modem.adjective" )
|
||||
I18n.translateToLocal( "upgrade.computercraft:wireless_modem.adjective" )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return StatCollector.translateToLocal( baseString + ".name" );
|
||||
return I18n.translateToLocal( baseString + ".name" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +375,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAudioRecordName( ItemStack stack )
|
||||
public SoundEvent getAudio( ItemStack stack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package dan200.computercraft.shared.pocket.peripherals;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.modem.WirelessModemPeripheral;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
@@ -14,18 +14,18 @@ import net.minecraft.world.World;
|
||||
public class PocketModemPeripheral extends WirelessModemPeripheral
|
||||
{
|
||||
private World m_world;
|
||||
private Vec3 m_position;
|
||||
private Vec3d m_position;
|
||||
|
||||
public PocketModemPeripheral( boolean advanced )
|
||||
{
|
||||
super( advanced );
|
||||
m_world = null;
|
||||
m_position = new Vec3( 0.0, 0.0, 0.0 );
|
||||
m_position = new Vec3d( 0.0, 0.0, 0.0 );
|
||||
}
|
||||
|
||||
public void setLocation( World world, double x, double y, double z )
|
||||
{
|
||||
m_position = new Vec3( x, y, z );
|
||||
m_position = new Vec3d( x, y, z );
|
||||
if( m_world != world )
|
||||
{
|
||||
m_world = world;
|
||||
@@ -40,7 +40,7 @@ public class PocketModemPeripheral extends WirelessModemPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3 getPosition()
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
if( m_world != null )
|
||||
{
|
||||
|
@@ -342,37 +342,37 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
// Recipes
|
||||
// Turtle
|
||||
GameRegistry.addRecipe( new TurtleRecipe( new Item[] {
|
||||
Items.iron_ingot, Items.iron_ingot, Items.iron_ingot,
|
||||
Items.iron_ingot, Item.getItemFromBlock( ComputerCraft.Blocks.computer ), Items.iron_ingot,
|
||||
Items.iron_ingot, Item.getItemFromBlock( Blocks.chest ), Items.iron_ingot,
|
||||
Items.IRON_INGOT, Items.IRON_INGOT, Items.IRON_INGOT,
|
||||
Items.IRON_INGOT, Item.getItemFromBlock( ComputerCraft.Blocks.computer ), Items.IRON_INGOT,
|
||||
Items.IRON_INGOT, Item.getItemFromBlock( Blocks.CHEST ), Items.IRON_INGOT,
|
||||
}, ComputerFamily.Normal ) );
|
||||
GameRegistry.addRecipe( new TurtleUpgradeRecipe() );
|
||||
|
||||
// Impostor Turtle recipe (to fool NEI)
|
||||
ItemStack iron = new ItemStack( Items.iron_ingot, 1 );
|
||||
ItemStack iron = new ItemStack( Items.IRON_INGOT, 1 );
|
||||
GameRegistry.addRecipe( new ImpostorRecipe( 3, 3,
|
||||
new ItemStack[] {
|
||||
iron, iron, iron,
|
||||
iron, ComputerItemFactory.create( -1, null, ComputerFamily.Normal ), iron,
|
||||
iron, new ItemStack( Blocks.chest, 1 ), iron,
|
||||
iron, new ItemStack( Blocks.CHEST, 1 ), iron,
|
||||
},
|
||||
TurtleItemFactory.create( -1, null, null, ComputerFamily.Normal, null, null, 0, null )
|
||||
) );
|
||||
|
||||
// Advanced Turtle
|
||||
GameRegistry.addRecipe( new TurtleRecipe( new Item[] {
|
||||
Items.gold_ingot, Items.gold_ingot, Items.gold_ingot,
|
||||
Items.gold_ingot, Item.getItemFromBlock( ComputerCraft.Blocks.computer ), Items.gold_ingot,
|
||||
Items.gold_ingot, Item.getItemFromBlock( Blocks.chest ), Items.gold_ingot,
|
||||
Items.GOLD_INGOT, Items.GOLD_INGOT, Items.GOLD_INGOT,
|
||||
Items.GOLD_INGOT, Item.getItemFromBlock( ComputerCraft.Blocks.computer ), Items.GOLD_INGOT,
|
||||
Items.GOLD_INGOT, Item.getItemFromBlock( Blocks.CHEST ), Items.GOLD_INGOT,
|
||||
}, ComputerFamily.Advanced ) );
|
||||
|
||||
// Impostor Advanced Turtle recipe (to fool NEI)
|
||||
ItemStack gold = new ItemStack( Items.gold_ingot, 1 );
|
||||
ItemStack gold = new ItemStack( Items.GOLD_INGOT, 1 );
|
||||
GameRegistry.addRecipe( new ImpostorRecipe( 3, 3,
|
||||
new ItemStack[] {
|
||||
gold, gold, gold,
|
||||
gold, ComputerItemFactory.create( -1, null, ComputerFamily.Advanced ), gold,
|
||||
gold, new ItemStack( Blocks.chest, 1 ), gold,
|
||||
gold, new ItemStack( Blocks.CHEST, 1 ), gold,
|
||||
},
|
||||
TurtleItemFactory.create( -1, null, null, ComputerFamily.Advanced, null, null, 0, null )
|
||||
) );
|
||||
@@ -384,19 +384,19 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
ComputerCraft.Upgrades.craftingTable = new TurtleCraftingTable( 2 );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.craftingTable );
|
||||
|
||||
ComputerCraft.Upgrades.diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), 3, "upgrade.minecraft:diamond_sword.adjective", Items.diamond_sword );
|
||||
ComputerCraft.Upgrades.diamondSword = new TurtleSword( new ResourceLocation( "minecraft", "diamond_sword" ), 3, "upgrade.minecraft:diamond_sword.adjective", Items.DIAMOND_SWORD );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.diamondSword );
|
||||
|
||||
ComputerCraft.Upgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), 4, "upgrade.minecraft:diamond_shovel.adjective", Items.diamond_shovel );
|
||||
ComputerCraft.Upgrades.diamondShovel = new TurtleShovel( new ResourceLocation( "minecraft", "diamond_shovel" ), 4, "upgrade.minecraft:diamond_shovel.adjective", Items.DIAMOND_SHOVEL );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.diamondShovel );
|
||||
|
||||
ComputerCraft.Upgrades.diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), 5, "upgrade.minecraft:diamond_pickaxe.adjective", Items.diamond_pickaxe );
|
||||
ComputerCraft.Upgrades.diamondPickaxe = new TurtleTool( new ResourceLocation( "minecraft", "diamond_pickaxe" ), 5, "upgrade.minecraft:diamond_pickaxe.adjective", Items.DIAMOND_PICKAXE );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.diamondPickaxe );
|
||||
|
||||
ComputerCraft.Upgrades.diamondAxe = new TurtleAxe( new ResourceLocation( "minecraft", "diamond_axe" ), 6, "upgrade.minecraft:diamond_axe.adjective", Items.diamond_axe );
|
||||
ComputerCraft.Upgrades.diamondAxe = new TurtleAxe( new ResourceLocation( "minecraft", "diamond_axe" ), 6, "upgrade.minecraft:diamond_axe.adjective", Items.DIAMOND_AXE );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.diamondAxe );
|
||||
|
||||
ComputerCraft.Upgrades.diamondHoe = new TurtleHoe( new ResourceLocation( "minecraft", "diamond_hoe" ), 7, "upgrade.minecraft:diamond_hoe.adjective", Items.diamond_hoe );
|
||||
ComputerCraft.Upgrades.diamondHoe = new TurtleHoe( new ResourceLocation( "minecraft", "diamond_hoe" ), 7, "upgrade.minecraft:diamond_hoe.adjective", Items.DIAMOND_HOE );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.diamondHoe );
|
||||
|
||||
ComputerCraft.Upgrades.advancedModem = new TurtleModem( true, new ResourceLocation( "computercraft", "advanced_modem" ), -1 );
|
||||
@@ -427,7 +427,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
@SubscribeEvent
|
||||
public void onEntityLivingDrops( LivingDropsEvent event )
|
||||
{
|
||||
dispatchEntityDrops( event.entity, event.drops );
|
||||
dispatchEntityDrops( event.getEntity(), event.getDrops() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -127,18 +128,13 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
if( item instanceof ItemRecord )
|
||||
{
|
||||
ItemRecord record = (ItemRecord)item;
|
||||
if( (( ResourceLocation)Item.itemRegistry.getNameForObject( record )).getResourceDomain().equals( "minecraft" ) )
|
||||
{
|
||||
return "C418 - " + record.recordName;
|
||||
}
|
||||
// TODO: determine descriptions for mod items (ie: Portal gun mod)
|
||||
return record.recordName;
|
||||
return record.getRecordNameLocal();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void playRecord( String record, String recordInfo, World world, BlockPos pos );
|
||||
public abstract void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos );
|
||||
|
||||
@Override
|
||||
public abstract Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive );
|
||||
@@ -163,7 +159,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
@Override
|
||||
public void handlePacket( final ComputerCraftPacket packet, final EntityPlayer player )
|
||||
{
|
||||
IThreadListener listener = MinecraftServer.getServer();
|
||||
IThreadListener listener = player.getServer();
|
||||
if( listener != null )
|
||||
{
|
||||
if( listener.isCallingFromMinecraftThread() )
|
||||
@@ -217,10 +213,10 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
if( tileEntity != null && tileEntity instanceof TileGeneric )
|
||||
{
|
||||
TileGeneric generic = (TileGeneric)tileEntity;
|
||||
Packet description = generic.getDescriptionPacket();
|
||||
Packet description = generic.getUpdatePacket();
|
||||
if( description != null )
|
||||
{
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacket( description );
|
||||
((EntityPlayerMP)player).connection.sendPacket( description );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -286,107 +282,107 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
ItemStack computer = ComputerItemFactory.create( -1, null, ComputerFamily.Normal );
|
||||
GameRegistry.addRecipe( computer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Items.redstone,
|
||||
'Z', Blocks.glass_pane
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Advanced Computer
|
||||
ItemStack advancedComputer = ComputerItemFactory.create( -1, null, ComputerFamily.Advanced );
|
||||
GameRegistry.addRecipe( advancedComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Items.gold_ingot,
|
||||
'Y', Items.redstone,
|
||||
'Z', Blocks.glass_pane
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.REDSTONE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Disk Drive
|
||||
ItemStack diskDrive = PeripheralItemFactory.create( PeripheralType.DiskDrive, null, 1 );
|
||||
GameRegistry.addRecipe( diskDrive,
|
||||
"XXX", "XYX", "XYX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Items.redstone
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE
|
||||
);
|
||||
|
||||
// Wireless Modem
|
||||
ItemStack wirelessModem = PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 );
|
||||
GameRegistry.addRecipe( wirelessModem,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Items.ender_pearl
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.ENDER_PEARL
|
||||
);
|
||||
|
||||
// Monitor
|
||||
ItemStack monitor = PeripheralItemFactory.create( PeripheralType.Monitor, null, 1 );
|
||||
GameRegistry.addRecipe( monitor,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Blocks.glass_pane
|
||||
'X', Blocks.STONE,
|
||||
'Y', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// PrinterEmpty
|
||||
ItemStack printer = PeripheralItemFactory.create( PeripheralType.Printer, null, 1 );
|
||||
GameRegistry.addRecipe( printer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Items.redstone,
|
||||
'Z', new ItemStack( Items.dye, 1, 0 ) // 0 = Black
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE,
|
||||
'Z', new ItemStack( Items.DYE, 1, 0 ) // 0 = Black
|
||||
);
|
||||
|
||||
// Advanced Monitor
|
||||
ItemStack advancedMonitors = PeripheralItemFactory.create( PeripheralType.AdvancedMonitor, null, 4 );
|
||||
GameRegistry.addRecipe( advancedMonitors,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Items.gold_ingot,
|
||||
'Y', Blocks.glass_pane
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Networking Cable
|
||||
ItemStack cable = PeripheralItemFactory.create( PeripheralType.Cable, null, 6 );
|
||||
GameRegistry.addRecipe( cable,
|
||||
" X ", "XYX", " X ",
|
||||
'X', Blocks.stone,
|
||||
'Y', Items.redstone
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE
|
||||
);
|
||||
|
||||
// Wired Modem
|
||||
ItemStack wiredModem = PeripheralItemFactory.create( PeripheralType.WiredModem, null, 1 );
|
||||
GameRegistry.addRecipe( wiredModem,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Items.redstone
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE
|
||||
);
|
||||
|
||||
// Computer
|
||||
ItemStack commandComputer = ComputerItemFactory.create( -1, null, ComputerFamily.Command );
|
||||
GameRegistry.addRecipe( commandComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Blocks.command_block,
|
||||
'Z', Blocks.glass_pane
|
||||
'X', Blocks.STONE,
|
||||
'Y', Blocks.COMMAND_BLOCK,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Advanced Modem
|
||||
ItemStack advancedModem = PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 );
|
||||
GameRegistry.addRecipe( advancedModem,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Items.gold_ingot,
|
||||
'Y', Items.ender_eye
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.ENDER_EYE
|
||||
);
|
||||
|
||||
// Disk
|
||||
GameRegistry.addRecipe( new DiskRecipe() );
|
||||
|
||||
// Impostor Disk recipes (to fool NEI)
|
||||
ItemStack paper = new ItemStack( Items.paper, 1 );
|
||||
ItemStack redstone = new ItemStack( Items.redstone, 1 );
|
||||
ItemStack paper = new ItemStack( Items.PAPER, 1 );
|
||||
ItemStack redstone = new ItemStack( Items.REDSTONE, 1 );
|
||||
ItemStack basicDisk = ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.Blue.getHex() );
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( basicDisk, new Object[] { redstone, paper } ) );
|
||||
|
||||
for( int colour=0; colour<16; ++colour )
|
||||
{
|
||||
ItemStack disk = ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.values()[ colour ].getHex() );
|
||||
ItemStack dye = new ItemStack( Items.dye, 1, colour );
|
||||
ItemStack dye = new ItemStack( Items.DYE, 1, colour );
|
||||
for( int otherColour=0; otherColour<16; ++otherColour )
|
||||
{
|
||||
if( colour != otherColour )
|
||||
@@ -410,28 +406,28 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
ItemStack bookPrintout = ItemPrintout.createBookFromTitleAndText( null, null, null );
|
||||
|
||||
// Impostor Printout recipes (to fool NEI)
|
||||
ItemStack string = new ItemStack( Items.string, 1, 0 );
|
||||
ItemStack string = new ItemStack( Items.STRING, 1, 0 );
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( multiplePrintout, new Object[] { singlePrintout, singlePrintout, string } ) );
|
||||
|
||||
ItemStack leather = new ItemStack( Items.leather, 1, 0 );
|
||||
ItemStack leather = new ItemStack( Items.LEATHER, 1, 0 );
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( bookPrintout, new Object[] { leather, singlePrintout, string } ) );
|
||||
|
||||
// Pocket Computer
|
||||
ItemStack pocketComputer = PocketComputerItemFactory.create( -1, null, ComputerFamily.Normal, false );
|
||||
GameRegistry.addRecipe( pocketComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.stone,
|
||||
'Y', Items.golden_apple,
|
||||
'Z', Blocks.glass_pane
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.GOLDEN_APPLE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Advanced Pocket Computer
|
||||
ItemStack advancedPocketComputer = PocketComputerItemFactory.create( -1, null, ComputerFamily.Advanced, false );
|
||||
GameRegistry.addRecipe( advancedPocketComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Items.gold_ingot,
|
||||
'Y', Items.golden_apple,
|
||||
'Z', Blocks.glass_pane
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.GOLDEN_APPLE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Wireless Pocket Computer
|
||||
@@ -449,16 +445,16 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
// Dan
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString( "SkullOwner", "dan200" );
|
||||
ItemStack danHead = new ItemStack( Items.skull, 1, 3 );
|
||||
ItemStack danHead = new ItemStack( Items.SKULL, 1, 3 );
|
||||
danHead.setTagCompound( tag );
|
||||
GameRegistry.addShapelessRecipe( danHead, computer, new ItemStack( Items.skull, 1, 1 ) );
|
||||
GameRegistry.addShapelessRecipe( danHead, computer, new ItemStack( Items.SKULL, 1, 1 ) );
|
||||
|
||||
// Cloudy
|
||||
tag = new NBTTagCompound();
|
||||
tag.setString( "SkullOwner", "Cloudhunter" );
|
||||
ItemStack cloudyHead = new ItemStack( Items.skull, 1, 3 );
|
||||
ItemStack cloudyHead = new ItemStack( Items.SKULL, 1, 3 );
|
||||
cloudyHead.setTagCompound( tag );
|
||||
GameRegistry.addShapelessRecipe( cloudyHead, monitor, new ItemStack( Items.skull, 1, 1 ) );
|
||||
GameRegistry.addShapelessRecipe( cloudyHead, monitor, new ItemStack( Items.SKULL, 1, 1 ) );
|
||||
}
|
||||
|
||||
private void registerTileEntities()
|
||||
|
@@ -14,7 +14,8 @@ import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.io.File;
|
||||
@@ -31,7 +32,7 @@ public interface IComputerCraftProxy
|
||||
public Object getFixedWidthFontRenderer();
|
||||
|
||||
public String getRecordInfo( ItemStack item );
|
||||
public void playRecord( String record, String recordInfo, World world, BlockPos pos );
|
||||
public void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos );
|
||||
|
||||
public Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive );
|
||||
public Object getComputerGUI( TileComputer computer );
|
||||
|
@@ -478,7 +478,7 @@ public class TurtleAPI implements ILuaAPI
|
||||
if( stack != null && stack.stackSize > 0 )
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
String name = ((ResourceLocation)Item.itemRegistry.getNameForObject( item )).toString();
|
||||
String name = ((ResourceLocation)Item.REGISTRY.getNameForObject( item )).toString();
|
||||
int damage = stack.getItemDamage();
|
||||
int count = stack.stackSize;
|
||||
|
||||
|
@@ -16,12 +16,13 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -33,7 +34,7 @@ public class BlockTurtle extends BlockComputerBase
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create( "facing", EnumFacing.Plane.HORIZONTAL );
|
||||
public static final PropertyEnum DYE = PropertyEnum.create( "dye", BlockTurtleDyeVariant.class );
|
||||
public static final PropertyEnum<BlockTurtleDyeVariant> DYE = PropertyEnum.<BlockTurtleDyeVariant>create( "dye", BlockTurtleDyeVariant.class );
|
||||
}
|
||||
|
||||
public static BlockTurtle createTurtleBlock()
|
||||
@@ -45,7 +46,7 @@ public class BlockTurtle extends BlockComputerBase
|
||||
|
||||
public BlockTurtle()
|
||||
{
|
||||
super( Material.iron );
|
||||
super( Material.IRON );
|
||||
setHardness( 2.5f );
|
||||
setUnlocalizedName( "computercraft:turtle" );
|
||||
setCreativeTab( ComputerCraft.mainCreativeTab );
|
||||
@@ -56,27 +57,27 @@ public class BlockTurtle extends BlockComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
public EnumBlockRenderType getRenderType( IBlockState state )
|
||||
{
|
||||
return -1;
|
||||
return EnumBlockRenderType.INVISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
public boolean isOpaqueCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube()
|
||||
public boolean isFullCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] {
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.DYE
|
||||
});
|
||||
|
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.common.IDirectionalTile;
|
||||
import dan200.computercraft.shared.computer.blocks.IComputerTile;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public interface ITurtleTile extends IComputerTile, IDirectionalTile
|
||||
{
|
||||
@@ -22,7 +22,7 @@ public interface ITurtleTile extends IComputerTile, IDirectionalTile
|
||||
public ITurtleUpgrade getUpgrade( TurtleSide side );
|
||||
public ITurtleAccess getAccess();
|
||||
|
||||
public Vec3 getRenderOffset( float f );
|
||||
public Vec3d getRenderOffset( float f );
|
||||
public float getRenderYaw( float f );
|
||||
public float getToolRenderAngle( TurtleSide side, float f );
|
||||
}
|
||||
|
@@ -30,6 +30,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.List;
|
||||
@@ -135,7 +137,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, int fortune, boolean creative, boolean silkTouch )
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
IComputer computer = getComputer();
|
||||
if( !creative || (computer != null && computer.getLabel() != null) )
|
||||
@@ -157,10 +159,10 @@ public class TileTurtle extends TileComputerBase
|
||||
requestTileEntityUpdate();
|
||||
|
||||
// Apply dye
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
ItemStack currentItem = player.getHeldItem( EnumHand.MAIN_HAND );
|
||||
if( currentItem != null )
|
||||
{
|
||||
if( currentItem.getItem() == Items.dye )
|
||||
if( currentItem.getItem() == Items.DYE )
|
||||
{
|
||||
// Dye to change turtle colour
|
||||
if( !worldObj.isRemote )
|
||||
@@ -177,7 +179,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if( currentItem.getItem() == Items.water_bucket && m_brain.getDyeColour() != -1 )
|
||||
else if( currentItem.getItem() == Items.WATER_BUCKET && m_brain.getDyeColour() != -1 )
|
||||
{
|
||||
// Water to remove turtle colour
|
||||
if( !worldObj.isRemote )
|
||||
@@ -187,7 +189,7 @@ public class TileTurtle extends TileComputerBase
|
||||
m_brain.setDyeColour( -1 );
|
||||
if( !player.capabilities.isCreativeMode )
|
||||
{
|
||||
currentItem.setItem( Items.bucket );
|
||||
currentItem.setItem( Items.BUCKET );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +239,7 @@ public class TileTurtle extends TileComputerBase
|
||||
@Override
|
||||
public AxisAlignedBB getBounds()
|
||||
{
|
||||
Vec3 offset = getRenderOffset( 1.0f );
|
||||
Vec3d offset = getRenderOffset( 1.0f );
|
||||
return new AxisAlignedBB(
|
||||
offset.xCoord + 0.125, offset.yCoord + 0.125, offset.zCoord + 0.125,
|
||||
offset.xCoord + 0.875, offset.yCoord + 0.875, offset.zCoord + 0.875
|
||||
@@ -299,9 +301,9 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
|
||||
// Write inventory
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
@@ -318,7 +320,9 @@ public class TileTurtle extends TileComputerBase
|
||||
nbttagcompound.setTag( "Items", nbttaglist );
|
||||
|
||||
// Write brain
|
||||
m_brain.writeToNBT( nbttagcompound );
|
||||
nbttagcompound = m_brain.writeToNBT( nbttagcompound );
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -379,7 +383,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderOffset( float f )
|
||||
public Vec3d getRenderOffset( float f )
|
||||
{
|
||||
return m_brain.getRenderOffset( f );
|
||||
}
|
||||
@@ -524,15 +528,15 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
if( hasCustomName() )
|
||||
{
|
||||
return new ChatComponentText( getName() );
|
||||
return new TextComponentString( getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ChatComponentTranslation( getName() );
|
||||
return new TextComponentTranslation( getName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
@@ -297,7 +299,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
// Write state
|
||||
nbttagcompound.setInteger( "dir", m_direction.getIndex() );
|
||||
@@ -338,6 +340,8 @@ public class TurtleBrain implements ITurtleAccess
|
||||
{
|
||||
nbttagcompound.setTag( "rightUpgradeNBT", (NBTTagCompound) getUpgradeNBTData( TurtleSide.Right ).copy() );
|
||||
}
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
private String getUpgradeID( ITurtleUpgrade upgrade )
|
||||
@@ -535,11 +539,11 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getVisualPosition( float f )
|
||||
public Vec3d getVisualPosition( float f )
|
||||
{
|
||||
Vec3 offset = getRenderOffset( f );
|
||||
Vec3d offset = getRenderOffset( f );
|
||||
BlockPos pos = m_owner.getPos();
|
||||
return new Vec3(
|
||||
return new Vec3d(
|
||||
pos.getX() + 0.5 + offset.xCoord,
|
||||
pos.getY() + 0.5 + offset.yCoord,
|
||||
pos.getZ() + 0.5 + offset.zCoord
|
||||
@@ -856,7 +860,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
public Vec3 getRenderOffset( float f )
|
||||
public Vec3d getRenderOffset( float f )
|
||||
{
|
||||
switch( m_animation )
|
||||
{
|
||||
@@ -893,7 +897,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
double distance = -1.0 + (double)getAnimationFraction( f );
|
||||
return new Vec3(
|
||||
return new Vec3d(
|
||||
distance * (double)dir.getFrontOffsetX(),
|
||||
distance * (double)dir.getFrontOffsetY(),
|
||||
distance * (double)dir.getFrontOffsetZ()
|
||||
@@ -901,7 +905,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
default:
|
||||
{
|
||||
return new Vec3( 0.0, 0.0, 0.0 );
|
||||
return new Vec3d( 0.0, 0.0, 0.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1140,7 +1144,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
Holiday currentHoliday = HolidayUtil.getCurrentHoliday();
|
||||
if( currentHoliday == Holiday.Valentines )
|
||||
{
|
||||
Vec3 position = getVisualPosition( 1.0f );
|
||||
Vec3d position = getVisualPosition( 1.0f );
|
||||
if( position != null )
|
||||
{
|
||||
double x = position.xCoord + world.rand.nextGaussian() * 0.1;
|
||||
|
@@ -14,7 +14,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
@@ -50,11 +50,11 @@ public class TurtleCompareCommand implements ITurtleCommand
|
||||
{
|
||||
if( !world.isAirBlock( newPosition ) )
|
||||
{
|
||||
Block lookAtBlock = world.getBlockState( newPosition ).getBlock();
|
||||
if( lookAtBlock != null && !lookAtBlock.isAir( world, newPosition ) )
|
||||
IBlockState lookAtState = world.getBlockState( newPosition );
|
||||
Block lookAtBlock = lookAtState.getBlock();
|
||||
if( !lookAtBlock.isAir( lookAtState, world, newPosition ) )
|
||||
{
|
||||
// Try createStackedBlock first
|
||||
IBlockState lookAtState = world.getBlockState( newPosition );
|
||||
if( !lookAtBlock.hasTileEntity( lookAtState ) )
|
||||
{
|
||||
try
|
||||
|
@@ -14,7 +14,7 @@ import dan200.computercraft.shared.turtle.upgrades.TurtleInventoryCrafting;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -12,9 +12,12 @@ import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -81,7 +84,7 @@ public class TurtleDropCommand implements ITurtleCommand
|
||||
{
|
||||
// Drop the item into the world
|
||||
WorldUtil.dropItemStack( stack, world, oldPosition, direction );
|
||||
world.playSoundEffect( newPosition.getX() + 0.5, newPosition.getY() + 0.5, newPosition.getZ() + 0.5, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 2.0f );
|
||||
world.playBroadcastSound( 1000, newPosition, 0 );
|
||||
turtle.playAnimation( TurtleAnimation.Wait );
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class TurtleEquipCommand implements ITurtleCommand
|
||||
{
|
||||
|
@@ -14,7 +14,7 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -49,7 +49,7 @@ public class TurtleInspectCommand implements ITurtleCommand
|
||||
{
|
||||
IBlockState state = world.getBlockState( newPosition );
|
||||
Block block = state.getBlock();
|
||||
String name = ((ResourceLocation)Block.blockRegistry.getNameForObject( block )).toString();
|
||||
String name = ((ResourceLocation)Block.REGISTRY.getNameForObject( block )).toString();
|
||||
int metadata = block.getMetaFromState( state );
|
||||
|
||||
Map<Object, Object> table = new HashMap<Object, Object>();
|
||||
|
@@ -14,8 +14,8 @@ import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class TurtleMoveCommand implements ITurtleCommand
|
||||
(double) direction.getFrontOffsetY(),
|
||||
(double) direction.getFrontOffsetZ()
|
||||
);
|
||||
if( !oldWorld.func_147461_a( pushedBB ).isEmpty() ) // getCollidingBlockBoundingBoxes
|
||||
if( !oldWorld.getCollisionBoxes( pushedBB ).isEmpty() )
|
||||
{
|
||||
return TurtleCommandResult.failure( "Movement obstructed" );
|
||||
}
|
||||
|
@@ -22,10 +22,13 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -200,10 +203,10 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
// See if there is an entity present
|
||||
final World world = turtle.getWorld();
|
||||
final BlockPos position = turtle.getPosition();
|
||||
Vec3 turtlePos = new Vec3( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3 rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3 rayStart = turtlePos;
|
||||
Pair<Entity, Vec3> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
Vec3d turtlePos = new Vec3d( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3d rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3d rayStart = turtlePos;
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
if( hit == null )
|
||||
{
|
||||
return stack;
|
||||
@@ -216,7 +219,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Start claiming entity drops
|
||||
Entity hitEntity = hit.getKey();
|
||||
Vec3 hitPos = hit.getValue();
|
||||
Vec3d hitPos = hit.getValue();
|
||||
ComputerCraft.setEntityDropConsumer( hitEntity, new IEntityDropConsumer()
|
||||
{
|
||||
@Override
|
||||
@@ -232,21 +235,18 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Place on the entity
|
||||
boolean placed = false;
|
||||
if( hitEntity.interactFirst( turtlePlayer ) )
|
||||
if( hitEntity.applyPlayerInteraction( turtlePlayer, hitPos, stackCopy, EnumHand.MAIN_HAND ) == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( hitEntity instanceof EntityLivingBase )
|
||||
{
|
||||
placed = item.itemInteractionForEntity( stackCopy, turtlePlayer, (EntityLivingBase)hitEntity );
|
||||
placed = item.itemInteractionForEntity( stackCopy, turtlePlayer, (EntityLivingBase)hitEntity, EnumHand.MAIN_HAND );
|
||||
if( placed )
|
||||
{
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( hitEntity.interactAt( turtlePlayer, hitPos ) ) // interact
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Stop claiming drops
|
||||
@@ -346,19 +346,23 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Do the deploying (put everything in the players inventory)
|
||||
boolean placed = false;
|
||||
if( item.onItemUseFirst( stackCopy, turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ ) ||
|
||||
item.onItemUse( stackCopy, turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ ) )
|
||||
if( item.onItemUseFirst( stackCopy, turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ, EnumHand.MAIN_HAND ) == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( item.onItemUse( stackCopy, turtlePlayer, turtle.getWorld(), position, EnumHand.MAIN_HAND, side, hitX, hitY, hitZ ) == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( item instanceof ItemBucket || item instanceof ItemBoat || item instanceof ItemLilyPad || item instanceof ItemGlassBottle )
|
||||
{
|
||||
ItemStack result = item.onItemRightClick( stackCopy, turtle.getWorld(), turtlePlayer );
|
||||
if( !ItemStack.areItemStacksEqual( stack, result ) )
|
||||
ActionResult<ItemStack> result = item.onItemRightClick( stackCopy, turtle.getWorld(), turtlePlayer, EnumHand.MAIN_HAND );
|
||||
if( result.getType() == EnumActionResult.SUCCESS && !ItemStack.areItemStacksEqual( stack, result.getResult() ) )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( result );
|
||||
turtlePlayer.loadInventory( result.getResult() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,20 +390,20 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
{
|
||||
if( split[ i - firstLine ].length() > 15 )
|
||||
{
|
||||
signTile.signText[ i ] = new ChatComponentText( split[ i - firstLine ].substring( 0, 15 ) );
|
||||
signTile.signText[ i ] = new TextComponentString( split[ i - firstLine ].substring( 0, 15 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.signText[ i ] = new ChatComponentText( split[ i - firstLine ] );
|
||||
signTile.signText[ i ] = new TextComponentString( split[ i - firstLine ] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.signText[i] = new ChatComponentText( "" );
|
||||
signTile.signText[i] = new TextComponentString( "" );
|
||||
}
|
||||
}
|
||||
signTile.markDirty();
|
||||
world.markBlockForUpdate( signTile.getPos() );
|
||||
world.markBlockRangeForRenderUpdate( signTile.getPos(), signTile.getPos() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
@@ -78,7 +78,7 @@ public class TurtlePlayer extends FakePlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mountEntity( Entity entity )
|
||||
public void mountEntityAndWakeUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -16,8 +16,8 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -145,7 +145,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
if( storedItems )
|
||||
{
|
||||
// Play fx
|
||||
world.playSoundEffect( oldPosition.getX() + 0.5, oldPosition.getY() + 0.5, oldPosition.getZ() + 0.5, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 2.0f );
|
||||
world.playBroadcastSound( 1000, oldPosition, 0 );
|
||||
turtle.playAnimation( TurtleAnimation.Wait );
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
|
@@ -9,20 +9,25 @@ package dan200.computercraft.shared.turtle.entity;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TurtleVisionCamera extends EntityLivingBase
|
||||
{
|
||||
private ITurtleAccess m_turtle;
|
||||
private ItemStack[] m_inventory;
|
||||
private ArrayList<ItemStack> m_armor;
|
||||
|
||||
public TurtleVisionCamera( World world, ITurtleAccess turtle )
|
||||
{
|
||||
super( world );
|
||||
m_turtle = turtle;
|
||||
m_inventory = new ItemStack[0];
|
||||
m_armor = new ArrayList<ItemStack>();
|
||||
applyPos();
|
||||
}
|
||||
|
||||
@@ -37,6 +42,12 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHandSide getPrimaryHand()
|
||||
{
|
||||
return EnumHandSide.RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
@@ -46,7 +57,7 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
|
||||
private void applyPos()
|
||||
{
|
||||
Vec3 prevPos = m_turtle.getVisualPosition( 0.0f );
|
||||
Vec3d prevPos = m_turtle.getVisualPosition( 0.0f );
|
||||
this.lastTickPosX = this.prevPosX = prevPos.xCoord;
|
||||
this.lastTickPosY = this.prevPosY = prevPos.yCoord;
|
||||
this.lastTickPosZ = this.prevPosZ = prevPos.zCoord;
|
||||
@@ -54,7 +65,7 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
this.prevRotationYaw = m_turtle.getVisualYaw( 0.0f );
|
||||
this.prevCameraPitch = 0.0f;
|
||||
|
||||
Vec3 pos = m_turtle.getVisualPosition( 1.0f );
|
||||
Vec3d pos = m_turtle.getVisualPosition( 1.0f );
|
||||
this.posX = pos.xCoord;
|
||||
this.posY = pos.yCoord;
|
||||
this.posZ = pos.zCoord;
|
||||
@@ -76,31 +87,25 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
// EntityLivingBase overrides:
|
||||
|
||||
@Override
|
||||
public ItemStack getHeldItem()
|
||||
public ItemStack getHeldItem( EnumHand hand )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getEquipmentInSlot( int slot )
|
||||
public void setItemStackToSlot(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCurrentArmor( int slotIn )
|
||||
public Iterable<ItemStack> getArmorInventoryList()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentItemOrArmor( int slot, ItemStack stack )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInventory()
|
||||
{
|
||||
return m_inventory;
|
||||
return m_armor;
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -76,16 +76,16 @@ public class ContainerTurtle extends Container
|
||||
return m_selectedSlot;
|
||||
}
|
||||
|
||||
private void sendStateToPlayer( ICrafting icrafting )
|
||||
private void sendStateToPlayer( IContainerListener icrafting )
|
||||
{
|
||||
int selectedSlot = m_turtle.getSelectedSlot();
|
||||
icrafting.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftGuiOpened( ICrafting crafting )
|
||||
public void addListener( IContainerListener crafting )
|
||||
{
|
||||
super.onCraftGuiOpened( crafting );
|
||||
super.addListener( crafting );
|
||||
sendStateToPlayer( crafting );
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ public class ContainerTurtle extends Container
|
||||
super.detectAndSendChanges();
|
||||
|
||||
int selectedSlot = m_turtle.getSelectedSlot();
|
||||
for( int i=0; i<crafters.size(); ++i )
|
||||
for( int i=0; i<listeners.size(); ++i )
|
||||
{
|
||||
ICrafting icrafting = (ICrafting)crafters.get(i);
|
||||
IContainerListener icrafting = (IContainerListener)listeners.get(i);
|
||||
if( m_selectedSlot != selectedSlot )
|
||||
{
|
||||
icrafting.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
|
@@ -21,10 +21,10 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.text.translation.I18n;;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -142,29 +142,29 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle
|
||||
ITurtleUpgrade right = getUpgrade( stack, TurtleSide.Right );
|
||||
if( left != null && right != null )
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(
|
||||
return I18n.translateToLocalFormatted(
|
||||
baseString + ".upgraded_twice.name",
|
||||
StatCollector.translateToLocal( right.getUnlocalisedAdjective() ),
|
||||
StatCollector.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
I18n.translateToLocal( right.getUnlocalisedAdjective() ),
|
||||
I18n.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else if( left != null )
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(
|
||||
return I18n.translateToLocalFormatted(
|
||||
baseString + ".upgraded.name",
|
||||
StatCollector.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
I18n.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else if( right != null )
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(
|
||||
return I18n.translateToLocalFormatted(
|
||||
baseString + ".upgraded.name",
|
||||
StatCollector.translateToLocal( right.getUnlocalisedAdjective() )
|
||||
I18n.translateToLocal( right.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return StatCollector.translateToLocal( baseString + ".name" );
|
||||
return I18n.translateToLocal( baseString + ".name" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,9 +9,9 @@ package dan200.computercraft.shared.turtle.upgrades;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.turtle.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -38,7 +38,7 @@ public class TurtleCraftingTable implements ITurtleUpgrade
|
||||
{
|
||||
m_id = new ResourceLocation( "minecraft", "crafting_table" );
|
||||
m_legacyID = legacyId;
|
||||
m_item = new ItemStack( Blocks.crafting_table, 1, 0 );
|
||||
m_item = new ItemStack( Blocks.CRAFTING_TABLE, 1, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -13,9 +13,10 @@ import dan200.computercraft.api.turtle.TurtleVerb;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -32,13 +33,15 @@ public class TurtleHoe extends TurtleTool
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
block.getMaterial() == Material.plants ||
|
||||
block.getMaterial() == Material.cactus ||
|
||||
block.getMaterial() == Material.gourd ||
|
||||
block.getMaterial() == Material.leaves ||
|
||||
block.getMaterial() == Material.vine;
|
||||
material == Material.PLANTS ||
|
||||
material == Material.CACTUS ||
|
||||
material == Material.GOURD ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -13,8 +13,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
@@ -120,7 +120,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
results.add( result );
|
||||
|
||||
// Consume resources from the inventory
|
||||
ItemStack[] remainingItems = CraftingManager.getInstance().func_180303_b( this, world ); // getRemainingItems
|
||||
ItemStack[] remainingItems = CraftingManager.getInstance().getRemainingItems( this, world );
|
||||
for( int n=0; n<size; ++n )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
@@ -214,9 +214,9 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return new ChatComponentText( "" );
|
||||
return new TextComponentString( "" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -12,15 +12,15 @@ import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.common.PeripheralItemFactory;
|
||||
import dan200.computercraft.shared.peripheral.modem.WirelessModemPeripheral;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -48,10 +48,10 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3 getPosition()
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
BlockPos turtlePos = m_turtle.getPosition();
|
||||
return new Vec3(
|
||||
return new Vec3d(
|
||||
(double)turtlePos.getX(),
|
||||
(double)turtlePos.getY(),
|
||||
(double)turtlePos.getZ()
|
||||
|
@@ -7,8 +7,9 @@
|
||||
package dan200.computercraft.shared.turtle.upgrades;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -24,19 +25,21 @@ public class TurtleShovel extends TurtleTool
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
return
|
||||
block.getMaterial() == Material.ground ||
|
||||
block.getMaterial() == Material.sand ||
|
||||
block.getMaterial() == Material.snow ||
|
||||
block.getMaterial() == Material.clay ||
|
||||
block.getMaterial() == Material.craftedSnow ||
|
||||
block.getMaterial() == Material.grass ||
|
||||
block.getMaterial() == Material.plants ||
|
||||
block.getMaterial() == Material.cactus ||
|
||||
block.getMaterial() == Material.gourd ||
|
||||
block.getMaterial() == Material.leaves ||
|
||||
block.getMaterial() == Material.vine;
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
material == Material.GROUND ||
|
||||
material == Material.SAND ||
|
||||
material == Material.SNOW ||
|
||||
material == Material.CLAY ||
|
||||
material == Material.CRAFTED_SNOW ||
|
||||
material == Material.GRASS ||
|
||||
material == Material.PLANTS ||
|
||||
material == Material.CACTUS ||
|
||||
material == Material.GOURD ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -7,8 +7,9 @@
|
||||
package dan200.computercraft.shared.turtle.upgrades;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -24,13 +25,15 @@ public class TurtleSword extends TurtleTool
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
return
|
||||
block.getMaterial() == Material.plants ||
|
||||
block.getMaterial() == Material.leaves ||
|
||||
block.getMaterial() == Material.vine ||
|
||||
block.getMaterial() == Material.cloth ||
|
||||
block.getMaterial() == Material.web;
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
material == Material.PLANTS ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE ||
|
||||
material == Material.CLOTH ||
|
||||
material == Material.WEB;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -18,7 +18,8 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.item.EntityArmorStand;
|
||||
@@ -26,6 +27,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
@@ -132,8 +134,9 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
if( block.isAir( world, pos ) || block == Blocks.bedrock || block.getBlockHardness( world, pos ) <= -1.0F )
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
if( block.isAir( state, world, pos ) || block == Blocks.BEDROCK || block.getBlockHardness( state, world, pos ) <= -1.0F )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -161,10 +164,10 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
final TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, position, direction );
|
||||
|
||||
// See if there is an entity present
|
||||
Vec3 turtlePos = new Vec3( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3 rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3 rayStart = turtlePos;
|
||||
Pair<Entity, Vec3> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
Vec3d turtlePos = new Vec3d( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3d rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3d rayStart = turtlePos;
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
if( hit != null )
|
||||
{
|
||||
// Load up the turtle's inventory
|
||||
@@ -188,9 +191,9 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
|
||||
// Place on the entity
|
||||
boolean placed = false;
|
||||
if( hitEntity.canAttackWithItem() && !hitEntity.hitByEntity( turtlePlayer ) )
|
||||
if( hitEntity.canBeAttackedWithItem() && !hitEntity.hitByEntity( turtlePlayer ) )
|
||||
{
|
||||
float damage = (float)turtlePlayer.getEntityAttribute( SharedMonsterAttributes.attackDamage ).getAttributeValue();
|
||||
float damage = (float)turtlePlayer.getEntityAttribute( SharedMonsterAttributes.ATTACK_DAMAGE ).getAttributeValue();
|
||||
damage *= getDamageMultiplier();
|
||||
if( damage > 0.0f )
|
||||
{
|
||||
@@ -277,16 +280,13 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
// Destroy the block
|
||||
Block previousBlock = world.getBlockState( newPosition ).getBlock();
|
||||
IBlockState previousState = world.getBlockState( newPosition );
|
||||
if( previousBlock != null )
|
||||
{
|
||||
world.playSoundEffect( newPosition.getX() + 0.5, newPosition.getY() + 0.5, newPosition.getZ() + 0.5, previousBlock.stepSound.getBreakSound(), (previousBlock.stepSound.getVolume() + 1.0F) / 2.0F, previousBlock.stepSound.getFrequency() * 0.8F);
|
||||
}
|
||||
Block previousBlock = previousState.getBlock();
|
||||
world.playSound( null, newPosition, previousBlock.getSoundType().getBreakSound(), SoundCategory.BLOCKS, (previousBlock.getSoundType().getVolume() + 1.0F) / 2.0F, previousBlock.getSoundType().getPitch() * 0.8F );
|
||||
world.setBlockToAir( newPosition );
|
||||
|
||||
// Remember the previous block
|
||||
if( turtle instanceof TurtleBrain && previousBlock != null )
|
||||
if( turtle instanceof TurtleBrain )
|
||||
{
|
||||
TurtleBrain brain = (TurtleBrain)turtle;
|
||||
brain.saveBlockChange( newPosition, previousState );
|
||||
|
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.util;
|
||||
import dan200.computercraft.shared.common.IDirectionalTile;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class DirectionUtil
|
||||
{
|
||||
|
@@ -14,9 +14,9 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryLargeChest;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.ILockableContainer;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -80,7 +80,7 @@ public class InventoryUtil
|
||||
{
|
||||
// Special case code for double chests
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
if( block == Blocks.chest || block == Blocks.trapped_chest )
|
||||
if( block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST )
|
||||
{
|
||||
// Check if it's a double chest, and return a combined inventory if so
|
||||
if( world.getBlockState( pos.west() ).getBlock() == block )
|
||||
@@ -107,16 +107,16 @@ public class InventoryUtil
|
||||
}
|
||||
|
||||
// Look for entity with inventory
|
||||
Vec3 vecStart = new Vec3(
|
||||
Vec3d vecStart = new Vec3d(
|
||||
pos.getX() + 0.5 + 0.6 * side.getFrontOffsetX(),
|
||||
pos.getY() + 0.5 + 0.6 * side.getFrontOffsetY(),
|
||||
pos.getZ() + 0.5 + 0.6 * side.getFrontOffsetZ()
|
||||
);
|
||||
EnumFacing dir = side.getOpposite();
|
||||
Vec3 vecDir = new Vec3(
|
||||
Vec3d vecDir = new Vec3d(
|
||||
dir.getFrontOffsetX(), dir.getFrontOffsetY(), dir.getFrontOffsetZ()
|
||||
);
|
||||
Pair<Entity, Vec3> hit = WorldUtil.rayTraceEntities( world, vecStart, vecDir, 1.1 );
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, vecStart, vecDir, 1.1 );
|
||||
if( hit != null )
|
||||
{
|
||||
Entity entity = hit.getKey();
|
||||
|
@@ -2,7 +2,7 @@ package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@@ -9,8 +9,9 @@ package dan200.computercraft.shared.util;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRedstoneWire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -30,24 +31,25 @@ public class RedstoneUtil
|
||||
{
|
||||
int power = 0;
|
||||
Block block = getBlock( world, pos );
|
||||
if( block != null && block != Blocks.air )
|
||||
if( block != null && block != Blocks.AIR )
|
||||
{
|
||||
if( block == Blocks.redstone_wire )
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
if( block == Blocks.REDSTONE_WIRE )
|
||||
{
|
||||
if( side != EnumFacing.UP )
|
||||
{
|
||||
power = ((Integer)world.getBlockState( pos ).getValue( BlockRedstoneWire.POWER )).intValue();
|
||||
power = ((Integer)state.getValue( BlockRedstoneWire.POWER )).intValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
power = 0;
|
||||
}
|
||||
}
|
||||
else if( block.canProvidePower() )
|
||||
else if( block.canProvidePower( state ) )
|
||||
{
|
||||
power = block.getWeakPower( world, pos, world.getBlockState( pos ), side.getOpposite() );
|
||||
power = block.getWeakPower( state, world, pos, side.getOpposite() );
|
||||
}
|
||||
if( block.isNormalCube( world, pos ) )
|
||||
if( block.isNormalCube( state, world, pos ) )
|
||||
{
|
||||
for( EnumFacing testSide : EnumFacing.VALUES )
|
||||
{
|
||||
@@ -55,9 +57,9 @@ public class RedstoneUtil
|
||||
{
|
||||
BlockPos testPos = pos.offset( testSide );
|
||||
Block neighbour = getBlock( world, testPos );
|
||||
if( neighbour != null && neighbour.canProvidePower() )
|
||||
if( neighbour != null && neighbour.canProvidePower( state ) )
|
||||
{
|
||||
power = Math.max( power, neighbour.getStrongPower( world, testPos, world.getBlockState( testPos ), testSide.getOpposite() ) );
|
||||
power = Math.max( power, neighbour.getStrongPower( state, world, testPos, testSide.getOpposite() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,10 +84,10 @@ public class RedstoneUtil
|
||||
Block block = getBlock( world, pos );
|
||||
BlockPos neighbourPos = pos.offset( side );
|
||||
Block neighbour = getBlock( world, neighbourPos );
|
||||
if( neighbour != null && neighbour != Blocks.air )
|
||||
if( neighbour != null && neighbour != Blocks.AIR )
|
||||
{
|
||||
world.notifyBlockOfStateChange( neighbourPos, block );
|
||||
if( neighbour.isNormalCube( world, neighbourPos ) )
|
||||
if( neighbour.isNormalCube( world.getBlockState( neighbourPos ), world, neighbourPos ) )
|
||||
{
|
||||
world.notifyNeighborsOfStateExcept( neighbourPos, neighbour, side.getOpposite() );
|
||||
}
|
||||
|
@@ -7,10 +7,12 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -27,10 +29,11 @@ public class WorldUtil
|
||||
{
|
||||
if( isBlockInWorld( world, pos ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
if( block != null )
|
||||
{
|
||||
return block.getMaterial().isLiquid();
|
||||
return block.getMaterial( state ).isLiquid();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -41,13 +44,13 @@ public class WorldUtil
|
||||
return pos.offset( dir );
|
||||
}
|
||||
|
||||
public static Pair<Entity, Vec3> rayTraceEntities( World world, Vec3 vecStart, Vec3 vecDir, double distance )
|
||||
public static Pair<Entity, Vec3d> rayTraceEntities( World world, Vec3d vecStart, Vec3d vecDir, double distance )
|
||||
{
|
||||
Vec3 vecEnd = vecStart.addVector( vecDir.xCoord * distance, vecDir.yCoord * distance, vecDir.zCoord * distance );
|
||||
Vec3d vecEnd = vecStart.addVector( vecDir.xCoord * distance, vecDir.yCoord * distance, vecDir.zCoord * distance );
|
||||
|
||||
// Raycast for blocks
|
||||
MovingObjectPosition result = world.rayTraceBlocks( vecStart.addVector(0.0,0.0,0.0), vecEnd.addVector(0.0,0.0,0.0) );
|
||||
if( result != null && result.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK )
|
||||
RayTraceResult result = world.rayTraceBlocks( vecStart.addVector(0.0,0.0,0.0), vecEnd.addVector(0.0,0.0,0.0) );
|
||||
if( result != null && result.typeOfHit == RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
distance = vecStart.distanceTo( result.hitVec );
|
||||
vecEnd = vecStart.addVector( vecDir.xCoord * distance, vecDir.yCoord * distance, vecDir.zCoord * distance );
|
||||
@@ -94,7 +97,7 @@ public class WorldUtil
|
||||
continue;
|
||||
}
|
||||
|
||||
MovingObjectPosition littleBoxResult = littleBox.calculateIntercept( vecStart, vecEnd );
|
||||
RayTraceResult littleBoxResult = littleBox.calculateIntercept( vecStart, vecEnd );
|
||||
if( littleBoxResult != null )
|
||||
{
|
||||
double dist = vecStart.distanceTo( littleBoxResult.hitVec );
|
||||
@@ -115,7 +118,7 @@ public class WorldUtil
|
||||
}
|
||||
if( closest != null && closestDist <= distance )
|
||||
{
|
||||
Vec3 closestPos = vecStart.addVector( vecDir.xCoord * closestDist, vecDir.yCoord * closestDist, vecDir.zCoord * closestDist );
|
||||
Vec3d closestPos = vecStart.addVector( vecDir.xCoord * closestDist, vecDir.yCoord * closestDist, vecDir.zCoord * closestDist );
|
||||
return Pair.of( closest, closestPos );
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user