GUI Rendering and various fixes
This commit is contained in:
@@ -26,7 +26,10 @@ import java.util.function.Supplier;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -133,8 +136,16 @@ public abstract class AEBaseTileBlock<T extends AEBaseTile> extends AEBaseBlock
|
||||
return this.tileEntityFactory.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
|
||||
super.dropXpOnBlockBreak(worldIn, pos, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final AEBaseTile te = this.getTileEntity( w, pos );
|
||||
if( te != null )
|
||||
@@ -236,10 +247,10 @@ public abstract class AEBaseTileBlock<T extends AEBaseTile> extends AEBaseBlock
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
// FIXME if( tile instanceof TileCableBus || tile instanceof TileSkyChest )
|
||||
// {
|
||||
// return ActionResultType.FAIL;
|
||||
// }
|
||||
if( tile instanceof TileCableBus || tile instanceof TileSkyChest)
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
final ItemStack[] itemDropCandidates = Platform.getBlockDrops( world, pos );
|
||||
final ItemStack op = new ItemStack( this );
|
||||
@@ -266,7 +277,7 @@ public abstract class AEBaseTileBlock<T extends AEBaseTile> extends AEBaseBlock
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( heldItem.getItem() instanceof IMemoryCard /* FIXME && !( this instanceof BlockCableBus ) */ )
|
||||
if( heldItem.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus) )
|
||||
{
|
||||
final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem();
|
||||
final AEBaseTile tileEntity = this.getTileEntity( world, pos );
|
||||
|
||||
@@ -70,6 +70,10 @@ public abstract class AbstractCraftingUnitBlock<T extends TileCraftingTile> exte
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final TileCraftingTile cp = this.getTileEntity( w, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
|
||||
@@ -91,7 +91,7 @@ public class BlockSecurityStation extends AEBaseTileBlock<TileSecurityStation>
|
||||
final TileSecurityStation tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( w.isRemote() )
|
||||
{
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
|
||||
if( Platform.isClient() )
|
||||
if( worldIn.isRemote() )
|
||||
{
|
||||
final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver;
|
||||
if( rtr instanceof BlockRayTraceResult)
|
||||
|
||||
@@ -86,6 +86,10 @@ public abstract class BlockQuantumBase extends AEBaseTileBlock<TileQuantumBridge
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null )
|
||||
{
|
||||
|
||||
@@ -91,7 +91,7 @@ public class BlockChest extends AEBaseTileBlock<TileChest>
|
||||
final TileChest tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isCrouching() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( w.isRemote() )
|
||||
{
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package appeng.bootstrap.components;
|
||||
|
||||
import appeng.bootstrap.IBootstrapComponent;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
|
||||
public interface IItemColorRegistrationComponent extends IBootstrapComponent {
|
||||
|
||||
void register(ItemColors itemColors, BlockColors blockColors);
|
||||
|
||||
}
|
||||
@@ -19,15 +19,14 @@
|
||||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
|
||||
public class ItemColorComponent implements IInitComponent
|
||||
public class ItemColorComponent implements IItemColorRegistrationComponent
|
||||
{
|
||||
|
||||
private final Item item;
|
||||
|
||||
private final IItemColor itemColor;
|
||||
@@ -39,8 +38,8 @@ public class ItemColorComponent implements IInitComponent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize()
|
||||
public void register(ItemColors itemColors, BlockColors blockColors)
|
||||
{
|
||||
Minecraft.getInstance().getItemColors().register( this.itemColor, this.item );
|
||||
itemColors.register( this.itemColor, this.item );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.client;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import appeng.client.render.effects.*;
|
||||
@@ -27,7 +26,6 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
@@ -39,22 +37,17 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
|
||||
public class ClientHelper extends ServerHelper
|
||||
@@ -63,24 +56,11 @@ public class ClientHelper extends ServerHelper
|
||||
|
||||
private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>( ActionKey.class );
|
||||
|
||||
@Override
|
||||
public void preinit()
|
||||
public void clientInit()
|
||||
{
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientInit);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::postPlayerRender);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::wheelEvent);
|
||||
// Do not register the Fullbright hacks if Optifine is present or if the Forge lighting is disabled
|
||||
// FIXME if( !FMLClientHandler.instance().hasOptifine() && ForgeModContainer.forgeLightPipelineEnabled )
|
||||
// FIXME {
|
||||
// FIXME ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
|
||||
// FIXME }
|
||||
|
||||
// FIXME RenderingRegistry.registerEntityRenderingHandler( EntityTinyTNTPrimed.class, manager -> new RenderTinyTNTPrimed( manager ) );
|
||||
// FIXME RenderingRegistry.registerEntityRenderingHandler( EntityFloatingItem.class, manager -> new RenderFloatingItem( manager ) );
|
||||
}
|
||||
|
||||
private void clientInit(FMLClientSetupEvent event)
|
||||
{
|
||||
for( ActionKey key : ActionKey.values() )
|
||||
{
|
||||
final KeyBinding binding = new KeyBinding( key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY );
|
||||
|
||||
@@ -92,26 +92,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
protected static String join( final Collection<String> toolTip, final String delimiter )
|
||||
{
|
||||
final Joiner joiner = Joiner.on( delimiter );
|
||||
|
||||
return joiner.join( toolTip );
|
||||
}
|
||||
|
||||
protected int getQty( final Button btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
final DecimalFormat df = new DecimalFormat( "+#;-#" );
|
||||
return df.parse( btn.getMessage() ).intValue();
|
||||
}
|
||||
catch( final ParseException e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
@@ -157,6 +137,7 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
this.drawTooltip( c, mouseX - this.guiLeft, mouseY - this.guiTop );
|
||||
}
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.enableDepthTest();
|
||||
|
||||
this.renderHoveredToolTip( mouseX, mouseY );
|
||||
|
||||
@@ -182,11 +163,9 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
|
||||
if( this.isPointInRegion( left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY ) && slot.canClick( this.minecraft.player ) )
|
||||
{
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.colorMask( true, true, true, false );
|
||||
this.fillGradient( left, top, right, bottom, -2130706433, -2130706433 );
|
||||
RenderSystem.colorMask( true, true, true, true );
|
||||
RenderSystem.enableLighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,45 +369,38 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME if( slot instanceof SlotPatternTerm )
|
||||
// FIXME {
|
||||
// FIXME if( mouseButton == 6 )
|
||||
// FIXME {
|
||||
// FIXME return; // prevent weird double clicks..
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME try
|
||||
// FIXME {
|
||||
// FIXME NetworkHandler.instance().sendToServer( ( (SlotPatternTerm) slot ).getRequest( hasShiftDown() ) );
|
||||
// FIXME }
|
||||
// FIXME catch( final IOException e )
|
||||
// FIXME {
|
||||
// FIXME AELog.debug( e );
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME else if( slot instanceof SlotCraftingTerm )
|
||||
// FIXME {
|
||||
// FIXME if( mouseButton == 6 )
|
||||
// FIXME {
|
||||
// FIXME return; // prevent weird double clicks..
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME InventoryAction action = null;
|
||||
// FIXME if( hasShiftDown() )
|
||||
// FIXME {
|
||||
// FIXME action = InventoryAction.CRAFT_SHIFT;
|
||||
// FIXME }
|
||||
// FIXME else
|
||||
// FIXME {
|
||||
// FIXME // Craft stack on right-click, craft single on left-click
|
||||
// FIXME action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
|
||||
// FIXME NetworkHandler.instance().sendToServer( p );
|
||||
// FIXME
|
||||
// FIXME return;
|
||||
// FIXME }
|
||||
if( slot instanceof SlotPatternTerm )
|
||||
{
|
||||
if( mouseButton == 6 )
|
||||
{
|
||||
return; // prevent weird double clicks..
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( ( (SlotPatternTerm) slot ).getRequest( hasShiftDown() ) );
|
||||
}
|
||||
else if( slot instanceof SlotCraftingTerm )
|
||||
{
|
||||
if( mouseButton == 6 )
|
||||
{
|
||||
return; // prevent weird double clicks..
|
||||
}
|
||||
|
||||
InventoryAction action = null;
|
||||
if( hasShiftDown() )
|
||||
{
|
||||
action = InventoryAction.CRAFT_SHIFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Craft stack on right-click, craft single on left-click
|
||||
action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
|
||||
}
|
||||
|
||||
final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
|
||||
NetworkHandler.instance().sendToServer( p );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_SPACE) )
|
||||
{
|
||||
@@ -777,7 +749,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
|
||||
if( fs != null && this.isPowered() )
|
||||
{
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableBlend();
|
||||
final Fluid fluid = fs.getFluid();
|
||||
FluidAttributes fluidAttributes = fluid.getAttributes();
|
||||
@@ -793,7 +764,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
RenderSystem.color3f( red, green, blue );
|
||||
|
||||
blit(s.xPos, s.yPos, 0 /* FIXME: Validate this was previous the controls zindex */, 16, 16, sprite);
|
||||
RenderSystem.enableLighting();
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
this.fluidStackSizeRenderer.renderStackSize( this.font, fs, s.xPos, s.yPos );
|
||||
@@ -823,7 +793,6 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
final int uv_x = aes.getIcon() - uv_y * 16;
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.blendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
@@ -897,9 +866,7 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
// FIXME this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
|
||||
RenderSystem.disableLighting();
|
||||
fill( s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66ff6666 );
|
||||
RenderSystem.enableLighting();
|
||||
|
||||
// FIXME this.zLevel = 0.0F;
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
@@ -107,6 +106,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
this.repo = new ItemRepo( scrollbar, this );
|
||||
setScrollBar();
|
||||
|
||||
this.xSize = 185;
|
||||
this.ySize = 204;
|
||||
@@ -333,11 +333,11 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
craftingGridOffsetX = Integer.MAX_VALUE;
|
||||
craftingGridOffsetY = Integer.MAX_VALUE;
|
||||
|
||||
for( final Object s : this.container.inventorySlots )
|
||||
for( final Slot s : this.container.inventorySlots )
|
||||
{
|
||||
if( s instanceof AppEngSlot )
|
||||
{
|
||||
if( ( (Slot) s ).xPos < 197 )
|
||||
if( s.xPos < 197 )
|
||||
{
|
||||
this.repositionSlot( (AppEngSlot) s );
|
||||
}
|
||||
@@ -345,11 +345,10 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
|
||||
if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix )
|
||||
{
|
||||
final Slot g = (Slot) s;
|
||||
if( g.xPos > 0 && g.yPos > 0 )
|
||||
if( s.xPos > 0 && s.yPos > 0 )
|
||||
{
|
||||
craftingGridOffsetX = Math.min( craftingGridOffsetX, g.xPos );
|
||||
craftingGridOffsetY = Math.min( craftingGridOffsetY, g.yPos );
|
||||
craftingGridOffsetX = Math.min( craftingGridOffsetX, s.xPos );
|
||||
craftingGridOffsetY = Math.min( craftingGridOffsetY, s.yPos );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -457,8 +456,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
|
||||
protected void repositionSlot( final AppEngSlot s )
|
||||
{
|
||||
// FIXME .... it's final now, WHAT DO WE DO ARGH
|
||||
// s.yPos = s.getY() + this.ySize - 78 - 5;
|
||||
s.yPos = s.getY() + this.ySize - 78 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -149,6 +149,6 @@ public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm>
|
||||
{
|
||||
final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3;
|
||||
|
||||
// FIXME OH NOOOOO WE CANNOT, ITS FINAL s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
|
||||
s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,7 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
tessellator.draw();
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.color4f( 1, 1, 1, 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.client.me;
|
||||
|
||||
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -62,15 +63,15 @@ public class SlotDisconnected extends AppEngSlot
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final ItemStack is = super.getStack();
|
||||
// FIXME if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern )
|
||||
// FIXME {
|
||||
// FIXME final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
// FIXME final ItemStack out = iep.getOutput( is );
|
||||
// FIXME if( !out.isEmpty() )
|
||||
// FIXME {
|
||||
// FIXME return out;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern)
|
||||
{
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput( is );
|
||||
if( !out.isEmpty() )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class StackSizeRenderer
|
||||
{
|
||||
final String craftLabelText = AEConfig.instance().useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft
|
||||
.getLocal();
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.pushMatrix();
|
||||
@@ -62,7 +61,6 @@ public class StackSizeRenderer
|
||||
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
||||
fontRenderer.drawStringWithShadow( craftLabelText, X, Y, 16777215 );
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.enableLighting();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableBlend();
|
||||
}
|
||||
@@ -71,7 +69,6 @@ public class StackSizeRenderer
|
||||
{
|
||||
final String stackSize = this.getToBeRenderedStackSize( aeStack.getStackSize() );
|
||||
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.pushMatrix();
|
||||
@@ -80,7 +77,6 @@ public class StackSizeRenderer
|
||||
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
||||
fontRenderer.drawStringWithShadow( stackSize, X, Y, 16777215 );
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.enableLighting();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableBlend();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.container.slot.*;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
@@ -56,12 +57,6 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.guisync.SyncData;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotDisabled;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketTargetItemStack;
|
||||
@@ -92,6 +87,8 @@ public abstract class AEBaseContainer extends Container
|
||||
private boolean sentCustomName;
|
||||
private int ticksSinceCheck = 900;
|
||||
private IAEItemStack clientRequestedTargetItem = null;
|
||||
// Slots that were created to represent the player inventory
|
||||
private List<Slot> playerInventorySlots = null;
|
||||
|
||||
public AEBaseContainer( ContainerType<?> containerType, int id, final PlayerInventory ip, final TileEntity myTile, final IPart myPart )
|
||||
{
|
||||
@@ -409,7 +406,7 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
|
||||
if( !( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) /* FIXME && !( cs instanceof SlotCraftingMatrix ) */ )
|
||||
if( !( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix) )
|
||||
{
|
||||
if( cs.isItemValid( tis ) )
|
||||
{
|
||||
@@ -428,7 +425,7 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
|
||||
if( ( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) /* FIXME && !( cs instanceof SlotCraftingMatrix ) */ )
|
||||
if( ( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix ) )
|
||||
{
|
||||
if( cs.isItemValid( tis ) )
|
||||
{
|
||||
@@ -658,18 +655,18 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
final Slot s = this.getSlot( slot );
|
||||
|
||||
// FIXME if( s instanceof SlotCraftingTerm )
|
||||
// FIXME {
|
||||
// FIXME switch( action )
|
||||
// FIXME {
|
||||
// FIXME case CRAFT_SHIFT:
|
||||
// FIXME case CRAFT_ITEM:
|
||||
// FIXME case CRAFT_STACK:
|
||||
// FIXME ( (SlotCraftingTerm) s ).doClick( action, player );
|
||||
// FIXME this.updateHeld( player );
|
||||
// FIXME default:
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
if( s instanceof SlotCraftingTerm )
|
||||
{
|
||||
switch( action )
|
||||
{
|
||||
case CRAFT_SHIFT:
|
||||
case CRAFT_ITEM:
|
||||
case CRAFT_STACK:
|
||||
( (SlotCraftingTerm) s ).doClick( action, player );
|
||||
this.updateHeld( player );
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
if( s instanceof SlotFake )
|
||||
{
|
||||
@@ -742,7 +739,7 @@ public abstract class AEBaseContainer extends Container
|
||||
|
||||
for( final Object j : this.inventorySlots )
|
||||
{
|
||||
if( j instanceof Slot && j.getClass() == s.getClass() /* FIXME && !( j instanceof SlotCraftingTerm ) */ )
|
||||
if( j instanceof Slot && j.getClass() == s.getClass() && !( j instanceof SlotCraftingTerm ) )
|
||||
{
|
||||
from.add( (Slot) j );
|
||||
}
|
||||
@@ -1014,17 +1011,10 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance()
|
||||
.sendTo(
|
||||
new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.fromItemStack( p.inventory.getItemStack() ) ),
|
||||
p );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
NetworkHandler.instance()
|
||||
.sendTo(
|
||||
new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.fromItemStack( p.inventory.getItemStack() ) ),
|
||||
p );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketProgressBar;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
|
||||
@@ -66,27 +67,20 @@ public class SyncData
|
||||
this.send( c, val );
|
||||
}
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IOException e )
|
||||
catch( final IllegalArgumentException | IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void send( final IContainerListener o, final Object val ) throws IOException
|
||||
private void send( final IContainerListener o, final Object val )
|
||||
{
|
||||
if( val instanceof String )
|
||||
{
|
||||
if( o instanceof ServerPlayerEntity)
|
||||
{
|
||||
// FIXME NetworkHandler.instance().sendTo( new PacketValueConfig( "SyncDat." + this.channel, (String) val ), (ServerPlayerEntity) o );
|
||||
NetworkHandler.instance().sendTo( new PacketValueConfig( "SyncDat." + this.channel, (String) val ), (ServerPlayerEntity) o );
|
||||
}
|
||||
}
|
||||
else if( this.field.getType().isEnum() )
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package appeng.container.helper;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
abstract class AbstractContainerHelper {
|
||||
|
||||
private final SecurityPermissions requiredPermission;
|
||||
|
||||
public AbstractContainerHelper(SecurityPermissions requiredPermission) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
}
|
||||
|
||||
protected boolean checkPermission(PlayerEntity player, Object accessInterface) {
|
||||
|
||||
// FIXME: Check permissions...
|
||||
if (requiredPermission != null && accessInterface instanceof IActionHost)
|
||||
{
|
||||
final IGridNode gn = ( (IActionHost) accessInterface ).getActionableNode();
|
||||
if( gn != null )
|
||||
{
|
||||
final IGrid g = gn.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
final boolean requirePower = false;
|
||||
if( requirePower )
|
||||
{
|
||||
final IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
if( !eg.isNetworkPowered() )
|
||||
{
|
||||
// FIXME trace logging?
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||
if( !sg.hasPermission( player, this.requiredPermission ) )
|
||||
{
|
||||
player.sendMessage(new TranslationTextComponent("appliedenergistics2.permission_denied")
|
||||
.applyTextStyle(TextFormatting.RED));
|
||||
// FIXME trace logging?
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
* @param <C>
|
||||
* @param <P> The type of part this container is for.
|
||||
*/
|
||||
public final class PartContainerHelper<C extends AEBaseContainer, P extends IPart> {
|
||||
public final class PartContainerHelper<C extends AEBaseContainer, P extends IPart> extends AbstractContainerHelper {
|
||||
|
||||
private final Class<P> partClass;
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class PartContainerHelper<C extends AEBaseContainer, P extends IPar
|
||||
}
|
||||
|
||||
public PartContainerHelper(ContainerFactory<P, C> factory, Class<P> partClass, SecurityPermissions requiredPermission) {
|
||||
super(requiredPermission);
|
||||
this.partClass = partClass;
|
||||
this.factory = factory;
|
||||
this.requiredPermission = requiredPermission;
|
||||
@@ -79,6 +80,10 @@ public final class PartContainerHelper<C extends AEBaseContainer, P extends IPar
|
||||
}
|
||||
P actualPart = partClass.cast(tileEntity);
|
||||
|
||||
if (!checkPermission(player, actualPart)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use block name at position
|
||||
// FIXME: this is not right, we'd need to check the part's item stack, or custom naming interface impl
|
||||
ITextComponent title = player.world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent();
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package appeng.container.helper;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.core.AELog;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
@@ -13,6 +19,8 @@ import net.minecraft.inventory.container.SimpleNamedContainerProvider;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
/**
|
||||
@@ -22,7 +30,7 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
* @param <C>
|
||||
*/
|
||||
// FIXME: This is also used in contexts where access is via an item that implements I or exposes I via IGuiItemObject
|
||||
public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> {
|
||||
public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> extends AbstractContainerHelper {
|
||||
|
||||
private final Class<I> interfaceClass;
|
||||
|
||||
@@ -35,6 +43,7 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> {
|
||||
}
|
||||
|
||||
public PartOrTileContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass, SecurityPermissions requiredPermission) {
|
||||
super(requiredPermission);
|
||||
this.interfaceClass = interfaceClass;
|
||||
this.factory = factory;
|
||||
this.requiredPermission = requiredPermission;
|
||||
@@ -61,16 +70,19 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> {
|
||||
|
||||
I accessInterface = getHostFromLocator(player, locator);
|
||||
|
||||
if (accessInterface == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkPermission(player, accessInterface)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use block name at position
|
||||
// FIXME: this is not right, we'd need to check the part's item stack, or custom naming interface impl
|
||||
// FIXME: Should move this up, because at this point, it's hard to know where the terminal host came from (part or tile)
|
||||
ITextComponent title = player.world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent();
|
||||
|
||||
// FIXME: Check permissions...
|
||||
if (requiredPermission != null) {
|
||||
throw new IllegalStateException(); // NOT YET IMPLEMENTED
|
||||
}
|
||||
|
||||
INamedContainerProvider container = new SimpleNamedContainerProvider(
|
||||
(wnd, p, pl) -> {
|
||||
C c = factory.create(wnd, p, accessInterface);
|
||||
@@ -80,7 +92,7 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> {
|
||||
return c;
|
||||
}, title
|
||||
);
|
||||
NetworkHooks.openGui((ServerPlayerEntity) player, container, locator.getBlockPos());
|
||||
NetworkHooks.openGui((ServerPlayerEntity) player, container, locator::write);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -92,6 +104,7 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> {
|
||||
}
|
||||
|
||||
TileEntity tileEntity = player.world.getTileEntity(locator.getBlockPos());
|
||||
|
||||
// The tile entity itself can host a terminal (i.e. Chest!)
|
||||
if (interfaceClass.isInstance(tileEntity)) {
|
||||
return interfaceClass.cast(tileEntity);
|
||||
@@ -99,10 +112,15 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> {
|
||||
// But it could also be a part attached to the tile entity
|
||||
IPartHost partHost = (IPartHost) tileEntity;
|
||||
IPart part = partHost.getPart(locator.getSide());
|
||||
if (part == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (interfaceClass.isInstance(part)) {
|
||||
return interfaceClass.cast(part);
|
||||
} else {
|
||||
// FIXME: Logging?
|
||||
AELog.debug("Trying to open a container @ {} for a {}, but the container requires {}",
|
||||
locator, part.getClass(), interfaceClass);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
public final class TileContainerHelper<C extends AEBaseContainer, T extends TileEntity> {
|
||||
public final class TileContainerHelper<C extends AEBaseContainer, T extends TileEntity> extends AbstractContainerHelper {
|
||||
|
||||
private final Class<T> tileEntityClass;
|
||||
|
||||
@@ -27,6 +27,7 @@ public final class TileContainerHelper<C extends AEBaseContainer, T extends Tile
|
||||
}
|
||||
|
||||
public TileContainerHelper(ContainerFactory<T, C> factory, Class<T> tileEntityClass, SecurityPermissions requiredPermission) {
|
||||
super(requiredPermission);
|
||||
this.tileEntityClass = tileEntityClass;
|
||||
this.factory = factory;
|
||||
this.requiredPermission = requiredPermission;
|
||||
@@ -61,14 +62,13 @@ public final class TileContainerHelper<C extends AEBaseContainer, T extends Tile
|
||||
}
|
||||
T te = tileEntityClass.cast(tileEntity);
|
||||
|
||||
if (!checkPermission(player, te)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use block name at position
|
||||
ITextComponent title = player.world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent();
|
||||
|
||||
// FIXME: Check permissions...
|
||||
if (requiredPermission != null) {
|
||||
throw new IllegalStateException(); // NOT YET IMPLEMENTED
|
||||
}
|
||||
|
||||
INamedContainerProvider container = new SimpleNamedContainerProvider(
|
||||
(wnd, p, pl) -> {
|
||||
C c = factory.create(wnd, p, te);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SlotPatternTerm extends SlotCraftingTerm
|
||||
this.groupNum = groupNumber;
|
||||
}
|
||||
|
||||
public AppEngPacket getRequest( final boolean shift ) throws IOException
|
||||
public AppEngPacket getRequest( final boolean shift )
|
||||
{
|
||||
return new PacketPatternSlot( this
|
||||
.getPattern(), Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createStack( this.getStack() ), shift );
|
||||
|
||||
@@ -27,9 +27,9 @@ import net.minecraftforge.items.IItemHandler;
|
||||
public class SlotPlayerInv extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotPlayerInv( final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
|
||||
public SlotPlayerInv( final IItemHandler par1iInventory, final int idx, final int x, final int y )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
super( par1iInventory, idx, x, y );
|
||||
|
||||
this.setPlayerSide( true );
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.BlockState;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -42,7 +43,7 @@ public final class AELog
|
||||
private static final Logger SERVER = LogManager.getFormatterLogger( LOGGER_PREFIX + SERVER_SUFFIX );
|
||||
private static final Logger CLIENT = LogManager.getFormatterLogger( LOGGER_PREFIX + CLIENT_SUFFIX );
|
||||
|
||||
private static final String BLOCK_UPDATE = "Block Update of %s @ ( %s )";
|
||||
private static final String BLOCK_UPDATE = "Block Update of %s @ ( %s ). State %s -> %s";
|
||||
|
||||
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception: ";
|
||||
|
||||
@@ -318,13 +319,15 @@ public final class AELog
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param pos
|
||||
* @param currentState
|
||||
* @param newState
|
||||
* @param aeBaseTile
|
||||
*/
|
||||
public static void blockUpdate( @Nonnull final BlockPos pos, @Nonnull final AEBaseTile aeBaseTile )
|
||||
public static void blockUpdate(@Nonnull final BlockPos pos, @Nonnull BlockState currentState, @Nonnull BlockState newState, @Nonnull final AEBaseTile aeBaseTile)
|
||||
{
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.UPDATE_LOGGING ) )
|
||||
{
|
||||
info( BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos );
|
||||
info( BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos, currentState, newState );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.core;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import appeng.block.paint.PaintSplotchesModel;
|
||||
@@ -27,6 +28,7 @@ import appeng.block.qnb.QnbFormedModel;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.bootstrap.components.ItemColorComponent;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
@@ -34,6 +36,7 @@ import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||
import appeng.client.render.model.*;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
import appeng.core.stats.AdvancementTriggers;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.PartPlacement;
|
||||
@@ -41,6 +44,7 @@ import appeng.server.AECommand;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.services.VersionChecker;
|
||||
import appeng.services.version.VersionCheckerConfig;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -51,6 +55,7 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -70,6 +75,7 @@ import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -137,6 +143,7 @@ public final class AppEng
|
||||
// Register client-only events
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(this::clientSetup));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::modelRegistryEvent));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::registerItemColors));
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener( TickHandler.INSTANCE::unloadWorld );
|
||||
MinecraftForge.EVENT_BUS.addListener( TickHandler.INSTANCE::onTick );
|
||||
@@ -164,10 +171,24 @@ public final class AppEng
|
||||
this.startService( "AE2 VersionChecker", versionCheckerThread );
|
||||
}
|
||||
|
||||
registerNetworkHandler();
|
||||
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
|
||||
((ClientHelper) proxy).clientInit();
|
||||
|
||||
// Do not register the Fullbright hacks if Optifine is present or if the Forge lighting is disabled
|
||||
// FIXME if( !FMLClientHandler.instance().hasOptifine() && ForgeModContainer.forgeLightPipelineEnabled )
|
||||
// FIXME {
|
||||
// FIXME ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
|
||||
// FIXME }
|
||||
|
||||
// FIXME RenderingRegistry.registerEntityRenderingHandler( EntityTinyTNTPrimed.class, manager -> new RenderTinyTNTPrimed( manager ) );
|
||||
// FIXME RenderingRegistry.registerEntityRenderingHandler( EntityFloatingItem.class, manager -> new RenderFloatingItem( manager ) );
|
||||
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents( IClientSetupComponent.class ).forEachRemaining(IClientSetupComponent::setup);
|
||||
|
||||
@@ -297,26 +318,23 @@ public final class AppEng
|
||||
//
|
||||
// AELog.info( "Initialization ( ended after " + start.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
// }
|
||||
//
|
||||
// @EventHandler
|
||||
// private void postInit( final FMLPostInitializationEvent event )
|
||||
// {
|
||||
// final Stopwatch start = Stopwatch.createStarted();
|
||||
// AELog.info( "Post Initialization ( started )" );
|
||||
//
|
||||
// this.registration.postInit( event );
|
||||
// IntegrationRegistry.INSTANCE.postInit();
|
||||
// CrashReportExtender.registerCrashCallable( new IntegrationCrashEnhancement() );
|
||||
//
|
||||
// AppEng.proxy.postInit();
|
||||
// AEConfig.instance().save();
|
||||
//
|
||||
// NetworkRegistry.INSTANCE.registerGuiHandler( this, GuiBridge.GUI_Handler );
|
||||
// NetworkHandler.init( "AE2" );
|
||||
//
|
||||
// AELog.info( "Post Initialization ( ended after " + start.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
// }
|
||||
//
|
||||
|
||||
private void registerNetworkHandler()
|
||||
{
|
||||
final Stopwatch start = Stopwatch.createStarted();
|
||||
AELog.info( "Post Initialization ( started )" );
|
||||
|
||||
// FIXME IntegrationRegistry.INSTANCE.postInit();
|
||||
// FIXME CrashReportExtender.registerCrashCallable( new IntegrationCrashEnhancement() );
|
||||
|
||||
AppEng.proxy.postInit();
|
||||
AEConfig.instance().save();
|
||||
|
||||
NetworkHandler.init( new ResourceLocation(MOD_ID, "main") );
|
||||
|
||||
AELog.info( "Post Initialization ( ended after " + start.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// private void handleIMCEvent( final FMLInterModComms.IMCEvent event )
|
||||
// {
|
||||
|
||||
@@ -40,8 +40,6 @@ import appeng.core.sync.AppEngPacket;
|
||||
public abstract class CommonHelper
|
||||
{
|
||||
|
||||
public abstract void preinit();
|
||||
|
||||
public abstract World getWorld();
|
||||
|
||||
public abstract void bindTileEntitySpecialRenderer( Class<? extends TileEntity> tile, AEBaseBlock blk );
|
||||
|
||||
@@ -104,6 +104,7 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
@@ -881,4 +882,10 @@ final class Registration
|
||||
new AECommand().register(evt.getCommandDispatcher());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerItemColors(ColorHandlerEvent.Item event) {
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents( IItemColorRegistrationComponent.class ).forEachRemaining(c -> c.register(event.getItemColors(), event.getBlockColors()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack readFromPacket( PacketBuffer input ) throws IOException
|
||||
public IAEItemStack readFromPacket( PacketBuffer input )
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
|
||||
@@ -215,7 +215,7 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack readFromPacket( PacketBuffer input ) throws IOException
|
||||
public IAEFluidStack readFromPacket( PacketBuffer input )
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ public final class ApiItems implements IItems
|
||||
private final IItemDefinition encodedPattern;
|
||||
private final IItemDefinition colorApplicator;
|
||||
|
||||
private final IItemDefinition paintBall;
|
||||
private final AEColoredItemDefinition coloredPaintBall;
|
||||
private final AEColoredItemDefinition coloredLumenPaintBall;
|
||||
|
||||
@@ -296,12 +295,13 @@ public final class ApiItems implements IItems
|
||||
.rendering( new ItemEncodedPatternRendering() )
|
||||
.build();
|
||||
|
||||
this.paintBall = registry.item( "paint_ball", ItemPaintBall::new )
|
||||
IItemDefinition paintBall = registry.item( "paint_ball", ItemPaintBall::new )
|
||||
.features( AEFeature.PAINT_BALLS )
|
||||
.rendering( new ItemPaintBallRendering() )
|
||||
.build();
|
||||
this.coloredPaintBall = registry.colored( this.paintBall, 0 );
|
||||
this.coloredLumenPaintBall = registry.colored( this.paintBall, 20 );
|
||||
// FIXME these are both wrong
|
||||
this.coloredPaintBall = registry.colored( paintBall, 0 );
|
||||
this.coloredLumenPaintBall = registry.colored( paintBall, 20 );
|
||||
|
||||
FeatureFactory debugTools = registry.features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE );
|
||||
this.toolEraser = debugTools.item( "debug_eraser", ToolEraser::new ).build();
|
||||
@@ -567,11 +567,6 @@ public final class ApiItems implements IItems
|
||||
return this.coloredLumenPaintBall;
|
||||
}
|
||||
|
||||
public IItemDefinition paintBall()
|
||||
{
|
||||
return this.paintBall;
|
||||
}
|
||||
|
||||
public IItemDefinition toolEraser()
|
||||
{
|
||||
return this.toolEraser;
|
||||
|
||||
@@ -4,6 +4,7 @@ package appeng.core.features.registries.cell;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -34,6 +35,6 @@ public class BasicItemCellGuiHandler implements ICellGuiHandler
|
||||
@Override
|
||||
public void openChestGui( final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerWireless.TYPE, player, ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp()));
|
||||
ContainerOpener.openContainer(ContainerMEMonitorable.TYPE, player, ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -28,6 +29,7 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
||||
public abstract class AppEngPacket
|
||||
@@ -41,8 +43,7 @@ public abstract class AppEngPacket
|
||||
|
||||
public final int getPacketID()
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
// FIXME return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal();
|
||||
return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal();
|
||||
}
|
||||
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
@@ -68,7 +69,6 @@ public abstract class AppEngPacket
|
||||
AELog.info( this.getClass().getName() + " : " + p.readableBytes() );
|
||||
}
|
||||
|
||||
// FIXME return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
|
||||
return null;
|
||||
return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,70 +61,63 @@ public class AppEngPacketHandlerBase
|
||||
|
||||
public enum PacketTypes
|
||||
{
|
||||
PACKET_COMPASS_REQUEST( PacketCompassRequest::new ),
|
||||
PACKET_COMPASS_REQUEST( PacketCompassRequest.class, PacketCompassRequest::new ),
|
||||
|
||||
PACKET_COMPASS_RESPONSE( PacketCompassResponse::new ),
|
||||
PACKET_COMPASS_RESPONSE( PacketCompassResponse.class, PacketCompassResponse::new ),
|
||||
|
||||
PACKET_INVENTORY_ACTION( PacketInventoryAction::new ),
|
||||
PACKET_INVENTORY_ACTION( PacketInventoryAction.class, PacketInventoryAction::new ),
|
||||
|
||||
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate::new ),
|
||||
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate.class, PacketMEInventoryUpdate::new ),
|
||||
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate::new ),
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate.class, PacketMEFluidInventoryUpdate::new ),
|
||||
|
||||
PACKET_CONFIG_BUTTON( PacketConfigButton::new ),
|
||||
PACKET_CONFIG_BUTTON( PacketConfigButton.class, PacketConfigButton::new ),
|
||||
|
||||
PACKET_PART_PLACEMENT( PacketPartPlacement::new ),
|
||||
PACKET_PART_PLACEMENT( PacketPartPlacement.class, PacketPartPlacement::new ),
|
||||
|
||||
PACKET_LIGHTNING( PacketLightning::new ),
|
||||
PACKET_LIGHTNING( PacketLightning.class, PacketLightning::new ),
|
||||
|
||||
PACKET_MATTER_CANNON( PacketMatterCannon::new ),
|
||||
PACKET_MATTER_CANNON( PacketMatterCannon.class, PacketMatterCannon::new ),
|
||||
|
||||
PACKET_MOCK_EXPLOSION( PacketMockExplosion::new ),
|
||||
PACKET_MOCK_EXPLOSION( PacketMockExplosion.class, PacketMockExplosion::new ),
|
||||
|
||||
PACKET_VALUE_CONFIG( PacketValueConfig::new ),
|
||||
PACKET_VALUE_CONFIG( PacketValueConfig.class, PacketValueConfig::new ),
|
||||
|
||||
PACKET_TRANSITION_EFFECT( PacketTransitionEffect::new ),
|
||||
PACKET_TRANSITION_EFFECT( PacketTransitionEffect.class, PacketTransitionEffect::new ),
|
||||
|
||||
PACKET_PROGRESS_VALUE( PacketProgressBar::new ),
|
||||
PACKET_PROGRESS_VALUE( PacketProgressBar.class, PacketProgressBar::new ),
|
||||
|
||||
PACKET_CLICK( PacketClick::new ),
|
||||
PACKET_CLICK( PacketClick.class, PacketClick::new ),
|
||||
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis::new ),
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis.class, PacketSwitchGuis::new ),
|
||||
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots::new ),
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots.class, PacketSwapSlots::new ),
|
||||
|
||||
PACKET_PATTERN_SLOT( PacketPatternSlot::new ),
|
||||
PACKET_PATTERN_SLOT( PacketPatternSlot.class, PacketPatternSlot::new ),
|
||||
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe::new ),
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe.class, PacketJEIRecipe::new ),
|
||||
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack::new ),
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack.class, PacketTargetItemStack::new ),
|
||||
|
||||
PACKET_TARGET_FLUID( PacketTargetFluidStack::new ),
|
||||
PACKET_TARGET_FLUID( PacketTargetFluidStack.class, PacketTargetFluidStack::new ),
|
||||
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest::new ),
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest.class, PacketCraftRequest::new ),
|
||||
|
||||
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation::new ),
|
||||
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation.class, PacketAssemblerAnimation::new ),
|
||||
|
||||
PACKET_COMPRESSED_NBT( PacketCompressedNBT::new ),
|
||||
PACKET_COMPRESSED_NBT( PacketCompressedNBT.class, PacketCompressedNBT::new ),
|
||||
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity::new ),
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity.class, PacketPaintedEntity::new ),
|
||||
|
||||
PACKET_FLUID_TANK( PacketFluidSlot::new );
|
||||
PACKET_FLUID_TANK( PacketFluidSlot.class, PacketFluidSlot::new );
|
||||
|
||||
private final Class<? extends AppEngPacket> packetClass;
|
||||
private final Function<PacketBuffer, AppEngPacket> factory;
|
||||
|
||||
PacketTypes( Function<PacketBuffer, AppEngPacket> factory )
|
||||
PacketTypes( Class<? extends AppEngPacket> packetClass, Function<PacketBuffer, AppEngPacket> factory )
|
||||
{
|
||||
Type c = TypeResolver.resolveGenericType( Function.class, factory.getClass() );
|
||||
if( c == TypeResolver.Unknown.class )
|
||||
{
|
||||
throw new IllegalStateException("Failed to resolve type for AE packet type: " + factory.toString());
|
||||
}
|
||||
this.packetClass = (Class<? extends AppEngPacket>) c;
|
||||
this.factory = factory;
|
||||
|
||||
REVERSE_LOOKUP.put( this.packetClass, this );
|
||||
REVERSE_LOOKUP.put(packetClass, this );
|
||||
}
|
||||
|
||||
public static PacketTypes getPacket( final int id )
|
||||
|
||||
@@ -72,8 +72,7 @@ public class NetworkHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
// FIXME return new AppEngClientPacketHandler();
|
||||
return null;
|
||||
return new AppEngClientPacketHandler();
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
@@ -85,8 +84,7 @@ public class NetworkHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
// FIXME return new AppEngServerPacketHandler();
|
||||
return null;
|
||||
return new AppEngServerPacketHandler();
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketAssemblerAnimation( final BlockPos pos, final byte rate, final IAEItemStack is ) throws IOException
|
||||
public PacketAssemblerAnimation( final BlockPos pos, final byte rate, final IAEItemStack is )
|
||||
{
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.io.OutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import appeng.client.gui.implementations.GuiInterfaceTerminal;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -61,7 +62,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
public int read()
|
||||
{
|
||||
if( stream.readableBytes() <= 0 )
|
||||
{
|
||||
@@ -80,6 +81,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: this is pointless, PacketBuffer.writeNBT will already compress
|
||||
// api
|
||||
public PacketCompressedNBT( final CompoundNBT din ) throws IOException
|
||||
{
|
||||
@@ -93,7 +95,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
|
||||
@Override
|
||||
public void write( final int value ) throws IOException
|
||||
public void write( final int value )
|
||||
{
|
||||
PacketCompressedNBT.this.data.writeByte( value );
|
||||
}
|
||||
@@ -111,9 +113,9 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
// FIXME if( gs instanceof GuiInterfaceTerminal )
|
||||
// FIXME {
|
||||
// FIXME ( (GuiInterfaceTerminal) gs ).postUpdate( this.in );
|
||||
// FIXME }
|
||||
if( gs instanceof GuiInterfaceTerminal)
|
||||
{
|
||||
( (GuiInterfaceTerminal) gs ).postUpdate( this.in );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,21 +19,10 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -41,6 +30,11 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
|
||||
public class PacketInventoryAction extends AppEngPacket
|
||||
@@ -68,7 +62,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketInventoryAction( final InventoryAction action, final int slot, final IAEItemStack slotItem ) throws IOException
|
||||
public PacketInventoryAction( final InventoryAction action, final int slot, final IAEItemStack slotItem )
|
||||
{
|
||||
|
||||
if( Platform.isClient() )
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketJEIRecipe( final CompoundNBT recipe ) throws IOException
|
||||
public PacketJEIRecipe( final CompoundNBT recipe )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
|
||||
@@ -80,12 +80,10 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
this.list = new LinkedList<>();
|
||||
this.ref = stream.readByte();
|
||||
|
||||
// int originalBytes = stream.readableBytes();
|
||||
|
||||
try( final GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
|
||||
{
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
public int read()
|
||||
{
|
||||
if( stream.readableBytes() <= 0 )
|
||||
{
|
||||
@@ -140,7 +138,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
this.compressFrame = new GZIPOutputStream( new OutputStream()
|
||||
{
|
||||
@Override
|
||||
public void write( final int value ) throws IOException
|
||||
public void write( final int value )
|
||||
{
|
||||
PacketMEFluidInventoryUpdate.this.data.writeByte( value );
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -80,7 +84,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
try( GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
|
||||
{
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
public int read()
|
||||
{
|
||||
if( stream.readableBytes() <= 0 )
|
||||
{
|
||||
@@ -134,7 +138,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
this.compressFrame = new GZIPOutputStream( new OutputStream()
|
||||
{
|
||||
@Override
|
||||
public void write( final int value ) throws IOException
|
||||
public void write( final int value )
|
||||
{
|
||||
PacketMEInventoryUpdate.this.data.writeByte( value );
|
||||
}
|
||||
@@ -149,25 +153,25 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
{
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
// FIXME if( gs instanceof GuiCraftConfirm )
|
||||
// FIXME {
|
||||
// FIXME ( (GuiCraftConfirm) gs ).postUpdate( this.list, this.ref );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( gs instanceof GuiCraftingCPU )
|
||||
// FIXME {
|
||||
// FIXME ( (GuiCraftingCPU) gs ).postUpdate( this.list, this.ref );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( gs instanceof GuiMEMonitorable )
|
||||
// FIXME {
|
||||
// FIXME ( (GuiMEMonitorable) gs ).postUpdate( this.list );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( gs instanceof GuiNetworkStatus )
|
||||
// FIXME {
|
||||
// FIXME ( (GuiNetworkStatus) gs ).postUpdate( this.list );
|
||||
// FIXME }
|
||||
if( gs instanceof GuiCraftConfirm)
|
||||
{
|
||||
( (GuiCraftConfirm) gs ).postUpdate( this.list, this.ref );
|
||||
}
|
||||
|
||||
if( gs instanceof GuiCraftingCPU)
|
||||
{
|
||||
( (GuiCraftingCPU<?>) gs ).postUpdate( this.list, this.ref );
|
||||
}
|
||||
|
||||
if( gs instanceof GuiMEMonitorable)
|
||||
{
|
||||
( (GuiMEMonitorable<?>) gs ).postUpdate( this.list );
|
||||
}
|
||||
|
||||
if( gs instanceof GuiNetworkStatus)
|
||||
{
|
||||
( (GuiNetworkStatus) gs ).postUpdate( this.list );
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPatternSlot( final IItemHandler pat, final IAEItemStack slotItem, final boolean shift ) throws IOException
|
||||
public PacketPatternSlot( final IItemHandler pat, final IAEItemStack slotItem, final boolean shift )
|
||||
{
|
||||
|
||||
this.slotItem = slotItem;
|
||||
@@ -94,7 +94,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
private void writeItem( final IAEItemStack slotItem, final PacketBuffer data ) throws IOException
|
||||
private void writeItem( final IAEItemStack slotItem, final PacketBuffer data )
|
||||
{
|
||||
if( slotItem == null )
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ToolDebugCard extends AEBaseItem
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if( Platform.isClient() )
|
||||
if( context.getWorld().isRemote() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ToolEraser extends AEBaseItem
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if( Platform.isClient() )
|
||||
if( context.getWorld().isRemote() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ToolMeteoritePlacer extends AEBaseItem
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if( Platform.isClient() )
|
||||
if( context.getWorld().isRemote() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ToolReplicatorCard extends AEBaseItem
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if( Platform.isClient() )
|
||||
if( context.getWorld().isRemote() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,10 @@ public class BlockSkyStone extends AEBaseBlock
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
super.onReplaced(state, w, pos, newState, isMoving);
|
||||
|
||||
if( Platform.isServer() )
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class EntityChargedQuartz extends AEBaseEntityItem
|
||||
return;
|
||||
}
|
||||
|
||||
if( Platform.isClient() && this.delay > 30 && AEConfig.instance().isEnableEffects() )
|
||||
if( world.isRemote && this.delay > 30 && AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
AppEng.proxy.spawnEffect( EffectType.Lightning, this.world, this.getPosX(), this.getPosY(), this.getPosZ(), null );
|
||||
this.delay = 0;
|
||||
|
||||
@@ -45,7 +45,6 @@ public class GuiFluidSlot extends GuiCustomSlot
|
||||
final IAEFluidStack fs = this.getFluidStack();
|
||||
if( fs != null )
|
||||
{
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableBlend();
|
||||
final Fluid fluid = fs.getFluid();
|
||||
final FluidAttributes attributes = fluid.getAttributes();
|
||||
|
||||
@@ -52,7 +52,6 @@ public class GuiFluidTank extends Widget implements ITooltip
|
||||
if( this.visible )
|
||||
{
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableLighting();
|
||||
|
||||
fill( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ public class FluidStackSizeRenderer
|
||||
{
|
||||
final String stackSize = this.getToBeRenderedStackSize( aeStack.getStackSize() );
|
||||
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.pushMatrix();
|
||||
@@ -69,7 +68,6 @@ public class FluidStackSizeRenderer
|
||||
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
||||
fontRenderer.drawStringWithShadow( stackSize, X, Y, 16777215 );
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.enableLighting();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableBlend();
|
||||
}
|
||||
|
||||
@@ -110,43 +110,6 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
return fluid;
|
||||
}
|
||||
|
||||
public static IAEFluidStack fromPacket( final PacketBuffer buffer ) throws IOException
|
||||
{
|
||||
final byte mask = buffer.readByte();
|
||||
final byte stackType = (byte) ( ( mask & 0x0C ) >> 2 );
|
||||
final byte countReqType = (byte) ( ( mask & 0x30 ) >> 4 );
|
||||
final boolean isCraftable = ( mask & 0x40 ) > 0;
|
||||
final boolean hasTagCompound = ( mask & 0x80 ) > 0;
|
||||
|
||||
// don't send this...
|
||||
final CompoundNBT d = new CompoundNBT();
|
||||
|
||||
d.putString( "FluidName", buffer.readString() );
|
||||
d.putByte( "Amount", (byte) 0 );
|
||||
|
||||
if( hasTagCompound )
|
||||
{
|
||||
d.put( "Tag", buffer.readCompoundTag() );
|
||||
}
|
||||
|
||||
final long stackSize = getPacketValue( stackType, buffer );
|
||||
final long countRequestable = getPacketValue( countReqType, buffer );
|
||||
|
||||
final FluidStack fluidStack = FluidStack.loadFluidStackFromNBT( d );
|
||||
|
||||
if( fluidStack == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final AEFluidStack fluid = AEFluidStack.fromFluidStack( fluidStack );
|
||||
// fluid.priority = (int) priority;
|
||||
fluid.setStackSize( stackSize );
|
||||
fluid.setCountRequestable( countRequestable );
|
||||
fluid.setCraftable( isCraftable );
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add( final IAEFluidStack option )
|
||||
{
|
||||
@@ -299,8 +262,45 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static IAEFluidStack fromPacket( final PacketBuffer buffer )
|
||||
{
|
||||
final byte mask = buffer.readByte();
|
||||
final byte stackType = (byte) ( ( mask & 0x0C ) >> 2 );
|
||||
final byte countReqType = (byte) ( ( mask & 0x30 ) >> 4 );
|
||||
final boolean isCraftable = ( mask & 0x40 ) > 0;
|
||||
final boolean hasTagCompound = ( mask & 0x80 ) > 0;
|
||||
|
||||
// don't send this...
|
||||
final CompoundNBT d = new CompoundNBT();
|
||||
|
||||
d.putString( "FluidName", buffer.readString() );
|
||||
d.putByte( "Amount", (byte) 0 );
|
||||
|
||||
if( hasTagCompound )
|
||||
{
|
||||
d.put( "Tag", buffer.readCompoundTag() );
|
||||
}
|
||||
|
||||
final long stackSize = getPacketValue( stackType, buffer );
|
||||
final long countRequestable = getPacketValue( countReqType, buffer );
|
||||
|
||||
final FluidStack fluidStack = FluidStack.loadFluidStackFromNBT( d );
|
||||
|
||||
if( fluidStack == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final AEFluidStack fluid = AEFluidStack.fromFluidStack( fluidStack );
|
||||
// fluid.priority = (int) priority;
|
||||
fluid.setStackSize( stackSize );
|
||||
fluid.setCountRequestable( countRequestable );
|
||||
fluid.setCraftable( isCraftable );
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacket( final PacketBuffer buffer ) throws IOException
|
||||
public void writeToPacket( final PacketBuffer buffer )
|
||||
{
|
||||
final byte mask = (byte) ( ( this.getType( this.getStackSize() ) << 2 ) | ( this
|
||||
.getType( this.getCountRequestable() ) << 4 ) | ( (byte) ( this.isCraftable() ? 1 : 0 ) << 6 ) | ( this.hasTagCompound() ? 1 : 0 ) << 7 );
|
||||
@@ -313,7 +313,7 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
this.putPacketValue( buffer, this.getCountRequestable() );
|
||||
}
|
||||
|
||||
private void writeToStream( final PacketBuffer buffer ) throws IOException
|
||||
private void writeToStream( final PacketBuffer buffer )
|
||||
{
|
||||
buffer.writeString( fluid.getRegistryName().toString() );
|
||||
if( this.hasTagCompound() )
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
package appeng.items.misc;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
@@ -33,14 +33,14 @@ import net.minecraft.util.text.TranslationTextComponent;
|
||||
public class ItemPaintBall extends AEBaseItem
|
||||
{
|
||||
|
||||
private static final String TAG_COLOR = "c";
|
||||
private static final String TAG_LUMEN = "l";
|
||||
|
||||
private static final ITextComponent LUMEN_PREFIX = new TranslationTextComponent(GuiText.Lumen.getTranslationKey())
|
||||
.appendText(" ");
|
||||
|
||||
private static final int DAMAGE_THRESHOLD = 20;
|
||||
|
||||
public ItemPaintBall(Properties properties) {
|
||||
super(properties);
|
||||
// FIXME this.setHasSubtypes( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public class ItemPaintBall extends AEBaseItem
|
||||
private ITextComponent getExtraName( final ItemStack is )
|
||||
{
|
||||
ITextComponent colorText = new TranslationTextComponent(this.getColor(is).translationKey);
|
||||
if (is.getDamage() >= DAMAGE_THRESHOLD) {
|
||||
if (isLumen(is)) {
|
||||
return LUMEN_PREFIX.shallowCopy().appendSibling(colorText);
|
||||
} else {
|
||||
return colorText;
|
||||
@@ -63,18 +63,33 @@ public class ItemPaintBall extends AEBaseItem
|
||||
|
||||
public AEColor getColor( final ItemStack is )
|
||||
{
|
||||
int dmg = is.getDamage();
|
||||
if( dmg >= DAMAGE_THRESHOLD )
|
||||
{
|
||||
dmg -= DAMAGE_THRESHOLD;
|
||||
}
|
||||
|
||||
if( dmg >= AEColor.values().length )
|
||||
{
|
||||
CompoundNBT tag = is.getTag();
|
||||
if (tag == null || !tag.contains(TAG_COLOR)) {
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
int c = tag.getInt(TAG_COLOR);
|
||||
if (c < 0 || c >= AEColor.values().length) {
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
return AEColor.values()[c];
|
||||
}
|
||||
|
||||
return AEColor.values()[dmg];
|
||||
public ItemStack setColor( final ItemStack is, AEColor color )
|
||||
{
|
||||
is.getOrCreateTag().putInt(TAG_COLOR, color.ordinal());
|
||||
return is;
|
||||
}
|
||||
|
||||
public boolean isLumen( final ItemStack is )
|
||||
{
|
||||
CompoundNBT tag = is.getTag();
|
||||
return tag != null && tag.getBoolean(TAG_LUMEN);
|
||||
}
|
||||
|
||||
public ItemStack setLumen( final ItemStack is, boolean lumen )
|
||||
{
|
||||
is.getOrCreateTag().putBoolean(TAG_LUMEN, lumen);
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +99,7 @@ public class ItemPaintBall extends AEBaseItem
|
||||
{
|
||||
if( c != AEColor.TRANSPARENT )
|
||||
{
|
||||
itemStacks.add( new ItemStack( this, 1 /* FIXME, c.ordinal() */ ) );
|
||||
itemStacks.add( setColor(new ItemStack( this ), c) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,15 +107,9 @@ public class ItemPaintBall extends AEBaseItem
|
||||
{
|
||||
if( c != AEColor.TRANSPARENT )
|
||||
{
|
||||
itemStacks.add( new ItemStack( this, 1 /* FIXME , DAMAGE_THRESHOLD + c.ordinal() */ ) );
|
||||
itemStacks.add( setLumen(setColor(new ItemStack( this ), c), true) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLumen( final ItemStack is )
|
||||
{
|
||||
final int dmg = is.getDamage();
|
||||
return dmg >= DAMAGE_THRESHOLD;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,14 +44,16 @@ public class ItemPaintBallRendering extends ItemRenderingCustomizer
|
||||
|
||||
private static int getColorFromItemstack( ItemStack stack, int tintIndex )
|
||||
{
|
||||
final AEColor col = ( (ItemPaintBall) stack.getItem() ).getColor( stack );
|
||||
ItemPaintBall item = (ItemPaintBall) stack.getItem();
|
||||
final AEColor col = item.getColor( stack );
|
||||
|
||||
final int colorValue = stack.getDamage() >= 20 ? col.mediumVariant : col.mediumVariant;
|
||||
boolean lumen = item.isLumen(stack);
|
||||
final int colorValue = lumen ? col.mediumVariant : col.mediumVariant;
|
||||
final int r = ( colorValue >> 16 ) & 0xff;
|
||||
final int g = ( colorValue >> 8 ) & 0xff;
|
||||
final int b = ( colorValue ) & 0xff;
|
||||
|
||||
if( stack.getDamage() >= 20 )
|
||||
if( lumen )
|
||||
{
|
||||
final float fail = 0.7f;
|
||||
final int full = (int) ( 255 * 0.3 );
|
||||
|
||||
@@ -36,6 +36,7 @@ import appeng.block.networking.BlockCableBus;
|
||||
import appeng.block.paint.BlockPaint;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.hooks.IBlockTool;
|
||||
@@ -59,6 +60,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -76,6 +78,8 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
|
||||
private static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<>();
|
||||
|
||||
private static final String TAG_COLOR = "color";
|
||||
|
||||
static
|
||||
{
|
||||
for( final AEColor color : AEColor.VALID_COLORS )
|
||||
@@ -91,6 +95,16 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
public ToolColorApplicator(Item.Properties props)
|
||||
{
|
||||
super( AEConfig.instance().getColorApplicatorBattery(), props );
|
||||
addPropertyOverride(
|
||||
new ResourceLocation(AppEng.MOD_ID, "colored"),
|
||||
(itemStack, world, entity) -> {
|
||||
// If the stack has no color, don't use the colored model since the impact of calling getColor
|
||||
// for every quad is extremely high, if the stack tries to re-search its inventory for a new
|
||||
// paintball everytime
|
||||
AEColor col = getActiveColor( itemStack );
|
||||
return ( col != null ) ? 1 : 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,9 +253,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
public ItemStack getColor( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT c = is.getTag();
|
||||
if( c != null && c.contains("color") )
|
||||
if( c != null && c.contains(TAG_COLOR) )
|
||||
{
|
||||
final CompoundNBT color = c.getCompound( "color" );
|
||||
final CompoundNBT color = c.getCompound( TAG_COLOR );
|
||||
final ItemStack oldColor = ItemStack.read(color);
|
||||
if( !oldColor.isEmpty() )
|
||||
{
|
||||
@@ -326,13 +340,13 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
final CompoundNBT data = is.getOrCreateTag();
|
||||
if( newColor.isEmpty() )
|
||||
{
|
||||
data.remove( "color" );
|
||||
data.remove( TAG_COLOR );
|
||||
}
|
||||
else
|
||||
{
|
||||
final CompoundNBT color = new CompoundNBT();
|
||||
newColor.write(color);
|
||||
data.put( "color", color );
|
||||
data.put( TAG_COLOR, color );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,25 +461,25 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
@Override
|
||||
public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition )
|
||||
{
|
||||
// FIXME if( requestedAddition != null )
|
||||
// FIXME {
|
||||
// FIXME final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() );
|
||||
// FIXME
|
||||
// FIXME for( final int x : id )
|
||||
// FIXME {
|
||||
// FIXME if( ORE_TO_COLOR.containsKey( x ) )
|
||||
// FIXME {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( requestedAddition.getItem() instanceof SnowballItem )
|
||||
// FIXME {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 );
|
||||
// FIXME }
|
||||
if( requestedAddition != null )
|
||||
{
|
||||
// FIXME final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() );
|
||||
|
||||
// FIXME for( final int x : id )
|
||||
// FIXME {
|
||||
// FIXME if( ORE_TO_COLOR.containsKey( x ) )
|
||||
// FIXME {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
|
||||
if( requestedAddition.getItem() instanceof SnowballItem )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -542,4 +556,5 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
{
|
||||
this.cycleColors( is, this.getColor( is ), up ? 1 : -1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,11 +23,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -48,12 +51,6 @@ public class ServerHelper extends CommonHelper
|
||||
|
||||
private PlayerEntity renderModeBased;
|
||||
|
||||
@Override
|
||||
public void preinit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
@@ -99,7 +96,7 @@ public class ServerHelper extends CommonHelper
|
||||
final double dZ = z - entityplayermp.getPosZ();
|
||||
if( dX * dX + dY * dY + dZ * dZ < dist * dist )
|
||||
{
|
||||
// FIXME NetworkHandler.instance().sendTo( packet, entityplayermp );
|
||||
NetworkHandler.instance().sendTo( packet, entityplayermp );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,14 +157,14 @@ public class ServerHelper extends CommonHelper
|
||||
{
|
||||
final ItemStack is = player.inventory.getStackInSlot( x );
|
||||
|
||||
// FIXME if( !is.isEmpty() && is.getItem() instanceof ToolNetworkTool )
|
||||
// FIXME {
|
||||
// FIXME final CompoundNBT c = is.getTag();
|
||||
// FIXME if( c != null && c.getBoolean( "hideFacades" ) )
|
||||
// FIXME {
|
||||
// FIXME return CableRenderMode.CABLE_VIEW;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
if( !is.isEmpty() && is.getItem() instanceof ToolNetworkTool)
|
||||
{
|
||||
final CompoundNBT c = is.getTag();
|
||||
if( c != null && c.getBoolean( "hideFacades" ) )
|
||||
{
|
||||
return CableRenderMode.CABLE_VIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile;
|
||||
|
||||
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.util.ICommonTile;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
@@ -28,6 +29,9 @@ import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -47,6 +51,7 @@ import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -293,8 +298,14 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
// TODO: Optimize Network Load
|
||||
if( this.world != null )
|
||||
{
|
||||
AELog.blockUpdate( this.pos, this );
|
||||
this.world.notifyBlockUpdate( this.pos, this.getBlockState(), this.getBlockState(), 3 );
|
||||
// Let the block update
|
||||
BlockState currentState = getBlockState();
|
||||
BlockState newState = currentState.updatePostPlacement(Direction.EAST, currentState, world, pos, pos);
|
||||
|
||||
AELog.blockUpdate( this.pos, currentState, newState, this );
|
||||
if (currentState != newState) {
|
||||
this.world.setBlockState(pos, newState);
|
||||
}
|
||||
this.requestModelDataUpdate();
|
||||
}
|
||||
}
|
||||
@@ -357,27 +368,27 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
cm.readFromNBT( compound );
|
||||
}
|
||||
}
|
||||
// FIXME
|
||||
// if( this instanceof IPriorityHost )
|
||||
// {
|
||||
// final IPriorityHost pHost = (IPriorityHost) this;
|
||||
// pHost.setPriority( compound.getInt( "priority" ) );
|
||||
// }
|
||||
//
|
||||
// if( this instanceof ISegmentedInventory )
|
||||
// {
|
||||
// final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
|
||||
// if( inv instanceof AppEngInternalAEInventory )
|
||||
// {
|
||||
// final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
|
||||
// final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSlots() );
|
||||
// tmp.readFromNBT( compound, "config" );
|
||||
// for( int x = 0; x < tmp.getSlots(); x++ )
|
||||
// {
|
||||
// target.setStackInSlot( x, tmp.getStackInSlot( x ) );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if( this instanceof IPriorityHost )
|
||||
{
|
||||
final IPriorityHost pHost = (IPriorityHost) this;
|
||||
pHost.setPriority( compound.getInt( "priority" ) );
|
||||
}
|
||||
|
||||
if( this instanceof ISegmentedInventory )
|
||||
{
|
||||
final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
|
||||
if( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
|
||||
final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSlots() );
|
||||
tmp.readFromNBT( compound, "config" );
|
||||
for( int x = 0; x < tmp.getSlots(); x++ )
|
||||
{
|
||||
target.setStackInSlot( x, tmp.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,21 +436,20 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// if( this instanceof IPriorityHost )
|
||||
// {
|
||||
// final IPriorityHost pHost = (IPriorityHost) this;
|
||||
// output.putInt( "priority", pHost.getPriority() );
|
||||
// }
|
||||
//
|
||||
// if( this instanceof ISegmentedInventory )
|
||||
// {
|
||||
// final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
|
||||
// if( inv instanceof AppEngInternalAEInventory )
|
||||
// {
|
||||
// ( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" );
|
||||
// }
|
||||
// }
|
||||
if( this instanceof IPriorityHost)
|
||||
{
|
||||
final IPriorityHost pHost = (IPriorityHost) this;
|
||||
output.putInt( "priority", pHost.getPriority() );
|
||||
}
|
||||
|
||||
if( this instanceof ISegmentedInventory)
|
||||
{
|
||||
final IItemHandler inv = ( (ISegmentedInventory) this ).getInventoryByName( "config" );
|
||||
if( inv instanceof AppEngInternalAEInventory)
|
||||
{
|
||||
( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" );
|
||||
}
|
||||
}
|
||||
|
||||
return output.isEmpty() ? null : output;
|
||||
}
|
||||
@@ -482,7 +492,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
this.world.markChunkDirty( this.pos, this );
|
||||
if( !this.markDirtyQueued )
|
||||
{
|
||||
// FIXME TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick );
|
||||
TickHandler.INSTANCE.addCallable( null, this::markDirtyAtEndOfTick );
|
||||
this.markDirtyQueued = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public boolean isFormed()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.FORMED );
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return this.world.getBlockState( this.pos ).get( AbstractCraftingUnitBlock.POWERED );
|
||||
}
|
||||
|
||||
@@ -476,16 +476,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
|
||||
this.ejectHeldItems();
|
||||
|
||||
try
|
||||
{
|
||||
final TargetPoint where = new TargetPoint( this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32, this.world.getDimension().getType() );
|
||||
final IAEItemStack item = AEItemStack.fromItemStack( output );
|
||||
NetworkHandler.instance().sendToAllAround( new PacketAssemblerAnimation( this.pos, (byte) speed, item ), where );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
// ;P
|
||||
}
|
||||
final TargetPoint where = new TargetPoint( this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32, this.world.getDimension().getType() );
|
||||
final IAEItemStack item = AEItemStack.fromItemStack( output );
|
||||
NetworkHandler.instance().sendToAllAround( new PacketAssemblerAnimation( this.pos, (byte) speed, item ), where );
|
||||
|
||||
this.saveChanges();
|
||||
this.updateSleepiness();
|
||||
|
||||
@@ -96,7 +96,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
|
||||
|
||||
public void setSide( final Direction facing )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return this.isPowered() && ( CHANNEL_FLAG == ( this.getClientFlags() & CHANNEL_FLAG ) );
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return ( this.constructed & this.powered ) == this.powered && this.constructed != -1;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,12 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.storage.BlockChest;
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.core.Api;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -37,6 +40,7 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
@@ -139,7 +143,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
this.setInternalPowerFlow( AccessRestriction.WRITE );
|
||||
|
||||
this.inputInventory.setFilter( new InputInventoryFilter() );
|
||||
this.cellInventory.setFilter( new CellInventoryFilter() );
|
||||
this.cellInventory.setFilter(new CellInventoryFilter());
|
||||
}
|
||||
|
||||
public ItemStack getCell()
|
||||
@@ -272,7 +276,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
@Override
|
||||
public int getCellStatus( final int slot )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return ( this.state >> ( slot * 3 ) ) & 3;
|
||||
}
|
||||
@@ -293,7 +297,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return ( this.state & 0x40 ) == 0x40;
|
||||
}
|
||||
@@ -923,7 +927,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
private class CellInventoryFilter implements IAEItemFilter
|
||||
private static class CellInventoryFilter implements IAEItemFilter
|
||||
{
|
||||
|
||||
@Override
|
||||
|
||||
@@ -168,7 +168,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
if( isRemote() )
|
||||
{
|
||||
return ( this.state & BIT_POWER_MASK ) == BIT_POWER_MASK;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ public class Platform
|
||||
*/
|
||||
public static boolean isClient()
|
||||
{
|
||||
return Thread.currentThread().getThreadGroup() == SidedThreadGroups.CLIENT;
|
||||
return Thread.currentThread().getThreadGroup() != SidedThreadGroups.SERVER;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -137,10 +138,10 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
||||
public void writeToPacket( final PacketBuffer i )
|
||||
{
|
||||
final byte mask = (byte) ( ( this.getType( this.getStackSize() ) << 2 ) | ( this
|
||||
.getType( this.getCountRequestable() ) << 4 ) | ( (byte) ( this.isCraftable() ? 1 : 0 ) << 6 ) | ( this.hasTagCompound() ? 1 : 0 ) << 7 );
|
||||
.getType( this.getCountRequestable() ) << 4 ) | ( (byte) ( this.isCraftable() ? 1 : 0 ) << 6 ) );
|
||||
|
||||
i.writeByte( mask );
|
||||
i.writeCompoundTag( this.getDefinition().serializeNBT() );
|
||||
i.writeItemStack(getDefinition());
|
||||
this.putPacketValue( i, this.getStackSize() );
|
||||
this.putPacketValue( i, this.getCountRequestable() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user