All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.
This commit is contained in:
@@ -18,8 +18,12 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.StateContainer;
|
||||
@@ -83,7 +87,7 @@ public abstract class AbstractCraftingUnitBlock<T extends TileCraftingTile> exte
|
||||
{
|
||||
if ( !w.isRemote() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CRAFTING_CPU );
|
||||
ContainerOpener.openContainer(ContainerCraftingCPU.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
|
||||
@@ -20,6 +20,10 @@ package appeng.block.crafting;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -69,7 +73,7 @@ public class BlockMolecularAssembler extends AEBaseTileBlock<TileMolecularAssemb
|
||||
if( tg != null && !p.isCrouching() )
|
||||
{
|
||||
if (!tg.isRemote()) {
|
||||
// FIXME Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_MAC);
|
||||
ContainerOpener.openContainer(ContainerMAC.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ package appeng.block.grindstone;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -48,7 +50,7 @@ public class BlockGrinder extends AEBaseTileBlock<TileGrinder>
|
||||
if( tg != null && !p.isCrouching() )
|
||||
{
|
||||
if (p instanceof ServerPlayerEntity) {
|
||||
ContainerGrinder.open((ServerPlayerEntity) p, tg, getNameTextComponent());
|
||||
ContainerOpener.openContainer(ContainerGrinder.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ package appeng.block.misc;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,7 +32,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
@@ -58,7 +59,7 @@ public class BlockCellWorkbench extends AEBaseTileBlock<TileCellWorkbench>
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit.getFace()), GuiBridge.GUI_CELL_WORKBENCH );
|
||||
ContainerCellWorkbench.open(p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ package appeng.block.misc;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -58,7 +62,7 @@ public class BlockCondenser extends AEBaseTileBlock<TileCondenser>
|
||||
final TileCondenser tc = this.getTileEntity( w, pos );
|
||||
if( tc != null && !player.isCrouching() )
|
||||
{
|
||||
// FIXME Platform.openGUI( player, tc, AEPartLocation.fromFacing(hit), GuiBridge.GUI_CONDENSER );
|
||||
ContainerOpener.openContainer(ContainerCondenser.TYPE, player, ContainerLocator.forTileEntitySide(tc, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ package appeng.block.misc;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -50,7 +55,7 @@ public class BlockInscriber extends AEBaseTileBlock<TileInscriber> {
|
||||
final TileInscriber tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (!tg.isRemote()) {
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit.getFace()), GuiBridge.GUI_INSCRIBER );
|
||||
ContainerOpener.openContainer(ContainerInscriber.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ package appeng.block.misc;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -83,7 +87,7 @@ public class BlockInterface extends AEBaseTileBlock<TileInterface>
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_INTERFACE );
|
||||
ContainerOpener.openContainer(ContainerInterface.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ package appeng.block.misc;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.container.implementations.ContainerSecurityStation;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
@@ -92,7 +96,7 @@ public class BlockSecurityStation extends AEBaseTileBlock<TileSecurityStation>
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_SECURITY );
|
||||
ContainerOpener.openContainer(ContainerSecurityStation.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
|
||||
@@ -20,6 +20,10 @@ package appeng.block.misc;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
@@ -85,7 +89,7 @@ public final class BlockVibrationChamber extends AEBaseTileBlock<TileVibrationCh
|
||||
final TileVibrationChamber tc = this.getTileEntity( w, pos );
|
||||
if( tc != null && !player.isCrouching() )
|
||||
{
|
||||
// FIXME Platform.openGUI( player, tc, AEPartLocation.fromFacing(hit), GuiBridge.GUI_VIBRATION_CHAMBER );
|
||||
ContainerOpener.openContainer(ContainerVibrationChamber.TYPE, player, ContainerLocator.forTileEntitySide(tc, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
@@ -104,7 +107,7 @@ public class BlockWireless extends AEBaseTileBlock<TileWireless>
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// FIXME Platform.openGUI( player, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_WIRELESS );
|
||||
ContainerOpener.openContainer(ContainerWireless.TYPE, player, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
|
||||
class PaintModel implements IModel
|
||||
{
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return PaintBakedModel.getRequiredTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
return new PaintBakedModel( format, bakedTextureGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
}
|
||||
+28
-32
@@ -5,26 +5,31 @@ package appeng.block.paint;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.Splotch;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,20 +37,17 @@ import appeng.helpers.Splotch;
|
||||
* a
|
||||
* matter cannon with paint balls.
|
||||
*/
|
||||
class PaintBakedModel implements IBakedModel
|
||||
class PaintSplotchesBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
|
||||
private static final ResourceLocation TEXTURE_PAINT1 = new ResourceLocation( AppEng.MOD_ID, "blocks/paint1" );
|
||||
private static final ResourceLocation TEXTURE_PAINT2 = new ResourceLocation( AppEng.MOD_ID, "blocks/paint2" );
|
||||
private static final ResourceLocation TEXTURE_PAINT3 = new ResourceLocation( AppEng.MOD_ID, "blocks/paint3" );
|
||||
|
||||
private final VertexFormat vertexFormat;
|
||||
private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "blocks/paint1" ));
|
||||
private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "blocks/paint2" ));
|
||||
private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "blocks/paint3" ));
|
||||
|
||||
private final TextureAtlasSprite[] textures;
|
||||
|
||||
PaintBakedModel( VertexFormat vertexFormat, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
PaintSplotchesBakedModel(Function<Material, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
this.vertexFormat = vertexFormat;
|
||||
this.textures = new TextureAtlasSprite[] {
|
||||
bakedTextureGetter.apply( TEXTURE_PAINT1 ),
|
||||
bakedTextureGetter.apply( TEXTURE_PAINT2 ),
|
||||
@@ -53,35 +55,30 @@ class PaintBakedModel implements IBakedModel
|
||||
};
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
{
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
|
||||
if( side != null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if( !( state instanceof IExtendedBlockState ) )
|
||||
PaintSplotches splotchesState = extraData.getData(TilePaint.SPLOTCHES);
|
||||
|
||||
if( splotchesState == null )
|
||||
{
|
||||
// This is the inventory model which should usually not be used other than in special cases
|
||||
List<BakedQuad> quads = new ArrayList<>( 1 );
|
||||
CubeBuilder builder = new CubeBuilder( this.vertexFormat, quads );
|
||||
CubeBuilder builder = new CubeBuilder( quads );
|
||||
builder.setTexture( this.textures[0] );
|
||||
builder.addCube( 0, 0, 0, 16, 16, 16 );
|
||||
return quads;
|
||||
}
|
||||
|
||||
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
|
||||
PaintSplotches splotchesState = extendedBlockState.getValue( BlockPaint.SPLOTCHES );
|
||||
|
||||
if( splotchesState == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Splotch> splotches = splotchesState.getSplotches();
|
||||
|
||||
CubeBuilder builder = new CubeBuilder( this.vertexFormat );
|
||||
CubeBuilder builder = new CubeBuilder( );
|
||||
|
||||
float offsetConstant = 0.001f;
|
||||
for( final Splotch s : splotches )
|
||||
@@ -179,19 +176,18 @@ class PaintBakedModel implements IBakedModel
|
||||
return this.textures[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return ItemOverrideList.EMPTY;
|
||||
}
|
||||
|
||||
static List<ResourceLocation> getRequiredTextures()
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static List<Material> getRequiredTextures()
|
||||
{
|
||||
return ImmutableList.of(
|
||||
TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3 );
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel>
|
||||
{
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
return new PaintSplotchesBakedModel( spriteGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return PaintSplotchesBakedModel.getRequiredTextures();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,9 @@ import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -94,7 +97,7 @@ public class BlockQuantumLinkChamber extends BlockQuantumBase
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_QNB );
|
||||
ContainerOpener.openContainer(ContainerQNB.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2,41 +2,37 @@
|
||||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
class QnbFormedBakedModel implements IBakedModel
|
||||
class QnbFormedBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
|
||||
private static final ResourceLocation TEXTURE_LINK = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_link" );
|
||||
private static final ResourceLocation TEXTURE_RING = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring" );
|
||||
private static final ResourceLocation TEXTURE_RING_LIGHT = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring_light" );
|
||||
private static final ResourceLocation TEXTURE_RING_LIGHT_CORNER = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring_light_corner" );
|
||||
private static final ResourceLocation TEXTURE_CABLE_GLASS = new ResourceLocation( AppEng.MOD_ID, "parts/cable/glass/transparent" );
|
||||
private static final ResourceLocation TEXTURE_COVERED_CABLE = new ResourceLocation( AppEng.MOD_ID, "parts/cable/covered/transparent" );
|
||||
private static final Material TEXTURE_LINK = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "blocks/quantum_link" ));
|
||||
private static final Material TEXTURE_RING = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring" ));
|
||||
private static final Material TEXTURE_RING_LIGHT = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring_light" ));
|
||||
private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring_light_corner" ));
|
||||
private static final Material TEXTURE_CABLE_GLASS = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/cable/glass/transparent" ));
|
||||
private static final Material TEXTURE_COVERED_CABLE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/cable/covered/transparent" ));
|
||||
|
||||
private static final float DEFAULT_RENDER_MIN = 2.0f;
|
||||
private static final float DEFAULT_RENDER_MAX = 14.0f;
|
||||
@@ -47,8 +43,6 @@ class QnbFormedBakedModel implements IBakedModel
|
||||
private static final float CENTER_POWERED_RENDER_MIN = -0.01f;
|
||||
private static final float CENTER_POWERED_RENDER_MAX = 16.01f;
|
||||
|
||||
private final VertexFormat vertexFormat;
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final Block linkBlock;
|
||||
@@ -60,9 +54,8 @@ class QnbFormedBakedModel implements IBakedModel
|
||||
private final TextureAtlasSprite lightTexture;
|
||||
private final TextureAtlasSprite lightCornerTexture;
|
||||
|
||||
public QnbFormedBakedModel( VertexFormat vertexFormat, IBakedModel baseModel, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
public QnbFormedBakedModel( IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
this.vertexFormat = vertexFormat;
|
||||
this.baseModel = baseModel;
|
||||
this.linkTexture = bakedTextureGetter.apply( TEXTURE_LINK );
|
||||
this.ringTexture = bakedTextureGetter.apply( TEXTURE_RING );
|
||||
@@ -74,23 +67,25 @@ class QnbFormedBakedModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
// Get the correct base model
|
||||
if( !( state instanceof IExtendedBlockState ) )
|
||||
QnbFormedState formedState = modelData.getData(TileQuantumBridge.FORMED_STATE);
|
||||
|
||||
if( formedState == null )
|
||||
{
|
||||
return this.baseModel.getQuads( state, side, rand );
|
||||
}
|
||||
|
||||
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
|
||||
QnbFormedState formedState = extendedBlockState.getValue( BlockQuantumBase.FORMED_STATE );
|
||||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.getQuads( formedState, state, side, rand );
|
||||
return this.getQuads( formedState, state );
|
||||
}
|
||||
|
||||
private List<BakedQuad> getQuads( QnbFormedState formedState, BlockState state, Direction side, long rand )
|
||||
private List<BakedQuad> getQuads( QnbFormedState formedState, BlockState state )
|
||||
{
|
||||
CubeBuilder builder = new CubeBuilder( this.vertexFormat );
|
||||
CubeBuilder builder = new CubeBuilder( );
|
||||
|
||||
if( state.getBlock() == this.linkBlock )
|
||||
{
|
||||
@@ -212,6 +207,11 @@ class QnbFormedBakedModel implements IBakedModel
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
@@ -224,19 +224,13 @@ class QnbFormedBakedModel implements IBakedModel
|
||||
return this.baseModel.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return this.baseModel.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return this.baseModel.getOverrides();
|
||||
}
|
||||
|
||||
public static List<ResourceLocation> getRequiredTextures()
|
||||
public static List<Material> getRequiredTextures()
|
||||
{
|
||||
return ImmutableList.of(
|
||||
TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE, TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER );
|
||||
|
||||
@@ -2,63 +2,33 @@
|
||||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
public class QnbFormedModel implements IModel
|
||||
public class QnbFormedModel implements IModelGeometry<QnbFormedModel>
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_RING = new ResourceLocation( AppEng.MOD_ID, "block/qnb/ring" );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return ImmutableList.of( MODEL_RING );
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
|
||||
return new QnbFormedBakedModel( ringModel, spriteGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return QnbFormedBakedModel.getRequiredTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
IBakedModel ringModel = this.getBaseModel( MODEL_RING, state, format, bakedTextureGetter );
|
||||
return new QnbFormedBakedModel( format, ringModel, bakedTextureGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
private IBakedModel getBaseModel( ResourceLocation model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
// Load the base model
|
||||
try
|
||||
{
|
||||
return ModelLoaderRegistry.getModel( model ).bake( state, format, bakedTextureGetter );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ package appeng.block.spatial;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -70,7 +74,7 @@ public class BlockSpatialIOPort extends AEBaseTileBlock<TileSpatialIOPort>
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_SPATIAL_IO_PORT );
|
||||
ContainerOpener.openContainer(ContainerSpatialIOPort.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.util.Platform;
|
||||
@@ -94,7 +98,7 @@ public class BlockChest extends AEBaseTileBlock<TileChest>
|
||||
|
||||
if( hit.getFace() != tg.getUp() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_CHEST );
|
||||
ContainerOpener.openContainer(ContainerChest.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,6 +20,10 @@ package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -55,7 +59,7 @@ public class BlockDrive extends AEBaseTileBlock<TileDrive>
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_DRIVE );
|
||||
ContainerOpener.openContainer(ContainerDrive.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -67,7 +71,7 @@ public class BlockIOPort extends AEBaseTileBlock<TileIOPort>
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// FIXME Platform.openGUI( p, tg, AEPartLocation.fromFacing(hit), GuiBridge.GUI_IOPORT );
|
||||
ContainerOpener.openContainer(ContainerIOPort.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
@@ -83,7 +85,7 @@ public class BlockSkyChest extends AEBaseTileBlock<TileSkyChest>
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
ContainerSkyChest.open((ServerPlayerEntity) player, tile, getNameTextComponent());
|
||||
ContainerOpener.openContainer(ContainerSkyChest.TYPE, player, ContainerLocator.forTileEntity(tile));
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
|
||||
@@ -22,6 +22,11 @@ package appeng.client;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import appeng.client.render.effects.*;
|
||||
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;
|
||||
@@ -49,6 +54,7 @@ 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
|
||||
@@ -115,34 +121,35 @@ public class ClientHelper extends ServerHelper
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Instead of doing a custom packet and this dispatcher, we can use the vanilla particle system
|
||||
@Override
|
||||
public void spawnEffect( final EffectType effect, final World world, final double posX, final double posY, final double posZ, final Object o )
|
||||
{
|
||||
// FIXME if( AEConfig.instance().isEnableEffects() )
|
||||
// FIXME {
|
||||
// FIXME switch( effect )
|
||||
// FIXME {
|
||||
// FIXME case Assembler:
|
||||
// FIXME this.spawnAssembler( world, posX, posY, posZ, o );
|
||||
// FIXME return;
|
||||
// FIXME case Vibrant:
|
||||
// FIXME this.spawnVibrant( world, posX, posY, posZ );
|
||||
// FIXME return;
|
||||
// FIXME case Crafting:
|
||||
// FIXME this.spawnCrafting( world, posX, posY, posZ );
|
||||
// FIXME return;
|
||||
// FIXME case Energy:
|
||||
// FIXME this.spawnEnergy( world, posX, posY, posZ );
|
||||
// FIXME return;
|
||||
// FIXME case Lightning:
|
||||
// FIXME this.spawnLightning( world, posX, posY, posZ );
|
||||
// FIXME return;
|
||||
// FIXME case LightningArc:
|
||||
// FIXME this.spawnLightningArc( world, posX, posY, posZ, (Vec3d) o );
|
||||
// FIXME return;
|
||||
// FIXME default:
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
if( AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
switch( effect )
|
||||
{
|
||||
case Assembler:
|
||||
this.spawnAssembler( world, posX, posY, posZ, o );
|
||||
return;
|
||||
case Vibrant:
|
||||
this.spawnVibrant( world, posX, posY, posZ );
|
||||
return;
|
||||
case Crafting:
|
||||
this.spawnCrafting( world, posX, posY, posZ );
|
||||
return;
|
||||
case Energy:
|
||||
this.spawnEnergy( world, posX, posY, posZ );
|
||||
return;
|
||||
case Lightning:
|
||||
this.spawnLightning( world, posX, posY, posZ );
|
||||
return;
|
||||
case LightningArc:
|
||||
this.spawnLightningArc( world, posX, posY, posZ, (Vec3d) o );
|
||||
return;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,12 +225,13 @@ public class ClientHelper extends ServerHelper
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
// FIXME: double check all of these particle spawns, also move any of these that are triggered as part of a packet to the vanilla way of spawning particles from the server directly
|
||||
private void spawnAssembler( final World world, final double posX, final double posY, final double posZ, final Object o )
|
||||
{
|
||||
// FIXME final PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o;
|
||||
final PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o;
|
||||
|
||||
// FIXME final AssemblerFX fx = new AssemblerFX( world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is );
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
final AssemblerFX fx = new AssemblerFX( world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is.asItemStackRepresentation() );
|
||||
Minecraft.getInstance().particles.addEffect( fx );
|
||||
}
|
||||
|
||||
private void spawnVibrant( final World w, final double x, final double y, final double z )
|
||||
@@ -234,8 +242,7 @@ public class ClientHelper extends ServerHelper
|
||||
final double d1 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D;
|
||||
final double d2 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D;
|
||||
|
||||
// FIXME final VibrantFX fx = new VibrantFX( w, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D );
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
Minecraft.getInstance().particles.addParticle(VibrantFX.TYPE, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,13 +252,7 @@ public class ClientHelper extends ServerHelper
|
||||
final float y = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
|
||||
final float z = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
|
||||
|
||||
// FIXME final CraftingFx fx = new CraftingFx( w, posX + x, posY + y, posZ + z, Items.DIAMOND );
|
||||
|
||||
// FIXME fx.setMotionX( -x * 0.2f );
|
||||
// FIXME fx.setMotionY( -y * 0.2f );
|
||||
// FIXME fx.setMotionZ( -z * 0.2f );
|
||||
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
Minecraft.getInstance().particles.addParticle(CraftingFx.TYPE, posX + x, posY + y, posZ + z, -x * 0.2, -y * 0.2, -z * 0.2);
|
||||
}
|
||||
|
||||
private void spawnEnergy( final World w, final double posX, final double posY, final double posZ )
|
||||
@@ -260,25 +261,18 @@ public class ClientHelper extends ServerHelper
|
||||
final float y = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
|
||||
final float z = (float) ( ( ( Platform.getRandomInt() % 100 ) * 0.01 ) - 0.5 ) * 0.7f;
|
||||
|
||||
// FIXME final EnergyFx fx = new EnergyFx( w, posX + x, posY + y, posZ + z, Items.DIAMOND );
|
||||
|
||||
// FIXME fx.setMotionX( -x * 0.1f );
|
||||
// FIXME fx.setMotionY( -y * 0.1f );
|
||||
// FIXME fx.setMotionZ( -z * 0.1f );
|
||||
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, posX + x, posY + y, posZ + z, -x * 0.1, -y * 0.1, -z * 0.1);
|
||||
}
|
||||
|
||||
private void spawnLightning( final World world, final double posX, final double posY, final double posZ )
|
||||
{
|
||||
// FIXME final LightningFX fx = new LightningFX( world, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
private void spawnLightningArc( final World world, final double posX, final double posY, final double posZ, final Vec3d second )
|
||||
{
|
||||
// FIXME final LightningFX fx = new LightningArcFX( world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f, 0.0f );
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
final LightningFX fx = new LightningArcFX( world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getInstance().particles.addEffect( fx );
|
||||
}
|
||||
|
||||
private void wheelEvent( final InputEvent.MouseScrollEvent me )
|
||||
@@ -297,26 +291,12 @@ public class ClientHelper extends ServerHelper
|
||||
|
||||
if( mainHand || offHand )
|
||||
{
|
||||
// FIXME try
|
||||
// FIXME {
|
||||
// FIXME NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getScrollDelta() > 0 ? "WheelUp" : "WheelDown" ) );
|
||||
// FIXME me.setCanceled( true );
|
||||
// FIXME }
|
||||
// FIXME catch( final IOException e )
|
||||
// FIXME {
|
||||
// FIXME AELog.debug( e );
|
||||
// FIXME }
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getScrollDelta() > 0 ? "WheelUp" : "WheelDown" ) );
|
||||
me.setCanceled( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTextureStitch( final TextureStitchEvent.Pre event )
|
||||
{
|
||||
// FIXME ParticleTextures.registerSprite( event );
|
||||
// FIXME InscriberTESR.registerTexture( event );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionKey( ActionKey key, InputMappings.Input pressedKey )
|
||||
{
|
||||
|
||||
@@ -68,7 +68,6 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
@@ -266,7 +265,7 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
final int ox = this.guiLeft; // (width - xSize) / 2;
|
||||
final int oy = this.guiTop; // (height - ySize) / 2;
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
this.drawBG( ox, oy, x, y );
|
||||
this.drawBG( ox, oy, x, y, f );
|
||||
|
||||
final List<Slot> slots = this.getInventorySlots();
|
||||
for( final Slot slot : slots )
|
||||
@@ -655,7 +654,7 @@ public abstract class AEBaseGui<T extends AEBaseContainer> extends ContainerScre
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void drawBG( int offsetX, int offsetY, int mouseX, int mouseY );
|
||||
public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks);
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double x, double y, double wheelDelta) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class AEBaseMEGui<T extends AEBaseContainer> extends AEBaseGui<T
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderToolTip( final ItemStack stack, final int x, final int y )
|
||||
protected void renderTooltip( final ItemStack stack, final int x, final int y )
|
||||
{
|
||||
final Slot s = this.getSlot( x, y );
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class AEBaseMEGui<T extends AEBaseContainer> extends AEBaseGui<T
|
||||
final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
final List<String> currentToolTip = this.getItemToolTip( stack );
|
||||
final List<String> currentToolTip = this.getTooltipFromItem( stack );
|
||||
|
||||
try
|
||||
{
|
||||
@@ -67,7 +67,7 @@ public abstract class AEBaseMEGui<T extends AEBaseContainer> extends AEBaseGui<T
|
||||
|
||||
if( myStack != null )
|
||||
{
|
||||
if( myStack.getStackSize() > bigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
|
||||
if( myStack.getStackSize() > bigNumber || ( myStack.getStackSize() > 1 && stack.isDamaged() ) )
|
||||
{
|
||||
final String local = ButtonToolTips.ItemsStored.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() );
|
||||
@@ -84,8 +84,7 @@ public abstract class AEBaseMEGui<T extends AEBaseContainer> extends AEBaseGui<T
|
||||
|
||||
currentToolTip.add( format );
|
||||
}
|
||||
|
||||
this.drawHoveringText( currentToolTip, x, y, this.font );
|
||||
this.renderTooltip( currentToolTip, x, y, this.font );
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -97,12 +96,12 @@ public abstract class AEBaseMEGui<T extends AEBaseContainer> extends AEBaseGui<T
|
||||
|
||||
currentToolTip.add( TextFormatting.GRAY + format );
|
||||
|
||||
this.drawHoveringText( currentToolTip, x, y, this.font );
|
||||
this.renderTooltip( currentToolTip, x, y, this.font );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.renderToolTip( stack, x, y );
|
||||
super.renderTooltip( stack, x, y );
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui;
|
||||
|
||||
|
||||
import net.minecraft.inventory.container.Container;
|
||||
|
||||
|
||||
public class GuiNull extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiNull( final Container container )
|
||||
{
|
||||
super( container );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.config;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
public class AEConfigGui extends GuiConfig
|
||||
{
|
||||
|
||||
public AEConfigGui( final Screen parent )
|
||||
{
|
||||
super( parent, getConfigElements(), AppEng.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance().getFilePath() ) );
|
||||
}
|
||||
|
||||
private static List<IConfigElement> getConfigElements()
|
||||
{
|
||||
final List<IConfigElement> list = new ArrayList<>();
|
||||
|
||||
for( final String cat : AEConfig.instance().getCategoryNames() )
|
||||
{
|
||||
if( cat.equals( "versionchecker" ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( cat.equals( "settings" ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final ConfigCategory cc = AEConfig.instance().getCategory( cat );
|
||||
|
||||
if( cc.isChild() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final ConfigElement ce = new ConfigElement( cc );
|
||||
list.add( ce );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.config;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
|
||||
|
||||
public class AEConfigGuiFactory implements IModGuiFactory
|
||||
{
|
||||
|
||||
@Override
|
||||
public void initialize( final Minecraft minecraftInstance )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If this method returns false, the config button in the mod list will be disabled
|
||||
*
|
||||
* @return true if this object provides a config gui screen, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean hasConfigGui()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an initialized {@link Screen}. This screen will be displayed
|
||||
* when the "config" button is pressed in the mod list. It will
|
||||
* have a single argument constructor - the "parent" screen, the same as all
|
||||
* Minecraft GUIs. The expected behaviour is that this screen will replace the
|
||||
* "mod list" screen completely, and will return to the mod list screen through
|
||||
* the parent link, once the appropriate action is taken from the config screen.
|
||||
* <p>
|
||||
* This config GUI is anticipated to provide configuration to the mod in a friendly
|
||||
* visual way. It should not be abused to set internals such as IDs (they're gonna
|
||||
* keep disappearing anyway), but rather, interesting behaviours. This config GUI
|
||||
* is never run when a server game is running, and should be used to configure
|
||||
* desired behaviours that affect server state. Costs, mod game modes, stuff like that
|
||||
* can be changed here.
|
||||
*
|
||||
* @param parentScreen The screen to which must be returned when closing the
|
||||
* returned screen.
|
||||
* @return A class that will be instantiated on clicks on the config button
|
||||
* or null if no GUI is desired.
|
||||
*/
|
||||
@Override
|
||||
public Screen createConfigGui(Screen parentScreen )
|
||||
{
|
||||
return new AEConfigGui( parentScreen );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerWirelessTerm;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
final class AESubGui {
|
||||
|
||||
private final AEBaseGui<?> gui;
|
||||
private final ContainerType<?> originalGui;
|
||||
private final ItemStack originalGuiIcon;
|
||||
|
||||
/**
|
||||
* Based on the container we're opening for, try to determine what it's "primary" GUI would be
|
||||
* so that we can go back to it.
|
||||
*/
|
||||
public AESubGui(AEBaseGui<?> gui, Object containerTarget) {
|
||||
this.gui = gui;
|
||||
|
||||
final IDefinitions definitions = Api.INSTANCE.definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (containerTarget instanceof IPriorityHost) {
|
||||
IPriorityHost priorityHost = (IPriorityHost) containerTarget;
|
||||
this.originalGuiIcon = priorityHost.getItemStackRepresentation();
|
||||
this.originalGui = priorityHost.getContainerType();
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof WirelessTerminalGuiObject)
|
||||
{
|
||||
this.originalGuiIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.originalGui = ContainerWirelessTerm.TYPE;
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof PartTerminal)
|
||||
{
|
||||
this.originalGuiIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.originalGui = ContainerMEMonitorable.TYPE;
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof PartCraftingTerminal)
|
||||
{
|
||||
this.originalGuiIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.originalGui = ContainerCraftingTerm.TYPE;
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof PartPatternTerminal)
|
||||
{
|
||||
this.originalGuiIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.originalGui = ContainerPatternTerm.TYPE;
|
||||
}
|
||||
|
||||
else {
|
||||
this.originalGuiIcon = null;
|
||||
this.originalGui = null;
|
||||
}
|
||||
}
|
||||
|
||||
public final GuiTabButton addBackButton(Consumer<GuiTabButton> buttonAdder, int x, int y) {
|
||||
return addBackButton(buttonAdder, x, y, null);
|
||||
}
|
||||
|
||||
public final GuiTabButton addBackButton(Consumer<GuiTabButton> buttonAdder, int x, int y, @Nullable String label) {
|
||||
if( this.originalGui != null && !originalGuiIcon.isEmpty() )
|
||||
{
|
||||
if (label == null) {
|
||||
label = originalGuiIcon.getDisplayName().getString();
|
||||
}
|
||||
ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer();
|
||||
GuiTabButton button = new GuiTabButton( gui.getGuiLeft() + x, gui.getGuiTop() + y, originalGuiIcon, label, itemRenderer, btn -> goBack() );
|
||||
buttonAdder.accept(button);
|
||||
return button;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void goBack() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.originalGui ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,12 +21,10 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -43,7 +41,6 @@ import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -62,11 +59,11 @@ public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE, this::actionPerformed );
|
||||
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH, this::actionPerformed );
|
||||
this.copyMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc
|
||||
.getLocal() );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
.getLocal(), this::actionPerformed );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
|
||||
|
||||
this.addButton( this.fuzzyMode );
|
||||
this.addButton( this.partition );
|
||||
@@ -75,7 +72,7 @@ public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.handleButtonVisibility();
|
||||
|
||||
@@ -86,7 +83,7 @@ public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
|
||||
if( this.container.availableUpgrades() <= 8 )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + this.container.availableUpgrades() * 18, 0 /* FIXME this.zlevel was used */ );
|
||||
GuiUtilsGuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( this.container.availableUpgrades() ) * 18 ), 177, 151, 35, 7, 0 /* FIXME this.zlevel was used */ );
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( this.container.availableUpgrades() ) * 18 ), 177, 151, 35, 7, 0 /* FIXME this.zlevel was used */ );
|
||||
}
|
||||
else if( this.container.availableUpgrades() <= 16 )
|
||||
{
|
||||
@@ -170,38 +167,32 @@ public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
protected void actionPerformed( final Button btn )
|
||||
{
|
||||
try
|
||||
if( btn == this.copyMode )
|
||||
{
|
||||
if( btn == this.copyMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
|
||||
}
|
||||
else if( btn == this.partition )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
|
||||
}
|
||||
else if( btn == this.clear )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
|
||||
}
|
||||
else if( btn == this.fuzzyMode )
|
||||
{
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
FuzzyMode fz = (FuzzyMode) this.fuzzyMode.getCurrentValue();
|
||||
fz = Platform.rotateEnum( fz, backwards, Settings.FUZZY_MODE.getPossibleValues() );
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
}
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
|
||||
}
|
||||
catch( final IOException ignored )
|
||||
else if( btn == this.partition )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
|
||||
}
|
||||
else if( btn == this.clear )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
|
||||
}
|
||||
else if( btn == this.fuzzyMode )
|
||||
{
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
|
||||
FuzzyMode fz = (FuzzyMode) this.fuzzyMode.getCurrentValue();
|
||||
fz = Platform.rotateEnum( fz, backwards, Settings.FUZZY_MODE.getPossibleValues() );
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
@@ -31,7 +30,6 @@ import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -46,14 +44,11 @@ public class GuiChest extends AEBaseGui<ContainerChest>
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton par1GuiButton ) throws IOException
|
||||
protected void actionPerformed( final Button button )
|
||||
{
|
||||
super.actionPerformed( par1GuiButton );
|
||||
|
||||
if( par1GuiButton == this.priority )
|
||||
if( button == this.priority )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +57,7 @@ public class GuiChest extends AEBaseGui<ContainerChest>
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.addButton( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
|
||||
this.addButton( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, this::actionPerformed ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +68,7 @@ public class GuiChest extends AEBaseGui<ContainerChest>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/chest.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -19,13 +19,9 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
@@ -37,7 +33,6 @@ import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
|
||||
|
||||
public class GuiCondenser extends AEBaseGui<ContainerCondenser>
|
||||
@@ -51,19 +46,6 @@ public class GuiCondenser extends AEBaseGui<ContainerCondenser>
|
||||
this.ySize = 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( this.mode == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
@@ -72,7 +54,10 @@ public class GuiCondenser extends AEBaseGui<ContainerCondenser>
|
||||
this.pb = new GuiProgressBar( this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy
|
||||
.getLocal() );
|
||||
|
||||
this.mode = new GuiImgButton( 128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.container.getOutput() );
|
||||
this.mode = new GuiImgButton( 128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.container.getOutput(), btn -> {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
|
||||
} );
|
||||
|
||||
this.addButton( this.pb );
|
||||
this.addButton( this.mode );
|
||||
@@ -89,7 +74,7 @@ public class GuiCondenser extends AEBaseGui<ContainerCondenser>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/condenser.png" );
|
||||
|
||||
|
||||
@@ -19,56 +19,31 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount>
|
||||
{
|
||||
private final AESubGui subGui;
|
||||
|
||||
private GuiNumberBox amountToCraft;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
|
||||
private GuiButton next;
|
||||
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
private GuiButton plus1000;
|
||||
private GuiButton minus1;
|
||||
private GuiButton minus10;
|
||||
private GuiButton minus100;
|
||||
private GuiButton minus1000;
|
||||
|
||||
private GuiBridge originalGui;
|
||||
private Button next;
|
||||
|
||||
public GuiCraftAmount(ContainerCraftAmount container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,52 +56,19 @@ public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount>
|
||||
final int c = AEConfig.instance().craftItemsByStackAmounts( 2 );
|
||||
final int d = AEConfig.instance().craftItemsByStackAmounts( 3 );
|
||||
|
||||
this.addButton( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
|
||||
this.addButton( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
|
||||
this.addButton( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
|
||||
this.addButton( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a, btn -> addQty(a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b, btn -> addQty(b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c, btn -> addQty(c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d, btn -> addQty(d) ) );
|
||||
|
||||
this.addButton( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
|
||||
this.addButton( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
|
||||
this.addButton( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
|
||||
this.addButton( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a, btn -> addQty(-a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b, btn -> addQty(-b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c, btn -> addQty(-c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d, btn -> addQty(-d) ) );
|
||||
|
||||
this.addButton( this.next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
|
||||
this.next = this.addButton(new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal(), this::confirm ));
|
||||
|
||||
ItemStack myIcon = null;
|
||||
final Object target = this.container.getTarget();
|
||||
final IDefinitions definitions = Api.INSTANCE.definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( myIcon );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if( target instanceof PartTerminal )
|
||||
{
|
||||
myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if( target instanceof PartPatternTerminal )
|
||||
{
|
||||
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if( this.originalGui != null && !myIcon.isEmpty() )
|
||||
{
|
||||
this.addButton( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) );
|
||||
}
|
||||
subGui.addBackButton(this::addButton, 154, 0);
|
||||
|
||||
this.amountToCraft = new GuiNumberBox( this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, Integer.class );
|
||||
this.amountToCraft.setEnableBackgroundDrawing( false );
|
||||
@@ -137,6 +79,10 @@ public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount>
|
||||
this.amountToCraft.setText( "1" );
|
||||
}
|
||||
|
||||
private void confirm(Button button) {
|
||||
NetworkHandler.instance().sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), hasShiftDown() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
@@ -144,9 +90,9 @@ public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.next.displayString = hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
|
||||
this.next.setMessage(hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal());
|
||||
|
||||
this.bindTexture( "guis/craft_amt.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
@@ -154,27 +100,32 @@ public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount>
|
||||
try
|
||||
{
|
||||
Long.parseLong( this.amountToCraft.getText() );
|
||||
this.next.enabled = !this.amountToCraft.getText().isEmpty();
|
||||
this.next.active = !this.amountToCraft.getText().isEmpty();
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
this.next.enabled = false;
|
||||
this.next.active = false;
|
||||
}
|
||||
|
||||
this.amountToCraft.drawTextBox();
|
||||
this.amountToCraft.render(offsetX, offsetY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
public boolean charTyped(char ch, int p_charTyped_2_) {
|
||||
// Forward entered text to the craft amount text-field
|
||||
return this.amountToCraft.charTyped(ch, p_charTyped_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( key == 28 )
|
||||
if( keyCode == 28 )
|
||||
{
|
||||
this.actionPerformed( this.next );
|
||||
this.next.onPress();
|
||||
}
|
||||
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.amountToCraft
|
||||
.textboxKeyTyped( character, key ) )
|
||||
if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 )
|
||||
&& this.amountToCraft.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -207,45 +158,11 @@ public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount>
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if( btn == this.originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.originalGui ) );
|
||||
}
|
||||
|
||||
if( btn == this.next )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), hasShiftDown() ) );
|
||||
}
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
// nope..
|
||||
this.amountToCraft.setText( "1" );
|
||||
}
|
||||
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
|
||||
|
||||
if( isPlus || isMinus )
|
||||
{
|
||||
this.addQty( this.getQty( btn ) );
|
||||
}
|
||||
return super.keyPressed( keyCode, scanCode, p_keyPressed_3_ );
|
||||
}
|
||||
|
||||
private void addQty( final int i )
|
||||
|
||||
@@ -19,26 +19,6 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
@@ -46,21 +26,32 @@ import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
{
|
||||
|
||||
private final AESubGui subGui;
|
||||
|
||||
private final int rows = 5;
|
||||
|
||||
private final IItemList<IAEItemStack> storage = Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
@@ -69,45 +60,24 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
|
||||
private final List<IAEItemStack> visual = new ArrayList<>();
|
||||
|
||||
private GuiBridge OriginalGui;
|
||||
private GuiButton cancel;
|
||||
private GuiButton start;
|
||||
private GuiButton selectCPU;
|
||||
private Button cancel;
|
||||
private Button start;
|
||||
private Button selectCPU;
|
||||
private int tooltip = -1;
|
||||
|
||||
public GuiCraftConfirm(ContainerCraftConfirm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
this.xSize = 238;
|
||||
this.ySize = 206;
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
|
||||
Object te = container.getTarget();
|
||||
if( te instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if( te instanceof PartTerminal )
|
||||
{
|
||||
this.OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if( te instanceof PartCraftingTerminal )
|
||||
{
|
||||
this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if( te instanceof PartPatternTerminal )
|
||||
{
|
||||
this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAutoStart()
|
||||
{
|
||||
return ( (ContainerCraftConfirm) this.container ).isAutoStart();
|
||||
return this.container.isAutoStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,30 +85,26 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal() );
|
||||
this.start.enabled = false;
|
||||
this.start = new Button(this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal(), btn -> start() );
|
||||
this.start.active = false;
|
||||
this.addButton( this.start );
|
||||
|
||||
this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU
|
||||
.getLocal() + ": " + GuiText.Automatic );
|
||||
this.selectCPU.enabled = false;
|
||||
this.selectCPU = new Button(this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU
|
||||
.getLocal() + ": " + GuiText.Automatic, btn -> selectNextCpu() );
|
||||
this.selectCPU.active = false;
|
||||
this.addButton( this.selectCPU );
|
||||
|
||||
if( this.OriginalGui != null )
|
||||
{
|
||||
this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
|
||||
}
|
||||
subGui.addBackButton(this::addButton, 6, this.ySize - 25, GuiText.Cancel.getLocal());
|
||||
|
||||
this.addButton( this.cancel );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.updateCPUButtonText();
|
||||
|
||||
this.start.enabled = !( this.container.hasNoCPU() || this.isSimulation() );
|
||||
this.selectCPU.enabled = !this.isSimulation();
|
||||
this.start.active = !( this.container.hasNoCPU() || this.isSimulation() );
|
||||
this.selectCPU.active = !this.isSimulation();
|
||||
|
||||
final int gx = ( this.width - this.xSize ) / 2;
|
||||
final int gy = ( this.height - this.ySize ) / 2;
|
||||
@@ -195,12 +161,12 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
}
|
||||
|
||||
this.selectCPU.displayString = btnTextText;
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
private boolean isSimulation()
|
||||
{
|
||||
return ( (ContainerCraftConfirm) this.container ).isSimulation();
|
||||
return this.container.isSimulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,8 +213,8 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
||||
if( refStack != null )
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale( 0.5, 0.5, 0.5 );
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise( refStack );
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
|
||||
@@ -347,7 +313,7 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
|
||||
final int posY = y * offY + yo;
|
||||
|
||||
@@ -355,7 +321,7 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( refStack );
|
||||
dspToolTip = Platform.getItemDisplayName( refStack ).getFormattedText();
|
||||
|
||||
if( lineList.size() > 0 )
|
||||
{
|
||||
@@ -392,7 +358,7 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.setScrollBar();
|
||||
this.bindTexture( "guis/craftingreport.png" );
|
||||
@@ -533,52 +499,25 @@ public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( key == 28 )
|
||||
if( keyCode == 28 )
|
||||
{
|
||||
this.actionPerformed( this.start );
|
||||
this.start();
|
||||
return true;
|
||||
}
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.selectCPU )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
if( btn == this.cancel )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
|
||||
}
|
||||
|
||||
if( btn == this.start )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
|
||||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
private void selectNextCpu() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
|
||||
private void start() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,24 +19,6 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
@@ -50,11 +32,26 @@ import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements ISortSource
|
||||
@@ -89,7 +86,7 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
private IItemList<IAEItemStack> pending = Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
|
||||
private List<IAEItemStack> visual = new ArrayList<>();
|
||||
private GuiButton cancel;
|
||||
private Button cancel;
|
||||
private int tooltip = -1;
|
||||
|
||||
public GuiCraftingCPU(ContainerCraftingCPU container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
@@ -109,22 +106,8 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
this.visual = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if( this.cancel == btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
private void cancel() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,8 +115,8 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
{
|
||||
super.init();
|
||||
this.setScrollBar();
|
||||
this.cancel = new GuiButton( 0, this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel
|
||||
.getLocal() );
|
||||
this.cancel = new Button(this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel
|
||||
.getLocal(), btn -> cancel() );
|
||||
this.addButton( this.cancel );
|
||||
}
|
||||
|
||||
@@ -148,7 +131,7 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.cancel.enabled = !this.visual.isEmpty();
|
||||
this.cancel.active = !this.visual.isEmpty();
|
||||
|
||||
final int gx = ( this.width - this.xSize ) / 2;
|
||||
final int gy = ( this.height - this.ySize ) / 2;
|
||||
@@ -216,8 +199,8 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
||||
if( refStack != null )
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale( 0.5, 0.5, 0.5 );
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise( refStack );
|
||||
final IAEItemStack activeStack = this.active.findPrecise( refStack );
|
||||
@@ -298,7 +281,7 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
|
||||
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
|
||||
@@ -306,7 +289,7 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( refStack );
|
||||
dspToolTip = Platform.getItemDisplayName( refStack ).getFormattedText();
|
||||
|
||||
if( lineList.size() > 0 )
|
||||
{
|
||||
@@ -336,7 +319,7 @@ public class GuiCraftingCPU extends AEBaseGui<ContainerCraftingCPU> implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/craftingcpu.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -23,102 +23,31 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
{
|
||||
|
||||
private GuiButton selectCPU;
|
||||
private final ContainerCraftingStatus craftingStatus;
|
||||
|
||||
private GuiTabButton originalGuiBtn;
|
||||
private GuiBridge originalGui;
|
||||
private ItemStack myIcon = ItemStack.EMPTY;
|
||||
private final AESubGui subGui;
|
||||
|
||||
public GuiCraftingStatus(ContainerCraftingCPU container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
private Button selectCPU;
|
||||
|
||||
public GuiCraftingStatus(ContainerCraftingStatus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
|
||||
final Object target = this.container.getTarget();
|
||||
final IDefinitions definitions = Api.INSTANCE.definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
this.myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if( target instanceof PartTerminal )
|
||||
{
|
||||
this.myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
this.myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if( target instanceof PartPatternTerminal )
|
||||
{
|
||||
this.myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.selectCPU )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
if( btn == this.originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.originalGui ) );
|
||||
}
|
||||
this.craftingStatus = container;
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,17 +55,14 @@ public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.selectCPU = new GuiButton( 0, this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU
|
||||
.getLocal() + ": " + GuiText.NoCraftingCPUs );
|
||||
// selectCPU.enabled = false;
|
||||
this.selectCPU = new Button(this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU
|
||||
.getLocal() + ": " + GuiText.NoCraftingCPUs, btn -> selectNextCpu() );
|
||||
this.addButton( this.selectCPU );
|
||||
|
||||
if( !this.myIcon.isEmpty() )
|
||||
{
|
||||
this.addButton(
|
||||
this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), this.itemRender ) );
|
||||
this.originalGuiBtn.setHideEdge( 13 );
|
||||
}
|
||||
subGui.addBackButton(btn -> {
|
||||
addButton(btn);
|
||||
btn.setHideEdge( 13 );
|
||||
}, 213, -4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,25 +76,25 @@ public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
{
|
||||
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
|
||||
if( this.container.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
|
||||
if( this.craftingStatus.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if( this.container.myName.length() > 0 )
|
||||
if( this.craftingStatus.myName.length() > 0 )
|
||||
{
|
||||
final String name = this.container.myName.substring( 0, Math.min( 20, this.container.myName.length() ) );
|
||||
final String name = this.craftingStatus.myName.substring( 0, Math.min( 20, this.craftingStatus.myName.length() ) );
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.container.selectedCpu;
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.craftingStatus.selectedCpu;
|
||||
}
|
||||
}
|
||||
|
||||
if( this.container.noCPU )
|
||||
if( this.craftingStatus.noCPU )
|
||||
{
|
||||
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
}
|
||||
|
||||
this.selectCPU.displayString = btnTextText;
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,4 +102,11 @@ public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
{
|
||||
return in; // the cup name is on the button
|
||||
}
|
||||
|
||||
// FIXME: Extract to separate class? Shared with GuiCraftConfirm
|
||||
private void selectNextCpu() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,14 +19,10 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
@@ -41,34 +37,25 @@ import net.minecraft.util.text.ITextComponent;
|
||||
public class GuiCraftingTerm extends GuiMEMonitorable<ContainerCraftingTerm>
|
||||
{
|
||||
|
||||
private GuiImgButton clearBtn;
|
||||
|
||||
public GuiCraftingTerm(ContainerCraftingTerm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace( 73 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if( this.clearBtn == btn )
|
||||
private void clear() {
|
||||
Slot s = null;
|
||||
for( final Object j : this.container.inventorySlots )
|
||||
{
|
||||
Slot s = null;
|
||||
for( final Object j : this.container.inventorySlots )
|
||||
if( j instanceof SlotCraftingMatrix )
|
||||
{
|
||||
if( j instanceof SlotCraftingMatrix )
|
||||
{
|
||||
s = (Slot) j;
|
||||
}
|
||||
s = (Slot) j;
|
||||
}
|
||||
}
|
||||
|
||||
if( s != null )
|
||||
{
|
||||
final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
|
||||
NetworkHandler.instance().sendToServer( p );
|
||||
}
|
||||
if( s != null )
|
||||
{
|
||||
final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
|
||||
NetworkHandler.instance().sendToServer( p );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +63,8 @@ public class GuiCraftingTerm extends GuiMEMonitorable<ContainerCraftingTerm>
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.addButton( this.clearBtn = new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH ) );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
GuiImgButton clearBtn = this.addButton( new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH, btn -> clear() ));
|
||||
clearBtn.setHalfSize( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,19 +19,14 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -39,30 +34,21 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
public class GuiDrive extends AEBaseGui<ContainerDrive>
|
||||
{
|
||||
|
||||
private GuiTabButton priority;
|
||||
|
||||
public GuiDrive(ContainerDrive container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 199;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton par1GuiButton ) throws IOException
|
||||
{
|
||||
super.actionPerformed( par1GuiButton );
|
||||
|
||||
if( par1GuiButton == this.priority )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.addButton( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +59,7 @@ public class GuiDrive extends AEBaseGui<ContainerDrive>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/drive.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -19,32 +19,24 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane>
|
||||
{
|
||||
|
||||
private GuiTabButton priority;
|
||||
private GuiImgButton placeMode;
|
||||
|
||||
public GuiFormationPlane(ContainerFormationPlane container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
@@ -55,10 +47,10 @@ public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane>
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.placeMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.placeMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES, btn -> selectNextPlaceMode() );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
|
||||
|
||||
this.addButton( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
|
||||
this.addButton( this.placeMode );
|
||||
this.addButton( this.fuzzyMode );
|
||||
@@ -87,20 +79,13 @@ public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane>
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.priority )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
else if( btn == this.placeMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.placeMode.getSetting(), backwards ) );
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
|
||||
private void selectNextPlaceMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.placeMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class GuiGrinder extends AEBaseGui<ContainerGrinder>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/grinder.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -19,16 +19,6 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -36,10 +26,12 @@ import appeng.api.config.Settings;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
|
||||
@@ -56,9 +48,9 @@ public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.fullMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
this.operationMode = new GuiImgButton( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, this::actionPerformed);
|
||||
this.fullMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY, btn -> selectNextFullMode() );
|
||||
this.operationMode = new GuiImgButton( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY, btn -> selectNextOperationMode() );
|
||||
|
||||
this.addButton( this.operationMode );
|
||||
this.addButton( this.redstoneMode );
|
||||
@@ -88,9 +80,9 @@ public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
|
||||
final IDefinitions definitions = Api.INSTANCE.definitions();
|
||||
|
||||
@@ -105,21 +97,14 @@ public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
|
||||
return "guis/io_port.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.fullMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
if( btn == this.operationMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) );
|
||||
}
|
||||
private void selectNextFullMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
private void selectNextOperationMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -67,7 +65,7 @@ public class GuiInscriber extends AEBaseGui<ContainerInscriber>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/inscriber.png" );
|
||||
this.pb.x = 135 + this.guiLeft;
|
||||
|
||||
@@ -19,33 +19,25 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
public class GuiInterface extends GuiUpgradeable<ContainerInterface>
|
||||
{
|
||||
|
||||
private GuiTabButton priority;
|
||||
private GuiImgButton BlockMode;
|
||||
private GuiImgButton blockMode;
|
||||
private GuiToggleButton interfaceMode;
|
||||
|
||||
public GuiInterface(ContainerInterface container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
@@ -56,23 +48,22 @@ public class GuiInterface extends GuiUpgradeable<ContainerInterface>
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender );
|
||||
this.addButton( this.priority );
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
|
||||
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
|
||||
this.addButton( this.BlockMode );
|
||||
this.blockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO, btn -> selectNextBlockMode() );
|
||||
this.addButton( this.blockMode);
|
||||
|
||||
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal
|
||||
.getLocal(), GuiText.InterfaceTerminalHint.getLocal() );
|
||||
.getLocal(), GuiText.InterfaceTerminalHint.getLocal(), btn -> selectNextInterfaceMode() );
|
||||
this.addButton( this.interfaceMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
if( this.BlockMode != null )
|
||||
if( this.blockMode != null )
|
||||
{
|
||||
this.BlockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() );
|
||||
this.blockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() );
|
||||
}
|
||||
|
||||
if( this.interfaceMode != null )
|
||||
@@ -95,26 +86,18 @@ public class GuiInterface extends GuiUpgradeable<ContainerInterface>
|
||||
return "guis/interface.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.priority )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
|
||||
if( btn == this.interfaceMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
|
||||
}
|
||||
|
||||
if( btn == this.BlockMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
|
||||
private void selectNextBlockMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.blockMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
private void selectNextInterfaceMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,27 +19,6 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
@@ -47,12 +26,21 @@ import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.parts.reporting.PartInterfaceTerminal;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class GuiInterfaceTerminal extends AEBaseGui<ContainerInterfaceTerminal>
|
||||
{
|
||||
@@ -147,21 +135,21 @@ public class GuiInterfaceTerminal extends AEBaseGui<ContainerInterfaceTerminal>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
|
||||
public boolean mouseClicked( final double xCoord, final double yCoord, final int btn )
|
||||
{
|
||||
this.searchField.mouseClicked( xCoord, yCoord, btn );
|
||||
|
||||
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
|
||||
{
|
||||
this.searchField.setText( "" );
|
||||
this.refreshList();
|
||||
if (this.searchField.mouseClicked( xCoord, yCoord, btn )) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.refreshList();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
return super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/interfaceterminal.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
@@ -185,29 +173,22 @@ public class GuiInterfaceTerminal extends AEBaseGui<ContainerInterfaceTerminal>
|
||||
|
||||
if( this.searchField != null )
|
||||
{
|
||||
this.searchField.drawTextBox();
|
||||
this.searchField.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
public boolean charTyped(char character, int key) {
|
||||
if( character == ' ' && this.searchField.getText().isEmpty() )
|
||||
{
|
||||
if( character == ' ' && this.searchField.getText().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.searchField.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
this.refreshList();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if( this.searchField.charTyped( character, key ) )
|
||||
{
|
||||
this.refreshList();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void postUpdate( final CompoundNBT in )
|
||||
@@ -341,16 +322,17 @@ public class GuiInterfaceTerminal extends AEBaseGui<ContainerInterfaceTerminal>
|
||||
|
||||
// Potential later use to filter by input
|
||||
// ListNBT inTag = encodedValue.getTagList( "in", 10 );
|
||||
final ListNBT outTag = encodedValue.getTagList( "out", 10 );
|
||||
final ListNBT outTag = encodedValue.getList( "out", 10 );
|
||||
|
||||
for( int i = 0; i < outTag.tagCount(); i++ )
|
||||
for( int i = 0; i < outTag.size(); i++ )
|
||||
{
|
||||
|
||||
final ItemStack parsedItemStack = new ItemStack( outTag.getCompoundTagAt( i ) );
|
||||
final ItemStack parsedItemStack = ItemStack.read( outTag.getCompound( i ) );
|
||||
if( !parsedItemStack.isEmpty() )
|
||||
{
|
||||
final String displayName = Platform
|
||||
.getItemDisplayName( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createStack( parsedItemStack ) )
|
||||
.getString()
|
||||
.toLowerCase();
|
||||
if( displayName.contains( searchTerm ) )
|
||||
{
|
||||
|
||||
@@ -21,10 +21,10 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -42,7 +42,6 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
|
||||
|
||||
public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
@@ -50,14 +49,14 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
|
||||
private GuiNumberBox level;
|
||||
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
private GuiButton plus1000;
|
||||
private GuiButton minus1;
|
||||
private GuiButton minus10;
|
||||
private GuiButton minus100;
|
||||
private GuiButton minus1000;
|
||||
private Button plus1;
|
||||
private Button plus10;
|
||||
private Button plus100;
|
||||
private Button plus1000;
|
||||
private Button minus1;
|
||||
private Button minus10;
|
||||
private Button minus100;
|
||||
private Button minus1000;
|
||||
|
||||
private GuiImgButton levelMode;
|
||||
private GuiImgButton craftingMode;
|
||||
@@ -83,25 +82,25 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.levelMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.craftingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
|
||||
this.levelMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, btn -> selectNextLevelMode() );
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, this::actionPerformed );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
|
||||
this.craftingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, btn -> selectNextCraftingMode() );
|
||||
|
||||
final int a = AEConfig.instance().levelByStackAmounts( 0 );
|
||||
final int b = AEConfig.instance().levelByStackAmounts( 1 );
|
||||
final int c = AEConfig.instance().levelByStackAmounts( 2 );
|
||||
final int d = AEConfig.instance().levelByStackAmounts( 3 );
|
||||
|
||||
this.addButton( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) );
|
||||
this.addButton( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) );
|
||||
this.addButton( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) );
|
||||
this.addButton( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) );
|
||||
this.addButton( this.plus1 = new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a) ) );
|
||||
this.addButton( this.plus10 = new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b) ) );
|
||||
this.addButton( this.plus100 = new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c) ) );
|
||||
this.addButton( this.plus1000 = new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d) ) );
|
||||
|
||||
this.addButton( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) );
|
||||
this.addButton( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) );
|
||||
this.addButton( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) );
|
||||
this.addButton( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) );
|
||||
this.addButton( this.minus1 = new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a) ) );
|
||||
this.addButton( this.minus10 = new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b) ) );
|
||||
this.addButton( this.minus100 = new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c) ) );
|
||||
this.addButton( this.minus1000 = new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d) ) );
|
||||
|
||||
this.addButton( this.levelMode );
|
||||
this.addButton( this.redstoneMode );
|
||||
@@ -116,22 +115,22 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
|
||||
// configure enabled status...
|
||||
this.level.setEnabled( notCraftingMode );
|
||||
this.plus1.enabled = notCraftingMode;
|
||||
this.plus10.enabled = notCraftingMode;
|
||||
this.plus100.enabled = notCraftingMode;
|
||||
this.plus1000.enabled = notCraftingMode;
|
||||
this.minus1.enabled = notCraftingMode;
|
||||
this.minus10.enabled = notCraftingMode;
|
||||
this.minus100.enabled = notCraftingMode;
|
||||
this.minus1000.enabled = notCraftingMode;
|
||||
this.levelMode.enabled = notCraftingMode;
|
||||
this.redstoneMode.enabled = notCraftingMode;
|
||||
this.plus1.active = notCraftingMode;
|
||||
this.plus10.active = notCraftingMode;
|
||||
this.plus100.active = notCraftingMode;
|
||||
this.plus1000.active = notCraftingMode;
|
||||
this.minus1.active = notCraftingMode;
|
||||
this.minus10.active = notCraftingMode;
|
||||
this.minus100.active = notCraftingMode;
|
||||
this.minus1000.active = notCraftingMode;
|
||||
this.levelMode.active = notCraftingMode;
|
||||
this.redstoneMode.active = notCraftingMode;
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
|
||||
if( this.craftingMode != null )
|
||||
{
|
||||
this.craftingMode.set( ( (ContainerLevelEmitter) this.cvb ).getCraftingMode() );
|
||||
this.craftingMode.set( this.cvb.getCraftingMode() );
|
||||
}
|
||||
|
||||
if( this.levelMode != null )
|
||||
@@ -141,10 +140,10 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.level.drawTextBox();
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
this.level.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,30 +165,14 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
return GuiText.LevelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
private void selectNextCraftingMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.craftingMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.craftingMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.craftingMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
if( btn == this.levelMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.levelMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
|
||||
|
||||
if( isPlus || isMinus )
|
||||
{
|
||||
this.addQty( this.getQty( btn ) );
|
||||
}
|
||||
private void selectNextLevelMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.levelMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
private void addQty( final long i )
|
||||
@@ -231,51 +214,45 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
// nope..
|
||||
this.level.setText( "0" );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
public boolean charTyped(char character, int key) {
|
||||
// Forward entered characters to the number-text-field
|
||||
return level.charTyped(character, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( ( key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit( character ) ) && this.level.textboxKeyTyped( character, key ) )
|
||||
if( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 )
|
||||
{
|
||||
try
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
catch( final IOException e )
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
AELog.debug( e );
|
||||
this.level.setText( Out );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed( keyCode, scanCode, p_keyPressed_3_ );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
@@ -54,7 +53,7 @@ public class GuiMAC extends GuiUpgradeable<ContainerMAC>
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, this::actionPerformed );
|
||||
this.addButton( this.redstoneMode );
|
||||
}
|
||||
|
||||
@@ -66,11 +65,11 @@ public class GuiMAC extends GuiUpgradeable<ContainerMAC>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.pb.x = 148 + this.guiLeft;
|
||||
this.pb.y = 48 + this.guiTop;
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,14 +22,14 @@ package appeng.client.gui.implementations;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
@@ -38,7 +38,6 @@ import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
@@ -64,11 +63,11 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.parts.reporting.AbstractPartTerminal;
|
||||
import appeng.tile.misc.TileSecurityStation;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
|
||||
public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseMEGui<T> implements ISortSource, IConfigManagerHost
|
||||
@@ -164,17 +163,15 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
if( btn == this.craftingStatusBtn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
|
||||
}
|
||||
private void showCraftingStatus() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis(ContainerCraftingStatus.TYPE) );
|
||||
}
|
||||
|
||||
protected void actionPerformed( final Button btn )
|
||||
{
|
||||
if( btn instanceof GuiImgButton )
|
||||
{
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if( iBtn.getSetting() != Settings.ACTIONS )
|
||||
@@ -192,14 +189,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
||||
}
|
||||
|
||||
iBtn.set( next );
|
||||
@@ -221,7 +211,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
Keyboard.enableRepeatEvents( true );
|
||||
minecraft.keyboardListener.enableRepeatEvents( true );
|
||||
|
||||
this.maxRows = this.getMaxRows();
|
||||
this.perRow = AEConfig.instance()
|
||||
@@ -275,27 +265,25 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
|
||||
if( this.customSortOrder )
|
||||
{
|
||||
this.buttonList
|
||||
.add( this.SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ) ) );
|
||||
this.SortByBox = this.addButton( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ), this::actionPerformed ) );
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
if( this.viewCell || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
this.buttonList
|
||||
.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
|
||||
this.ViewBox = this.addButton( new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ), this::actionPerformed ) );
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
this.addButton( this.SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc
|
||||
.getSetting( Settings.SORT_DIRECTION ) ) );
|
||||
.getSetting( Settings.SORT_DIRECTION ), this::actionPerformed ) );
|
||||
offset += 20;
|
||||
|
||||
this.addButton(
|
||||
this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance()
|
||||
.getConfigManager()
|
||||
.getSetting(
|
||||
Settings.SEARCH_MODE ) ) );
|
||||
Settings.SEARCH_MODE ), this::actionPerformed ) );
|
||||
|
||||
offset += 20;
|
||||
|
||||
@@ -303,7 +291,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
{
|
||||
this.addButton( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance()
|
||||
.getConfigManager()
|
||||
.getSetting( Settings.TERMINAL_STYLE ) ) );
|
||||
.getSetting( Settings.TERMINAL_STYLE ), this::actionPerformed ) );
|
||||
}
|
||||
|
||||
this.searchField = new MEGuiTextField( this.font, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
|
||||
@@ -315,8 +303,8 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
|
||||
if( this.viewCell || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
this.addButton( this.craftingStatusBtn = new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus
|
||||
.getLocal(), this.itemRender ) );
|
||||
this.craftingStatusBtn = this.addButton( new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus
|
||||
.getLocal(), this.itemRenderer, btn -> showCraftingStatus() ) );
|
||||
this.craftingStatusBtn.setHideEdge( 13 );
|
||||
}
|
||||
|
||||
@@ -326,11 +314,11 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
|
||||
final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting;
|
||||
|
||||
this.searchField.setFocused( this.isAutoFocus );
|
||||
this.searchField.setFocused2( this.isAutoFocus );
|
||||
|
||||
if( isJEIEnabled )
|
||||
{
|
||||
memoryText = Integrations.jei().getSearchText();
|
||||
memoryText = null; // FIXME Integrations.jei().getSearchText();
|
||||
}
|
||||
|
||||
if( isKeepFilter && memoryText != null && !memoryText.isEmpty() )
|
||||
@@ -382,31 +370,31 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
|
||||
public boolean mouseClicked( final double xCoord, final double yCoord, final int btn )
|
||||
{
|
||||
this.searchField.mouseClicked( xCoord, yCoord, btn );
|
||||
|
||||
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
|
||||
{
|
||||
this.searchField.setText( "" );
|
||||
this.repo.setSearchString( "" );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
if (this.searchField.mouseClicked( xCoord, yCoord, btn )) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
return super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed()
|
||||
{
|
||||
super.removed();
|
||||
Keyboard.enableRepeatEvents( false );
|
||||
minecraft.keyboardListener.enableRepeatEvents( false );
|
||||
memoryText = this.searchField.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
this.bindTexture( this.getBackground() );
|
||||
@@ -447,7 +435,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
|
||||
if( this.searchField != null )
|
||||
{
|
||||
this.searchField.drawTextBox();
|
||||
this.searchField.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,59 +457,71 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
|
||||
|
||||
protected void repositionSlot( final AppEngSlot s )
|
||||
{
|
||||
s.yPos = s.getY() + this.ySize - 78 - 5;
|
||||
// FIXME .... it's final now, WHAT DO WE DO ARGH
|
||||
// s.yPos = s.getY() + this.ySize - 78 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
public boolean charTyped(char character, int p_charTyped_2_) {
|
||||
if( character == ' ' && this.searchField.getText().isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final boolean mouseInGui = this.isMouseOver( this.currentMouseX, this.currentMouseY );
|
||||
if( this.isAutoFocus && !this.searchField.isFocused() && mouseInGui )
|
||||
{
|
||||
this.searchField.setFocused2( true );
|
||||
}
|
||||
|
||||
if (this.searchField.charTyped(character, p_charTyped_2_)) {
|
||||
this.repo.setSearchString( this.searchField.getText() );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
|
||||
|
||||
if( !this.checkHotbarKeys(input) )
|
||||
{
|
||||
if( AppEng.proxy.isActionKey( ActionKey.TOGGLE_FOCUS, key ) )
|
||||
if( AppEng.proxy.isActionKey( ActionKey.TOGGLE_FOCUS, input ) )
|
||||
{
|
||||
this.searchField.setFocused( !this.searchField.isFocused() );
|
||||
return;
|
||||
this.searchField.setFocused2( !this.searchField.isFocused() );
|
||||
return true;
|
||||
}
|
||||
|
||||
if( this.searchField.isFocused() && key == Keyboard.KEY_RETURN )
|
||||
if( this.searchField.isFocused() && keyCode == GLFW.GLFW_KEY_ENTER )
|
||||
{
|
||||
this.searchField.setFocused( false );
|
||||
return;
|
||||
this.searchField.setFocused2( false );
|
||||
return true;
|
||||
}
|
||||
|
||||
if( character == ' ' && this.searchField.getText().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean mouseInGui = this.isPointInRegion( 0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY );
|
||||
|
||||
if( this.isAutoFocus && !this.searchField.isFocused() && mouseInGui )
|
||||
{
|
||||
this.searchField.setFocused( true );
|
||||
}
|
||||
|
||||
if( this.searchField.textboxKeyTyped( character, key ) )
|
||||
if( this.searchField.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
this.repo.setSearchString( this.searchField.getText() );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
// tell forge the key event is handled and should not be sent out
|
||||
this.keyHandled = mouseInGui;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
public void tick()
|
||||
{
|
||||
this.repo.setPower( this.container.isPowered() );
|
||||
super.updateScreen();
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,25 +19,10 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
@@ -49,6 +34,14 @@ import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implements ISortSource
|
||||
@@ -70,29 +63,21 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
|
||||
this.repo.setRowSize( 5 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.units )
|
||||
{
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
this.units.set( AEConfig.instance().selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit() );
|
||||
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), btn -> selectNextUnit() );
|
||||
this.addButton( this.units );
|
||||
}
|
||||
|
||||
private void selectNextUnit() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
this.units.set( AEConfig.instance().selectedPowerUnit() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
@@ -160,8 +145,8 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
|
||||
final IAEItemStack refStack = this.repo.getReferenceItem( z );
|
||||
if( refStack != null )
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale( 0.5, 0.5, 0.5 );
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
String str = Long.toString( refStack.getStackSize() );
|
||||
if( refStack.getStackSize() >= 10000 )
|
||||
@@ -173,13 +158,13 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
|
||||
this.font.drawString( str, (int) ( ( x * sectionLength + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * 18 + yo + 6 ) * 2,
|
||||
4210752 );
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * sectionLength + xo + sectionLength - 18;
|
||||
final int posY = y * 18 + yo;
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
toolTip = Platform.getItemDisplayName( refStack );
|
||||
toolTip = Platform.getItemDisplayName( refStack ).getFormattedText();
|
||||
|
||||
toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) );
|
||||
if( refStack.getCountRequestable() > 0 )
|
||||
@@ -210,7 +195,7 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/networkstatus.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
@@ -237,11 +222,11 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderToolTip( final ItemStack stack, final int x, final int y )
|
||||
protected void renderTooltip( final ItemStack stack, final int x, final int y )
|
||||
{
|
||||
final Slot s = this.getSlot( x, y );
|
||||
|
||||
if( s instanceof SlotME && stack != null )
|
||||
if( s instanceof SlotME && !stack.isEmpty() )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
@@ -256,8 +241,7 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
|
||||
|
||||
if( myStack != null )
|
||||
{
|
||||
ITooltipFlag.TooltipFlags tooltipFlag = this.minecraft.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
|
||||
List<String> currentToolTip = stack.getTooltip( this.minecraft.player, tooltipFlag );
|
||||
List<String> currentToolTip = getTooltipFromItem(stack);
|
||||
|
||||
while( currentToolTip.size() > 1 )
|
||||
{
|
||||
@@ -271,7 +255,7 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
|
||||
}
|
||||
}
|
||||
|
||||
super.renderToolTip( stack, x, y );
|
||||
super.renderTooltip( stack, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,19 +19,13 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -46,35 +40,21 @@ public class GuiNetworkTool extends AEBaseGui<ContainerNetworkTool>
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
if( btn == this.tFacades )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.tFacades = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint
|
||||
.getLocal() );
|
||||
.getLocal(), btn -> toggleFacades() );
|
||||
|
||||
this.addButton( this.tFacades );
|
||||
}
|
||||
|
||||
private void toggleFacades() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
@@ -88,7 +68,7 @@ public class GuiNetworkTool extends AEBaseGui<ContainerNetworkTool>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/toolbox.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -19,25 +19,19 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
@@ -57,79 +51,55 @@ public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm>
|
||||
private GuiTabButton tabProcessButton;
|
||||
private GuiImgButton substitutionsEnabledBtn;
|
||||
private GuiImgButton substitutionsDisabledBtn;
|
||||
private GuiImgButton encodeBtn;
|
||||
private GuiImgButton clearBtn;
|
||||
|
||||
public GuiPatternTerm(ContainerPatternTerm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace( 81 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if( this.tabCraftButton == btn || this.tabProcessButton == btn )
|
||||
{
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketValueConfig( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING ) );
|
||||
}
|
||||
|
||||
if( this.encodeBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
|
||||
}
|
||||
|
||||
if( this.clearBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
|
||||
}
|
||||
|
||||
if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketValueConfig( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.CRAFTING_TABLE ), GuiText.CraftingPattern
|
||||
.getLocal(), this.itemRender );
|
||||
.getLocal(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_PROCESSING) );
|
||||
this.addButton( this.tabCraftButton );
|
||||
|
||||
this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.FURNACE ), GuiText.ProcessingPattern
|
||||
.getLocal(), this.itemRender );
|
||||
.getLocal(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_CRFTING) );
|
||||
this.addButton( this.tabProcessButton );
|
||||
|
||||
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED );
|
||||
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED, btn -> toggleSubstitutions(SUBSITUTION_DISABLE) );
|
||||
this.substitutionsEnabledBtn.setHalfSize( true );
|
||||
this.addButton( this.substitutionsEnabledBtn );
|
||||
|
||||
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED );
|
||||
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED, btn -> toggleSubstitutions(SUBSITUTION_ENABLE) );
|
||||
this.substitutionsDisabledBtn.setHalfSize( true );
|
||||
this.addButton( this.substitutionsDisabledBtn );
|
||||
|
||||
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.clearBtn.setHalfSize( true );
|
||||
this.addButton( this.clearBtn );
|
||||
GuiImgButton clearBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE, btn -> clear());
|
||||
clearBtn.setHalfSize( true );
|
||||
this.addButton(clearBtn);
|
||||
|
||||
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
|
||||
this.addButton( this.encodeBtn );
|
||||
GuiImgButton encodeBtn = new GuiImgButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE, btn -> encode());
|
||||
this.addButton(encodeBtn);
|
||||
}
|
||||
|
||||
private void toggleCraftMode(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig( "PatternTerminal.CraftMode", mode ) );
|
||||
}
|
||||
|
||||
private void toggleSubstitutions(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig( "PatternTerminal.Substitute", mode ) );
|
||||
}
|
||||
|
||||
private void encode() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,6 +149,6 @@ public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm>
|
||||
{
|
||||
final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3;
|
||||
|
||||
s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
|
||||
// FIXME OH NOOOOO WE CANNOT, ITS FINAL s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,47 +19,33 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class GuiPriority extends AEBaseGui<ContainerPriority>
|
||||
{
|
||||
|
||||
private final AESubGui subGui;
|
||||
|
||||
private GuiNumberBox priority;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
private GuiButton plus1000;
|
||||
private GuiButton minus1;
|
||||
private GuiButton minus10;
|
||||
private GuiButton minus100;
|
||||
private GuiButton minus1000;
|
||||
|
||||
private GuiBridge OriginalGui;
|
||||
|
||||
public GuiPriority(ContainerPriority container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getPriorityHost());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,23 +58,17 @@ public class GuiPriority extends AEBaseGui<ContainerPriority>
|
||||
final int c = AEConfig.instance().priorityByStacksAmounts( 2 );
|
||||
final int d = AEConfig.instance().priorityByStacksAmounts( 3 );
|
||||
|
||||
this.addButton( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
|
||||
this.addButton( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
|
||||
this.addButton( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
|
||||
this.addButton( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a, btn -> addQty(a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b, btn -> addQty(b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c, btn -> addQty(c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d, btn -> addQty(d) ) );
|
||||
|
||||
this.addButton( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
|
||||
this.addButton( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
|
||||
this.addButton( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
|
||||
this.addButton( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a, btn -> addQty(-a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b, btn -> addQty(-b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c, btn -> addQty(-c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d, btn -> addQty(-d) ) );
|
||||
|
||||
final ItemStack myIcon = container.getPriorityHost().getItemStackRepresentation();
|
||||
this.OriginalGui = container.getPriorityHost().getGuiBridge();
|
||||
|
||||
if( this.OriginalGui != null && !myIcon.isEmpty() )
|
||||
{
|
||||
this.addButton( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) );
|
||||
}
|
||||
this.subGui.addBackButton(this::addButton, 154, 0);
|
||||
|
||||
this.priority = new GuiNumberBox( this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, Long.class );
|
||||
this.priority.setEnableBackgroundDrawing( false );
|
||||
@@ -106,31 +86,12 @@ public class GuiPriority extends AEBaseGui<ContainerPriority>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/priority.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
this.priority.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if( btn == this.originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
|
||||
}
|
||||
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
|
||||
|
||||
if( isPlus || isMinus )
|
||||
{
|
||||
this.addQty( this.getQty( btn ) );
|
||||
}
|
||||
this.priority.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
private void addQty( final int i )
|
||||
@@ -168,53 +129,69 @@ public class GuiPriority extends AEBaseGui<ContainerPriority>
|
||||
// nope..
|
||||
this.priority.setText( "0" );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority
|
||||
.textboxKeyTyped( character, key ) )
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (priority.charTyped(character, key)) {
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
try
|
||||
{
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.priority.setText( out );
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
else
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
this.priority.setText( out );
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) && this.priority
|
||||
.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.priority.setText( out );
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class GuiQNB extends AEBaseGui<ContainerQNB>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/chest.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -30,7 +30,6 @@ import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class GuiQuartzKnife extends AEBaseGui<ContainerQuartzKnife>
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.name = new TextFieldWidget( 0, this.font, this.guiLeft + 24, this.guiTop + 32, 79, this.font.FONT_HEIGHT );
|
||||
this.name = new TextFieldWidget( this.font, this.guiLeft + 24, this.guiTop + 32, 79, this.font.FONT_HEIGHT, "" );
|
||||
this.name.setEnableBackgroundDrawing( false );
|
||||
this.name.setMaxStringLength( 32 );
|
||||
this.name.setTextColor( 0xFFFFFF );
|
||||
@@ -66,32 +65,37 @@ public class GuiQuartzKnife extends AEBaseGui<ContainerQuartzKnife>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/quartzknife.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
this.name.drawTextBox();
|
||||
this.name.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
public boolean charTyped(char character, int key) {
|
||||
if( this.name.charTyped( character, key ) )
|
||||
{
|
||||
final String Out = this.name.getText();
|
||||
container.setName( Out );
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.charTyped(character, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
if( this.name.textboxKeyTyped( character, key ) )
|
||||
if( this.name.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
final String Out = this.name.getText();
|
||||
container.setName( Out );
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
final String Out = this.name.getText();
|
||||
container.setName( Out );
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
@@ -54,45 +55,8 @@ public class GuiSecurityStation extends GuiMEMonitorable<ContainerSecurityStatio
|
||||
this.setStandardSize( this.xSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final net.minecraft.client.gui.GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
SecurityPermissions toggleSetting = null;
|
||||
|
||||
if( btn == this.inject )
|
||||
{
|
||||
toggleSetting = SecurityPermissions.INJECT;
|
||||
}
|
||||
if( btn == this.extract )
|
||||
{
|
||||
toggleSetting = SecurityPermissions.EXTRACT;
|
||||
}
|
||||
if( btn == this.craft )
|
||||
{
|
||||
toggleSetting = SecurityPermissions.CRAFT;
|
||||
}
|
||||
if( btn == this.build )
|
||||
{
|
||||
toggleSetting = SecurityPermissions.BUILD;
|
||||
}
|
||||
if( btn == this.security )
|
||||
{
|
||||
toggleSetting = SecurityPermissions.SECURITY;
|
||||
}
|
||||
|
||||
if( toggleSetting != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileSecurityStation.ToggleOption", toggleSetting.name() ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
private void toggleOption(SecurityPermissions permission) {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileSecurityStation.ToggleOption", permission.name() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,20 +65,20 @@ public class GuiSecurityStation extends GuiMEMonitorable<ContainerSecurityStatio
|
||||
super.init();
|
||||
|
||||
final int top = this.guiTop + this.ySize - 116;
|
||||
this.addButton( this.inject = new GuiToggleButton( this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT
|
||||
.getTranslationKey(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
|
||||
this.inject = this.addButton( new GuiToggleButton( this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT
|
||||
.getTranslatedName(), SecurityPermissions.INJECT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.INJECT) ) );
|
||||
|
||||
this.addButton( this.extract = new GuiToggleButton( this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
|
||||
.getTranslationKey(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
|
||||
this.extract = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
|
||||
.getTranslatedName(), SecurityPermissions.EXTRACT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.EXTRACT ) ) );
|
||||
|
||||
this.addButton( this.craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT
|
||||
.getTranslationKey(), SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
|
||||
this.craft = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT
|
||||
.getTranslatedName(), SecurityPermissions.CRAFT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.CRAFT ) ) );
|
||||
|
||||
this.addButton( this.build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD
|
||||
.getTranslationKey(), SecurityPermissions.BUILD.getUnlocalizedTip() ) );
|
||||
this.build = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD
|
||||
.getTranslatedName(), SecurityPermissions.BUILD.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.BUILD ) ) );
|
||||
|
||||
this.addButton( this.security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
|
||||
.getTranslationKey(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
|
||||
this.security = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
|
||||
.getTranslatedName(), SecurityPermissions.SECURITY.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.SECURITY ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,7 +49,7 @@ public class GuiSkyChest extends AEBaseGui<ContainerSkyChest>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
bindTexture(TEXTURE);
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 );
|
||||
|
||||
@@ -19,23 +19,16 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiSpatialIOPort extends AEBaseGui<ContainerSpatialIOPort>
|
||||
@@ -48,29 +41,21 @@ public class GuiSpatialIOPort extends AEBaseGui<ContainerSpatialIOPort>
|
||||
this.ySize = 199;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.units )
|
||||
{
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
this.units.set( AEConfig.instance().selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit() );
|
||||
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), btn -> selectNextUnit() );
|
||||
this.addButton( this.units );
|
||||
}
|
||||
|
||||
private void selectNextUnit() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
this.units.set( AEConfig.instance().selectedPowerUnit() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
@@ -97,7 +82,7 @@ public class GuiSpatialIOPort extends AEBaseGui<ContainerSpatialIOPort>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/spatialio.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -19,30 +19,18 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.*;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
||||
public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
|
||||
@@ -50,9 +38,6 @@ public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
|
||||
|
||||
private GuiImgButton rwMode;
|
||||
private GuiImgButton storageFilter;
|
||||
private GuiTabButton priority;
|
||||
private GuiImgButton partition;
|
||||
private GuiImgButton clear;
|
||||
|
||||
public GuiStorageBus(ContainerStorageBus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
@@ -62,19 +47,17 @@ public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
addButton( new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE, btn -> clear() ) );
|
||||
addButton( new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH, btn -> partition() ) );
|
||||
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE, btn -> toggleReadWriteMode() );
|
||||
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, btn -> toggleStorageFilterMode() );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
|
||||
|
||||
this.addButton( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
|
||||
this.addButton( this.storageFilter );
|
||||
this.addButton( this.fuzzyMode );
|
||||
this.addButton( this.rwMode );
|
||||
this.addButton( this.partition );
|
||||
this.addButton( this.clear );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,39 +88,26 @@ public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if( btn == this.partition )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
|
||||
}
|
||||
else if( btn == this.clear )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
|
||||
}
|
||||
else if( btn == this.priority )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
else if( btn == this.rwMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
|
||||
}
|
||||
else if( btn == this.storageFilter )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
private void partition() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
|
||||
private void toggleReadWriteMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
private void toggleStorageFilterMode() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -64,7 +63,7 @@ public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
|
||||
|
||||
protected boolean hasToolbox()
|
||||
{
|
||||
return ( (ContainerUpgradeable) this.container ).hasToolbox();
|
||||
return ( this.container ).hasToolbox();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,10 +75,10 @@ public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
|
||||
|
||||
protected void addButtons()
|
||||
{
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.craftMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
|
||||
this.schedulingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, this::actionPerformed );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
|
||||
this.craftMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO, this::actionPerformed );
|
||||
this.schedulingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, this::actionPerformed );
|
||||
|
||||
this.addButton( this.craftMode );
|
||||
this.addButton( this.redstoneMode );
|
||||
@@ -115,7 +114,7 @@ public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.handleButtonVisibility();
|
||||
|
||||
@@ -166,12 +165,11 @@ public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
|
||||
return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
// FIXME: replace with individual methods
|
||||
protected void actionPerformed( final Button btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
// Detect right-clicks
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
|
||||
if( btn == this.redstoneMode )
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ public class GuiVibrationChamber extends AEBaseGui<ContainerVibrationChamber>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/vibchamber.png" );
|
||||
this.pb.x = 99 + this.guiLeft;
|
||||
|
||||
@@ -19,23 +19,16 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiWireless extends AEBaseGui<ContainerWireless>
|
||||
@@ -48,29 +41,21 @@ public class GuiWireless extends AEBaseGui<ContainerWireless>
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.units )
|
||||
{
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
this.units.set( AEConfig.instance().selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit() );
|
||||
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), btn -> toggleUnits() );
|
||||
this.addButton( this.units );
|
||||
}
|
||||
|
||||
private void toggleUnits() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
this.units.set( AEConfig.instance().selectedPowerUnit() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
@@ -90,7 +75,7 @@ public class GuiWireless extends AEBaseGui<ContainerWireless>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/wireless.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME this.zlevel was used */ );
|
||||
|
||||
@@ -19,59 +19,39 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.RelativeDirection;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
|
||||
public class GuiImgButton extends Button implements ITooltip
|
||||
{
|
||||
private static final Pattern COMPILE = Pattern.compile( "%s" );
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private static Map<EnumPair, ButtonAppearance> appearances;
|
||||
private final Enum buttonSetting;
|
||||
private boolean halfSize = false;
|
||||
private String fillVar;
|
||||
private Enum currentValue;
|
||||
|
||||
public GuiImgButton( final int x, final int y, final Enum idx, final Enum val )
|
||||
public GuiImgButton( final int x, final int y, final Enum idx, final Enum val, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
|
||||
this.buttonSetting = idx;
|
||||
this.currentValue = val;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 16;
|
||||
this.height = 16;
|
||||
|
||||
if( appearances == null )
|
||||
{
|
||||
@@ -84,9 +64,9 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
this.registerApp( 16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
|
||||
this.registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
|
||||
|
||||
this.registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName );
|
||||
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
|
||||
this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
|
||||
this.registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.textComponent() );
|
||||
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.textComponent() );
|
||||
this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.textComponent() );
|
||||
|
||||
this.registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
|
||||
this.registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
|
||||
@@ -177,38 +157,48 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
}
|
||||
}
|
||||
|
||||
private void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final Object hint )
|
||||
private void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final ITextComponent hint )
|
||||
{
|
||||
final ButtonAppearance a = new ButtonAppearance();
|
||||
a.displayName = title.getUnlocalized();
|
||||
a.displayValue = (String) ( hint instanceof String ? hint : ( (ButtonToolTips) hint ).getUnlocalized() );
|
||||
a.displayName = title.getTranslationKey();
|
||||
a.displayValue = hint;
|
||||
a.index = iconIndex;
|
||||
appearances.put( new EnumPair( setting, val ), a );
|
||||
}
|
||||
|
||||
private void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final ButtonToolTips hint )
|
||||
{
|
||||
registerApp(iconIndex, setting, val, title, hint.getTranslationKey());
|
||||
}
|
||||
|
||||
public void setVisibility( final boolean vis )
|
||||
{
|
||||
this.visible = vis;
|
||||
this.enabled = vis;
|
||||
this.active = vis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, float partial )
|
||||
{
|
||||
public void renderButton(final int mouseX, final int mouseY, float partial) {
|
||||
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
TextureManager textureManager = minecraft.getTextureManager();
|
||||
textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.disableDepthTest();
|
||||
if( this.halfSize )
|
||||
{
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate( this.x, this.y, 0.0F );
|
||||
GlStateManager.scale( 0.5f, 0.5f, 0.5f );
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef( this.x, this.y, 0.0F );
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
if( this.enabled )
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
@@ -217,21 +207,16 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
|
||||
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16.0f );
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.enabled )
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
@@ -240,16 +225,13 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
|
||||
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
@@ -281,8 +263,8 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
String displayName = null;
|
||||
String displayValue = null;
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
|
||||
if( this.buttonSetting != null && this.currentValue != null )
|
||||
{
|
||||
@@ -298,17 +280,8 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
|
||||
if( displayName != null )
|
||||
{
|
||||
String name = I18n.format( displayName );
|
||||
String value = I18n.format( displayValue );
|
||||
|
||||
if( name == null || name.isEmpty() )
|
||||
{
|
||||
name = displayName;
|
||||
}
|
||||
if( value == null || value.isEmpty() )
|
||||
{
|
||||
value = displayValue;
|
||||
}
|
||||
String name = displayName.getString();
|
||||
String value = displayValue.getString();
|
||||
|
||||
if( this.fillVar != null )
|
||||
{
|
||||
@@ -428,7 +401,7 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
private static class ButtonAppearance
|
||||
{
|
||||
public int index;
|
||||
public String displayName;
|
||||
public String displayValue;
|
||||
public ITextComponent displayName;
|
||||
public ITextComponent displayValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package appeng.client.gui.widgets;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
|
||||
|
||||
// FIXME: Fix this piece of crap (i.e. onChange listener)
|
||||
public class GuiNumberBox extends TextFieldWidget
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GuiNumberBox extends TextFieldWidget
|
||||
|
||||
public GuiNumberBox( final FontRenderer fontRenderer, final int x, final int y, final int width, final int height, final Class type )
|
||||
{
|
||||
super( 0, fontRenderer, x, y, width, height );
|
||||
super( fontRenderer, x, y, width, height, "0" );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@ package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.container.interfaces.IProgressProvider;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiProgressBar extends Button implements ITooltip
|
||||
public class GuiProgressBar extends Widget implements ITooltip
|
||||
{
|
||||
|
||||
private final IProgressProvider source;
|
||||
@@ -45,13 +47,9 @@ public class GuiProgressBar extends Button implements ITooltip
|
||||
|
||||
public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir, final String title )
|
||||
{
|
||||
super( posX, posY, width, "" );
|
||||
super( posX, posY, width, height, "" );
|
||||
this.source = source;
|
||||
this.x = posX;
|
||||
this.y = posY;
|
||||
this.texture = new ResourceLocation( "appliedenergistics2", "textures/" + texture );
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.fill_u = u;
|
||||
this.fill_v = y;
|
||||
this.layout = dir;
|
||||
@@ -59,26 +57,24 @@ public class GuiProgressBar extends Button implements ITooltip
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, final float partial )
|
||||
public void renderButton( final int par2, final int par3, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
par1Minecraft.getTextureManager().bindTexture( this.texture );
|
||||
Minecraft.getInstance().getTextureManager().bindTexture( this.texture );
|
||||
final int max = this.source.getMaxProgress();
|
||||
final int current = this.source.getCurrentProgress();
|
||||
|
||||
if( this.layout == Direction.VERTICAL )
|
||||
{
|
||||
final int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 );
|
||||
this.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 );
|
||||
this.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height, 0 );
|
||||
}
|
||||
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,34 +19,31 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiTabButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private final ItemRenderer itemRenderer;
|
||||
private final String message;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir )
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myIcon = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
@@ -59,65 +56,51 @@ public class GuiTabButton extends Button implements ITooltip
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir )
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
this.myItem = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft minecraft, final int x, final int y, float partial )
|
||||
public void renderButton( final int x, final int y, float partial )
|
||||
{
|
||||
final Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
|
||||
minecraft.textureManager.bindTexture(TEXTURE_STATES);
|
||||
|
||||
int uv_x = ( this.hideEdge > 0 ? 11 : 13 );
|
||||
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
|
||||
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, 0, 25, 22 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, 0, 25, 22, 0 );
|
||||
|
||||
if( this.myIcon >= 0 )
|
||||
{
|
||||
final int uv_y = (int) Math.floor( this.myIcon / 16 );
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
GuiUtils.drawTexturedModalRect( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
|
||||
this.mouseDragged( minecraft, x, y );
|
||||
|
||||
if( this.myItem != null )
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
// FIXME RenderHelper.enableGUIStandardItemLighting();
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI( this.myItem, offsetX + this.x + 3, this.y + 3 );
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
|
||||
@@ -21,15 +21,17 @@ package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiToggleButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private final int iconIdxOn;
|
||||
private final int iconIdxOff;
|
||||
@@ -39,17 +41,13 @@ public class GuiToggleButton extends Button implements ITooltip
|
||||
|
||||
private boolean isActive;
|
||||
|
||||
public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint )
|
||||
public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
this.iconIdxOn = on;
|
||||
this.iconIdxOff = off;
|
||||
this.displayName = displayName;
|
||||
this.displayHint = displayHint;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 16;
|
||||
this.height = 16;
|
||||
}
|
||||
|
||||
public void setState( final boolean isOn )
|
||||
@@ -58,22 +56,20 @@ public class GuiToggleButton extends Button implements ITooltip
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, final float partial )
|
||||
public void renderButton( final int mouseX, final int mouseY, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
|
||||
Minecraft.getInstance().textureManager.bindTexture( TEXTURE_STATES );
|
||||
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
@@ -39,10 +40,6 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
{
|
||||
private static final int PADDING = 2;
|
||||
|
||||
private final int _xPos;
|
||||
private final int _yPos;
|
||||
private final int _width;
|
||||
private final int _height;
|
||||
private final int _fontPad;
|
||||
private int selectionColor = 0xFF00FF00;
|
||||
|
||||
@@ -58,21 +55,19 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
*/
|
||||
public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height )
|
||||
{
|
||||
super( 0, fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth( '_' ), height - 2 * PADDING );
|
||||
super( fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth( '_' ), height - 2 * PADDING, "" );
|
||||
|
||||
this._fontPad = fontRenderer.getCharWidth( '_' );
|
||||
this._xPos = xPos;
|
||||
this._yPos = yPos;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
this._fontPad = (int) fontRenderer.getCharWidth( '_' );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked( final int xPos, final int yPos, final int button )
|
||||
public boolean mouseClicked( final double xPos, final double yPos, final int button )
|
||||
{
|
||||
super.mouseClicked( xPos, yPos, button );
|
||||
if (!super.mouseClicked( xPos, yPos, button )) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean requiresFocus = this.isMouseIn( xPos, yPos );
|
||||
final boolean requiresFocus = this.isMouseOver( xPos, yPos );
|
||||
if( !this.isFocused() )
|
||||
{
|
||||
this.setFocused2( requiresFocus );
|
||||
@@ -81,22 +76,6 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the mouse is within the element
|
||||
*
|
||||
* @param xCoord current x coord of the mouse
|
||||
* @param yCoord current y coord of the mouse
|
||||
*
|
||||
* @return true if mouse position is within the text field area
|
||||
*/
|
||||
public boolean isMouseIn( final int xCoord, final int yCoord )
|
||||
{
|
||||
final boolean withinXRange = this._xPos <= xCoord && xCoord < this._xPos + this._width;
|
||||
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
|
||||
|
||||
return withinXRange && withinYRange;
|
||||
}
|
||||
|
||||
public void selectAll()
|
||||
{
|
||||
this.setCursorPosition( 0 );
|
||||
@@ -109,7 +88,7 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox()
|
||||
public void renderButton(int mouseX, int mouseY, float partial)
|
||||
{
|
||||
if( this.getVisible() )
|
||||
{
|
||||
@@ -123,7 +102,7 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFFA8A8A8 );
|
||||
}
|
||||
super.drawTextBox();
|
||||
super.renderButton(mouseX, mouseY, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,16 +152,16 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
float alpha = ( this.selectionColor >> 24 & 255 ) / 255.0F;
|
||||
|
||||
RenderSystem.color4f( red, green, blue, alpha );
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableColorLogic();
|
||||
GlStateManager.colorLogicOp( GlStateManager.LogicOp.OR_REVERSE );
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp( GlStateManager.LogicOp.OR_REVERSE );
|
||||
bufferbuilder.begin( 7, DefaultVertexFormats.POSITION );
|
||||
bufferbuilder.pos( startX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, startY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( startX, startY, 0.0D ).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.disableColorLogic();
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,22 +21,46 @@ package appeng.client.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.util.Direction;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public abstract class DelegateBakedModel implements IBakedModel
|
||||
{
|
||||
private IBakedModel baseModel;
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
protected DelegateBakedModel( IBakedModel base )
|
||||
{
|
||||
this.baseModel = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return baseModel.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return baseModel.func_230044_c_();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return baseModel.getOverrides();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
|
||||
{
|
||||
@@ -62,6 +86,19 @@ public abstract class DelegateBakedModel implements IBakedModel
|
||||
return this.baseModel.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return this.baseModel.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
|
||||
public IBakedModel getBaseModel()
|
||||
{
|
||||
return this.baseModel;
|
||||
|
||||
@@ -32,6 +32,8 @@ import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
@@ -53,9 +55,9 @@ import appeng.fluids.items.FluidDummyItem;
|
||||
*/
|
||||
public class DummyFluidDispatcherBakedModel extends DelegateBakedModel
|
||||
{
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter;
|
||||
private final Function<Material, TextureAtlasSprite> bakedTextureGetter;
|
||||
|
||||
public DummyFluidDispatcherBakedModel( IBakedModel baseModel, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
public DummyFluidDispatcherBakedModel( IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
super( baseModel );
|
||||
this.bakedTextureGetter = bakedTextureGetter;
|
||||
@@ -108,7 +110,9 @@ public class DummyFluidDispatcherBakedModel extends DelegateBakedModel
|
||||
}
|
||||
|
||||
FluidAttributes attributes = fluidStack.getFluid().getAttributes();
|
||||
TextureAtlasSprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply( attributes.getStillTexture( fluidStack ) );
|
||||
ResourceLocation stillTexture = attributes.getStillTexture(fluidStack);
|
||||
Material stillMaterial = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, stillTexture);
|
||||
TextureAtlasSprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply(stillMaterial);
|
||||
if( sprite == null )
|
||||
{
|
||||
return new DummyFluidBakedModel( ImmutableList.of() );
|
||||
|
||||
@@ -19,71 +19,39 @@
|
||||
package appeng.client.render;
|
||||
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
/**
|
||||
* The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other
|
||||
* than the cable anchor.
|
||||
*/
|
||||
public class DummyFluidItemModel implements IModel
|
||||
public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
|
||||
{
|
||||
// We use this to get the default item transforms and make our lives easier
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/dummy_fluid_item_base" );
|
||||
|
||||
private IModel baseModel = null;
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||
|
||||
private IModel getBaseModel()
|
||||
{
|
||||
if( this.baseModel == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.baseModel = ModelLoaderRegistry.getModel( MODEL_BASE );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
return this.baseModel;
|
||||
return new DummyFluidDispatcherBakedModel( bakedBaseModel, spriteGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
IBakedModel bakedBaseModel = this.getBaseModel().bake( state, format, bakedTextureGetter );
|
||||
|
||||
return new DummyFluidDispatcherBakedModel( bakedBaseModel, bakedTextureGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return this.getBaseModel().getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A quaint model loader that does not accept any additional parameters in JSON.
|
||||
*/
|
||||
public class SimpleModelLoader<T extends IModelGeometry<T>> implements IModelLoader<T> {
|
||||
|
||||
private final Supplier<T> factory;
|
||||
|
||||
public SimpleModelLoader(Supplier<T> factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
return factory.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,25 +19,20 @@
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.block.crafting.AbstractCraftingUnitBlock;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@@ -45,38 +40,34 @@ import appeng.client.render.cablebus.CubeBuilder;
|
||||
* Primarily this base class handles adding the "ring" that frames the multi-block structure and delegates
|
||||
* rendering of the "inner" part of each block to the subclasses of this class.
|
||||
*/
|
||||
abstract class CraftingCubeBakedModel implements IBakedModel
|
||||
abstract class CraftingCubeBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
|
||||
private final VertexFormat format;
|
||||
|
||||
private final TextureAtlasSprite ringCorner;
|
||||
|
||||
private final TextureAtlasSprite ringHor;
|
||||
|
||||
private final TextureAtlasSprite ringVer;
|
||||
|
||||
CraftingCubeBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer )
|
||||
CraftingCubeBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer )
|
||||
{
|
||||
this.format = format;
|
||||
this.ringCorner = ringCorner;
|
||||
this.ringHor = ringHor;
|
||||
this.ringVer = ringVer;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
{
|
||||
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
if( side == null )
|
||||
{
|
||||
return Collections.emptyList(); // No generic quads for this model
|
||||
}
|
||||
|
||||
EnumSet<Direction> connections = getConnections( state );
|
||||
EnumSet<Direction> connections = getConnections( extraData );
|
||||
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
CubeBuilder builder = new CubeBuilder( this.format, quads );
|
||||
CubeBuilder builder = new CubeBuilder( quads );
|
||||
|
||||
builder.setDrawFaces( EnumSet.of( side ) );
|
||||
|
||||
@@ -114,7 +105,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
|
||||
break;
|
||||
}
|
||||
|
||||
this.addInnerCube( side, state, builder, x1, y1, z1, x2, y2, z2 );
|
||||
this.addInnerCube( side, state, extraData, builder, x1, y1, z1, x2, y2, z2 );
|
||||
|
||||
return quads;
|
||||
}
|
||||
@@ -194,7 +185,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
|
||||
// drawn in those directions. Since a corner is drawn if the three touching faces dont have adjacent
|
||||
// crafting cube blocks, we'd have to check for a, side, and the perpendicular direction. But in this
|
||||
// block, we've already checked for side (due to face culling) and a (see above).
|
||||
Direction perpendicular = a.rotateAround( side.getAxis() );
|
||||
Direction perpendicular = Platform.rotateAround( a, side );
|
||||
for( Direction cornerCandidate : EnumSet.of( perpendicular, perpendicular.getOpposite() ) )
|
||||
{
|
||||
if( !connections.contains( cornerCandidate ) )
|
||||
@@ -256,15 +247,9 @@ abstract class CraftingCubeBakedModel implements IBakedModel
|
||||
|
||||
// Retrieve the cube connection state from the block state
|
||||
// If none is present, just assume there are no adjacent crafting cube blocks
|
||||
private static EnumSet<Direction> getConnections( @Nullable BlockState state )
|
||||
private static EnumSet<Direction> getConnections( IModelData modelData )
|
||||
{
|
||||
if( !( state instanceof IExtendedBlockState ) )
|
||||
{
|
||||
return EnumSet.noneOf( Direction.class );
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
CraftingCubeState cubeState = extState.getValue( AbstractCraftingUnitBlock.STATE );
|
||||
CraftingCubeState cubeState = modelData.getData( TileCraftingTile.STATE );
|
||||
if( cubeState == null )
|
||||
{
|
||||
return EnumSet.noneOf( Direction.class );
|
||||
@@ -273,7 +258,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
|
||||
return cubeState.getConnections();
|
||||
}
|
||||
|
||||
protected abstract void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 );
|
||||
protected abstract void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2);
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
@@ -300,14 +285,13 @@ abstract class CraftingCubeBakedModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
public ItemOverrideList getOverrides() {
|
||||
return ItemOverrideList.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,44 +19,42 @@
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.block.crafting.AbstractCraftingUnitBlock;
|
||||
import appeng.core.AppEng;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
/**
|
||||
* The built-in model for the connected texture crafting cube.
|
||||
*/
|
||||
class CraftingCubeModel implements IModel
|
||||
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel>
|
||||
{
|
||||
|
||||
private final static ResourceLocation RING_CORNER = texture( "ring_corner" );
|
||||
private final static ResourceLocation RING_SIDE_HOR = texture( "ring_side_hor" );
|
||||
private final static ResourceLocation RING_SIDE_VER = texture( "ring_side_ver" );
|
||||
private final static ResourceLocation UNIT_BASE = texture( "unit_base" );
|
||||
private final static ResourceLocation LIGHT_BASE = texture( "light_base" );
|
||||
private final static ResourceLocation ACCELERATOR_LIGHT = texture( "accelerator_light" );
|
||||
private final static ResourceLocation STORAGE_1K_LIGHT = texture( "storage_1k_light" );
|
||||
private final static ResourceLocation STORAGE_4K_LIGHT = texture( "storage_4k_light" );
|
||||
private final static ResourceLocation STORAGE_16K_LIGHT = texture( "storage_16k_light" );
|
||||
private final static ResourceLocation STORAGE_64K_LIGHT = texture( "storage_64k_light" );
|
||||
private final static ResourceLocation MONITOR_BASE = texture( "monitor_base" );
|
||||
private final static ResourceLocation MONITOR_LIGHT_DARK = texture( "monitor_light_dark" );
|
||||
private final static ResourceLocation MONITOR_LIGHT_MEDIUM = texture( "monitor_light_medium" );
|
||||
private final static ResourceLocation MONITOR_LIGHT_BRIGHT = texture( "monitor_light_bright" );
|
||||
private final static Material RING_CORNER = texture( "ring_corner" );
|
||||
private final static Material RING_SIDE_HOR = texture( "ring_side_hor" );
|
||||
private final static Material RING_SIDE_VER = texture( "ring_side_ver" );
|
||||
private final static Material UNIT_BASE = texture( "unit_base" );
|
||||
private final static Material LIGHT_BASE = texture( "light_base" );
|
||||
private final static Material ACCELERATOR_LIGHT = texture( "accelerator_light" );
|
||||
private final static Material STORAGE_1K_LIGHT = texture( "storage_1k_light" );
|
||||
private final static Material STORAGE_4K_LIGHT = texture( "storage_4k_light" );
|
||||
private final static Material STORAGE_16K_LIGHT = texture( "storage_16k_light" );
|
||||
private final static Material STORAGE_64K_LIGHT = texture( "storage_64k_light" );
|
||||
private final static Material MONITOR_BASE = texture( "monitor_base" );
|
||||
private final static Material MONITOR_LIGHT_DARK = texture( "monitor_light_dark" );
|
||||
private final static Material MONITOR_LIGHT_MEDIUM = texture( "monitor_light_medium" );
|
||||
private final static Material MONITOR_LIGHT_BRIGHT = texture( "monitor_light_bright" );
|
||||
|
||||
private final AbstractCraftingUnitBlock.CraftingUnitType type;
|
||||
|
||||
@@ -66,47 +64,39 @@ class CraftingCubeModel implements IModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return ImmutableList.of( RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT, STORAGE_1K_LIGHT, STORAGE_4K_LIGHT,
|
||||
STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE, MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
// Retrieve our textures and pass them on to the baked model
|
||||
TextureAtlasSprite ringCorner = bakedTextureGetter.apply( RING_CORNER );
|
||||
TextureAtlasSprite ringSideHor = bakedTextureGetter.apply( RING_SIDE_HOR );
|
||||
TextureAtlasSprite ringSideVer = bakedTextureGetter.apply( RING_SIDE_VER );
|
||||
TextureAtlasSprite ringCorner = spriteGetter.apply( RING_CORNER );
|
||||
TextureAtlasSprite ringSideHor = spriteGetter.apply( RING_SIDE_HOR );
|
||||
TextureAtlasSprite ringSideVer = spriteGetter.apply( RING_SIDE_VER );
|
||||
|
||||
switch( this.type )
|
||||
{
|
||||
case UNIT:
|
||||
return new UnitBakedModel( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter.apply( UNIT_BASE ) );
|
||||
return new UnitBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ) );
|
||||
case ACCELERATOR:
|
||||
case STORAGE_1K:
|
||||
case STORAGE_4K:
|
||||
case STORAGE_16K:
|
||||
case STORAGE_64K:
|
||||
return new LightBakedModel( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter
|
||||
.apply( LIGHT_BASE ), getLightTexture( bakedTextureGetter, this.type ) );
|
||||
return new LightBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter
|
||||
.apply( LIGHT_BASE ), getLightTexture( spriteGetter, this.type ) );
|
||||
case MONITOR:
|
||||
return new MonitorBakedModel( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter.apply( UNIT_BASE ), bakedTextureGetter
|
||||
.apply( MONITOR_BASE ), bakedTextureGetter.apply(
|
||||
MONITOR_LIGHT_DARK ), bakedTextureGetter.apply( MONITOR_LIGHT_MEDIUM ), bakedTextureGetter.apply( MONITOR_LIGHT_BRIGHT ) );
|
||||
return new MonitorBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ), spriteGetter
|
||||
.apply( MONITOR_BASE ), spriteGetter.apply(
|
||||
MONITOR_LIGHT_DARK ), spriteGetter.apply( MONITOR_LIGHT_MEDIUM ), spriteGetter.apply( MONITOR_LIGHT_BRIGHT ) );
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unsupported crafting unit type: " + this.type );
|
||||
}
|
||||
}
|
||||
|
||||
private static TextureAtlasSprite getLightTexture( Function<ResourceLocation, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
|
||||
private static TextureAtlasSprite getLightTexture( Function<Material, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
@@ -125,14 +115,8 @@ class CraftingCubeModel implements IModel
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
private static Material texture( String name )
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
private static ResourceLocation texture( String name )
|
||||
{
|
||||
return new ResourceLocation( AppEng.MOD_ID, "blocks/crafting/" + name );
|
||||
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "blocks/crafting/" + name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import appeng.block.crafting.AbstractCraftingUnitBlock;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
|
||||
|
||||
/**
|
||||
* Loader that allows access to the built-in crafting cube model from block-model JSONs.
|
||||
*/
|
||||
public class CraftingCubeModelLoader implements IModelLoader<CraftingCubeModel>
|
||||
{
|
||||
|
||||
public static final CraftingCubeModelLoader INSTANCE = new CraftingCubeModelLoader();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftingCubeModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
AbstractCraftingUnitBlock.CraftingUnitType unitType = null;
|
||||
|
||||
JsonElement typeEl = modelContents.get("type");
|
||||
if (typeEl != null) {
|
||||
String typeName = deserializationContext.deserialize(typeEl, String.class);
|
||||
if (typeName != null) {
|
||||
unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase());
|
||||
}
|
||||
}
|
||||
if (unitType == null) {
|
||||
throw new JsonParseException("type property is missing");
|
||||
}
|
||||
|
||||
return new CraftingCubeModel(unitType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
/**
|
||||
* This special model handles switching between rendering the crafting output of an encoded pattern (when shift is being
|
||||
* held), and showing the encoded pattern itself. Matters are further complicated by only wanting to show the crafting output when
|
||||
* the pattern is being rendered in the GUI, and not anywhere else.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class EncodedPatternRenderer extends ItemStackTileEntityRenderer {
|
||||
|
||||
@Override
|
||||
public void render(ItemStack is, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
|
||||
|
||||
/**
|
||||
* This special model handles switching between rendering the crafting output of an encoded pattern (when shift is being
|
||||
* held), and
|
||||
* showing the encoded pattern itself. Matters are further complicated by only wanting to show the crafting output when
|
||||
* the pattern is being
|
||||
* rendered in the GUI, and not anywhere else.
|
||||
*/
|
||||
class ItemEncodedPatternBakedModel implements IBakedModel
|
||||
{
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms;
|
||||
|
||||
private final CustomOverrideList overrides;
|
||||
|
||||
ItemEncodedPatternBakedModel( IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms )
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
this.transforms = transforms;
|
||||
this.overrides = new CustomOverrideList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
{
|
||||
return this.baseModel.getQuads( state, side, rand );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return this.baseModel.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return this.baseModel.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.baseModel.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return this.baseModel.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return this.overrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType )
|
||||
{
|
||||
if( this.baseModel instanceof IBakedModel )
|
||||
{
|
||||
return this.baseModel.handlePerspective( cameraTransformType );
|
||||
}
|
||||
|
||||
return PerspectiveMapWrapper.handlePerspective( this, this.transforms, cameraTransformType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Since the ItemOverrideList handling comes before handling the perspective awareness (which is the first place
|
||||
* where we
|
||||
* know how we are being rendered) we need to remember the model of the crafting output, and make the decision on
|
||||
* which to render later on.
|
||||
* Sadly, Forge is pretty inconsistent when it will call the handlePerspective method, so some methods are called
|
||||
* even on this interim-model.
|
||||
* Usually those methods only matter for rendering on the ground and other cases, where we wouldn't render the
|
||||
* crafting output model anyway,
|
||||
* so in those cases we delegate to the model of the encoded pattern.
|
||||
*/
|
||||
private class ShiftHoldingModelWrapper implements IBakedModel
|
||||
{
|
||||
|
||||
private final IBakedModel outputModel;
|
||||
|
||||
private ShiftHoldingModelWrapper( IBakedModel outputModel )
|
||||
{
|
||||
this.outputModel = outputModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType )
|
||||
{
|
||||
final IBakedModel selectedModel;
|
||||
|
||||
// No need to re-check for shift being held since this model is only handed out in that case
|
||||
if( cameraTransformType == ItemCameraTransforms.TransformType.GUI )
|
||||
{
|
||||
selectedModel = this.outputModel;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedModel = ItemEncodedPatternBakedModel.this.baseModel;
|
||||
}
|
||||
|
||||
// Now retroactively handle the isGui3d call, for which we always return false below
|
||||
if( selectedModel.isGui3d() != ItemEncodedPatternBakedModel.this.baseModel.isGui3d() )
|
||||
{
|
||||
RenderSystem.enableLighting();
|
||||
}
|
||||
|
||||
if( selectedModel instanceof IBakedModel )
|
||||
{
|
||||
return selectedModel.handlePerspective( cameraTransformType );
|
||||
}
|
||||
|
||||
return PerspectiveMapWrapper.handlePerspective( this, ItemEncodedPatternBakedModel.this.transforms, cameraTransformType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
{
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getQuads( state, side, rand );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
// NOTE: Sadly, Forge will let Minecraft call this method before handling the perspective awareness
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getOverrides();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Item Override Lists are the only point during item rendering where we can access the item stack that is being
|
||||
* rendered.
|
||||
* So this is the point where we actually check if shift is being held, and if so, determine the crafting output
|
||||
* model.
|
||||
*/
|
||||
private class CustomOverrideList extends ItemOverrideList
|
||||
{
|
||||
|
||||
CustomOverrideList()
|
||||
{
|
||||
super( ItemEncodedPatternBakedModel.this.baseModel.getOverrides().getOverrides() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
|
||||
{
|
||||
boolean shiftHeld = Keyboard.isKeyDown( GLFW.GLFW_KEY_LSHIFT ) || Keyboard.isKeyDown( GLFW.GLFW_KEY_RSHIFT );
|
||||
if( shiftHeld )
|
||||
{
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
|
||||
ItemStack output = iep.getOutput( stack );
|
||||
if( !output.isEmpty() )
|
||||
{
|
||||
IBakedModel realModel = Minecraft.getInstance().getRenderItem().getItemModelMesher().getItemModel( output );
|
||||
// Give the item model a chance to handle the overrides as well
|
||||
realModel = realModel.getOverrides().handleItemState( realModel, output, world, entity );
|
||||
return new ShiftHoldingModelWrapper( realModel );
|
||||
}
|
||||
}
|
||||
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getOverrides().handleItemState( originalModel, stack, world, entity );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
/**
|
||||
* Simple model for the encoded pattern built-in baked model.
|
||||
*/
|
||||
class ItemEncodedPatternModel implements IModel
|
||||
{
|
||||
|
||||
private static final ResourceLocation BASE_MODEL = new ResourceLocation( AppEng.MOD_ID, "item/encoded_pattern" );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.singletonList( BASE_MODEL );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
IBakedModel baseModel;
|
||||
try
|
||||
{
|
||||
baseModel = ModelLoaderRegistry.getModel( BASE_MODEL ).bake( state, format, bakedTextureGetter );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms = PerspectiveMapWrapper.getTransforms( state );
|
||||
|
||||
return new ItemEncodedPatternBakedModel( baseModel, transforms );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.block.crafting.AbstractCraftingUnitBlock;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,15 +40,15 @@ class LightBakedModel extends CraftingCubeBakedModel
|
||||
|
||||
private final TextureAtlasSprite lightTexture;
|
||||
|
||||
LightBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture )
|
||||
LightBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture )
|
||||
{
|
||||
super( format, ringCorner, ringHor, ringVer );
|
||||
super( ringCorner, ringHor, ringVer );
|
||||
this.baseTexture = baseTexture;
|
||||
this.lightTexture = lightTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
|
||||
protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
{
|
||||
builder.setTexture( this.baseTexture );
|
||||
builder.addCube( x1, y1, z1, x2, y2, z2 );
|
||||
|
||||
@@ -19,15 +19,14 @@
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.crafting.BlockCraftingMonitor;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
|
||||
/**
|
||||
@@ -50,9 +49,9 @@ class MonitorBakedModel extends CraftingCubeBakedModel
|
||||
|
||||
private final TextureAtlasSprite lightBrightTexture;
|
||||
|
||||
MonitorBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture )
|
||||
MonitorBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture )
|
||||
{
|
||||
super( format, ringCorner, ringHor, ringVer );
|
||||
super( ringCorner, ringHor, ringVer );
|
||||
this.chassisTexture = chassisTexture;
|
||||
this.baseTexture = baseTexture;
|
||||
this.lightDarkTexture = lightDarkTexture;
|
||||
@@ -61,9 +60,9 @@ class MonitorBakedModel extends CraftingCubeBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addInnerCube( Direction side, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
|
||||
protected void addInnerCube(Direction side, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
{
|
||||
Direction forward = getForward( state );
|
||||
Direction forward = getForward( modelData );
|
||||
|
||||
// For sides other than the front, use the chassis texture
|
||||
if( side != forward )
|
||||
@@ -77,7 +76,7 @@ class MonitorBakedModel extends CraftingCubeBakedModel
|
||||
builder.addCube( x1, y1, z1, x2, y2, z2 );
|
||||
|
||||
// Now add the three layered light textures
|
||||
AEColor color = getColor( state );
|
||||
AEColor color = getColor( modelData );
|
||||
boolean powered = state.get( BlockCraftingMonitor.POWERED );
|
||||
|
||||
builder.setRenderFullBright( powered );
|
||||
@@ -96,31 +95,20 @@ class MonitorBakedModel extends CraftingCubeBakedModel
|
||||
|
||||
}
|
||||
|
||||
private static AEColor getColor( BlockState state )
|
||||
{
|
||||
if( state instanceof IExtendedBlockState )
|
||||
{
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
AEColor color = extState.getValue( BlockCraftingMonitor.COLOR );
|
||||
if( color != null )
|
||||
{
|
||||
return color;
|
||||
}
|
||||
private static AEColor getColor(IModelData modelData) {
|
||||
|
||||
AEColor color = modelData.getData(TileCraftingMonitorTile.COLOR);
|
||||
if (color != null) {
|
||||
return color;
|
||||
}
|
||||
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
private static Direction getForward( BlockState state )
|
||||
{
|
||||
if( state instanceof IExtendedBlockState )
|
||||
{
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
Direction forward = extState.getValue( BlockCraftingMonitor.FORWARD );
|
||||
if( forward != null )
|
||||
{
|
||||
return forward;
|
||||
}
|
||||
private static Direction getForward(IModelData modelData) {
|
||||
Direction forward = modelData.getData(BlockCraftingMonitor.FORWARD);
|
||||
if (forward != null) {
|
||||
return forward;
|
||||
}
|
||||
|
||||
return Direction.NORTH;
|
||||
|
||||
@@ -21,10 +21,10 @@ package appeng.client.render.crafting;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
|
||||
/**
|
||||
@@ -35,14 +35,14 @@ class UnitBakedModel extends CraftingCubeBakedModel
|
||||
|
||||
private final TextureAtlasSprite unitTexture;
|
||||
|
||||
UnitBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture )
|
||||
UnitBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture )
|
||||
{
|
||||
super( format, ringCorner, ringHor, ringVer );
|
||||
super( ringCorner, ringHor, ringVer );
|
||||
this.unitTexture = unitTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
|
||||
protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
{
|
||||
builder.setTexture( this.unitTexture );
|
||||
builder.addCube( x1, y1, z1, x2, y2, z2 );
|
||||
|
||||
@@ -20,12 +20,24 @@ package appeng.client.render.effects;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.command.arguments.ItemInput;
|
||||
import net.minecraft.command.arguments.ItemParser;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -33,23 +45,32 @@ import appeng.client.EffectType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.entity.EntityFloatingItem;
|
||||
import appeng.entity.ICanDie;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class AssemblerFX extends Particle implements ICanDie
|
||||
{
|
||||
|
||||
public static final ParticleType<AssemblerParticleData> TYPE = new ParticleType<>(false, new AssemblerParticleData.Deserializer());
|
||||
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "assembler_fx");
|
||||
}
|
||||
|
||||
private final EntityFloatingItem fi;
|
||||
private final float speed;
|
||||
private float time = 0;
|
||||
|
||||
public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final IAEItemStack is )
|
||||
public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final ItemStack displayItem )
|
||||
{
|
||||
super( w, x, y, z, r, g, b );
|
||||
this.motionX = 0;
|
||||
this.motionY = 0;
|
||||
this.motionZ = 0;
|
||||
this.speed = speed;
|
||||
final ItemStack displayItem = is.asItemStackRepresentation();
|
||||
this.fi = new EntityFloatingItem( this, w, x, y, z, displayItem );
|
||||
w.addEntity( this.fi );
|
||||
this.maxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
|
||||
@@ -99,7 +120,6 @@ public class AssemblerFX extends Particle implements ICanDie
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
// TODO: FIXME
|
||||
return IParticleRenderType.NO_RENDER;
|
||||
}
|
||||
|
||||
@@ -117,4 +137,102 @@ public class AssemblerFX extends Particle implements ICanDie
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class AssemblerParticleData implements IParticleData {
|
||||
|
||||
private final float r;
|
||||
private final float g;
|
||||
private final float b;
|
||||
private final float speed;
|
||||
private final ItemStack itemStack;
|
||||
|
||||
public AssemblerParticleData(float r, float g, float b, float speed, ItemStack itemStack) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.speed = speed;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeFloat(r);
|
||||
buffer.writeFloat(g);
|
||||
buffer.writeFloat(b);
|
||||
buffer.writeFloat(speed);
|
||||
buffer.writeItemStack(itemStack);
|
||||
}
|
||||
|
||||
public static class Deserializer implements IDeserializer<AssemblerParticleData> {
|
||||
|
||||
@Override
|
||||
public AssemblerParticleData deserialize(ParticleType<AssemblerParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
|
||||
reader.expect(' ');
|
||||
float r = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float g = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float b = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float speed = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
ItemParser itemparser = (new ItemParser(reader, false)).parse();
|
||||
ItemStack itemstack = (new ItemInput(itemparser.getItem(), itemparser.getNbt())).createStack(1, false);
|
||||
return new AssemblerParticleData(r, g, b, speed, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssemblerParticleData read(ParticleType<AssemblerParticleData> particleTypeIn, PacketBuffer buffer) {
|
||||
float r = buffer.readFloat();
|
||||
float g = buffer.readFloat();
|
||||
float b = buffer.readFloat();
|
||||
float speed = buffer.readFloat();
|
||||
ItemStack itemStack = buffer.readItemStack();
|
||||
return new AssemblerParticleData(r, g, b, speed, itemStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameters() {
|
||||
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f ", Registry.PARTICLE_TYPE.getKey(this.getType()), this.r, this.g, this.b, this.speed)
|
||||
+ (new ItemInput(this.itemStack.getItem(), this.itemStack.getTag())).serialize();
|
||||
}
|
||||
|
||||
public float getR() {
|
||||
return r;
|
||||
}
|
||||
|
||||
public float getG() {
|
||||
return g;
|
||||
}
|
||||
|
||||
public float getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<AssemblerParticleData> {
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
}
|
||||
|
||||
public Particle makeParticle(AssemblerParticleData data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new AssemblerFX(world, x, y, z, data.r, data.g, data.b, data.speed, data.itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,130 +19,120 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
|
||||
import net.minecraft.client.particle.BreakingParticle;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.particles.ItemParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.render.textures.ParticleTextures;
|
||||
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class CraftingFx extends BreakingParticle
|
||||
{
|
||||
|
||||
private final TextureAtlasSprite particleTextureIndex;
|
||||
public static final BasicParticleType TYPE = new BasicParticleType(false);
|
||||
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "crafting_fx");
|
||||
}
|
||||
|
||||
private final int startBlkX;
|
||||
private final int startBlkY;
|
||||
private final int startBlkZ;
|
||||
|
||||
public CraftingFx( final World par1World, final double par2, final double par4, final double par6, final Item par8Item )
|
||||
public CraftingFx( final World par1World, final double x, final double y, final double z, final IAnimatedSprite sprite )
|
||||
{
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 0.9f;
|
||||
this.particleRed = 1;
|
||||
this.particleAlpha = 1.3f;
|
||||
this.particleScale = 1.5f;
|
||||
this.particleTextureIndex = ParticleTextures.BlockEnergyParticle;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
this.maxAge /= 1.2;
|
||||
|
||||
this.startBlkX = MathHelper.floor( this.getPosX() );
|
||||
this.startBlkY = MathHelper.floor( this.getPosY() );
|
||||
this.startBlkZ = MathHelper.floor( this.getPosZ() );
|
||||
this.startBlkX = MathHelper.floor( this.posX );
|
||||
this.startBlkY = MathHelper.floor( this.posY );
|
||||
this.startBlkZ = MathHelper.floor( this.posZ );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
// TODO: FIXME
|
||||
return IParticleRenderType.NO_RENDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle( final BufferBuilder par1Tessellator, final Entity p_180434_2_, final float partialTick, final float x, final float y, final float z, final float rx, final float rz )
|
||||
{
|
||||
if( partialTick < 0 || partialTick > 1 )
|
||||
if( partialTicks < 0 || partialTicks > 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final float f6 = this.particleTextureIndex.getMinU();
|
||||
final float f7 = this.particleTextureIndex.getMaxU();
|
||||
final float f8 = this.particleTextureIndex.getMinV();
|
||||
final float f9 = this.particleTextureIndex.getMaxV();
|
||||
final float scale = 0.1F * this.particleScale;
|
||||
|
||||
float offX = (float) ( this.prevPosX + ( this.getPosX() - this.prevPosX ) * partialTick );
|
||||
float offY = (float) ( this.prevPosY + ( this.getPosY() - this.prevPosY ) * partialTick );
|
||||
float offZ = (float) ( this.prevPosZ + ( this.getPosZ() - this.prevPosZ ) * partialTick );
|
||||
float offX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX));
|
||||
float offY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY));
|
||||
float offZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ));
|
||||
|
||||
final int blkX = MathHelper.floor( offX );
|
||||
final int blkY = MathHelper.floor( offY );
|
||||
final int blkZ = MathHelper.floor( offZ );
|
||||
// I believe this particle is same as breaking particle, but should not exit the original block it was
|
||||
// spawned in (which is encased in glass)
|
||||
if( blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ )
|
||||
{
|
||||
offX -= interpPosX;
|
||||
offY -= interpPosY;
|
||||
offZ -= interpPosZ;
|
||||
Vec3d vec3d = renderInfo.getProjectedView();
|
||||
offX -= vec3d.x;
|
||||
offY -= vec3d.y;
|
||||
offZ -= vec3d.z;
|
||||
|
||||
int i = this.getBrightnessForRender( partialTick );
|
||||
int j = i >> 16 & 65535;
|
||||
int k = i & 65535;
|
||||
Vector3f[] avector3f = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)};
|
||||
float scale = this.getScale(partialTicks);
|
||||
|
||||
// AELog.info( "" + partialTick );
|
||||
final float f14 = 1.0F;
|
||||
par1Tessellator.pos( offX - x * scale - rx * scale, offY - y * scale, offZ - z * scale - rz * scale )
|
||||
.tex( f7, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( offX - x * scale + rx * scale, offY + y * scale, offZ - z * scale + rz * scale )
|
||||
.tex( f7, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( offX + x * scale + rx * scale, offY + y * scale, offZ + z * scale + rz * scale )
|
||||
.tex( f6, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( offX + x * scale - rx * scale, offY - y * scale, offZ + z * scale - rz * scale )
|
||||
.tex( f6, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
Vector3f vector3f = avector3f[i];
|
||||
vector3f.transform(renderInfo.getRotation());
|
||||
vector3f.mul(scale);
|
||||
vector3f.add(offX, offY, offZ);
|
||||
}
|
||||
|
||||
float minU = this.getMinU();
|
||||
float maxU = this.getMaxU();
|
||||
float minV = this.getMinV();
|
||||
float maxV = this.getMaxV();
|
||||
int j = this.getBrightnessForRender(partialTicks);
|
||||
buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
public void fromItem( final AEPartLocation d )
|
||||
{
|
||||
this.getPosX() += 0.2 * d.xOffset;
|
||||
this.getPosY() += 0.2 * d.yOffset;
|
||||
this.getPosZ() += 0.2 * d.zOffset;
|
||||
this.posX += 0.2 * d.xOffset;
|
||||
this.posY += 0.2 * d.yOffset;
|
||||
this.posZ += 0.2 * d.zOffset;
|
||||
this.particleScale *= 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
this.prevPosX = this.getPosX();
|
||||
this.prevPosY = this.getPosY();
|
||||
this.prevPosZ = this.getPosZ();
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
||||
if( this.age++ >= this.maxAge )
|
||||
{
|
||||
@@ -172,4 +162,18 @@ public class CraftingFx extends BreakingParticle
|
||||
{
|
||||
this.motionZ = motionZ;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<BasicParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite p_i50477_1_) {
|
||||
this.spriteSet = p_i50477_1_;
|
||||
}
|
||||
|
||||
public Particle makeParticle(BasicParticleType data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new CraftingFx(worldIn, x, y, z, spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
|
||||
import net.minecraft.client.particle.BreakingParticle;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -38,22 +40,26 @@ import appeng.api.util.AEPartLocation;
|
||||
public class EnergyFx extends BreakingParticle
|
||||
{
|
||||
|
||||
// FIXME private final TextureAtlasSprite particleTextureIndex;
|
||||
public static final BasicParticleType TYPE = new BasicParticleType(false);
|
||||
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "energy_fx");
|
||||
}
|
||||
|
||||
private final int startBlkX;
|
||||
private final int startBlkY;
|
||||
private final int startBlkZ;
|
||||
|
||||
public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final ItemStack par8Item )
|
||||
public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final IAnimatedSprite sprite )
|
||||
{
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
super( par1World, par2, par4, par6, new ItemStack(Items.DIAMOND) );
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 1;
|
||||
this.particleRed = 1;
|
||||
this.particleAlpha = 1.4f;
|
||||
this.particleScale = 3.5f;
|
||||
// FIXME this.particleTextureIndex = ParticleTextures.BlockEnergyParticle;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
|
||||
this.startBlkX = MathHelper.floor( this.posX );
|
||||
this.startBlkY = MathHelper.floor( this.posY );
|
||||
@@ -163,4 +169,22 @@ public class EnergyFx extends BreakingParticle
|
||||
{
|
||||
this.motionZ = motionZ;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<BasicParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
EnergyFx result = new EnergyFx(worldIn, x, y, z, spriteSet);
|
||||
result.setMotionX((float) xSpeed);
|
||||
result.setMotionY((float) ySpeed);
|
||||
result.setMotionZ((float) zSpeed);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,23 @@ package appeng.client.render.effects;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
public class LightningArcFX extends LightningFX
|
||||
{
|
||||
public static final ParticleType<LightningArcParticleData> TYPE = new ParticleType<>(false, LightningArcParticleData.DESERIALIZER);
|
||||
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx");
|
||||
}
|
||||
|
||||
private static final Random RANDOM_GENERATOR = new Random();
|
||||
|
||||
private final double rx;
|
||||
@@ -61,4 +73,20 @@ public class LightningArcFX extends LightningFX
|
||||
localSteps[s][2] = ( lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<LightningArcParticleData> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
SpriteTexturedParticle lightningFX = new LightningArcFX(worldIn, x, y, z, data.target.x, data.target.y, data.target.z, 0, 0, 0);
|
||||
lightningFX.selectSpriteRandomly(this.spriteSet);
|
||||
return lightningFX;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.sun.javafx.geom.Vec3f;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Contains the target point of the lightning arc (the source point is infered from the particle starting position).
|
||||
*/
|
||||
public class LightningArcParticleData implements IParticleData {
|
||||
|
||||
public final Vec3f target;
|
||||
|
||||
public LightningArcParticleData(Vec3f target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public static final IDeserializer<LightningArcParticleData> DESERIALIZER = new IDeserializer<LightningArcParticleData>() {
|
||||
@Override
|
||||
public LightningArcParticleData deserialize(ParticleType<LightningArcParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
|
||||
reader.expect(' ');
|
||||
float x = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float y = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float z = reader.readFloat();
|
||||
return new LightningArcParticleData(new Vec3f(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn, PacketBuffer buffer) {
|
||||
float x = buffer.readFloat();
|
||||
float y = buffer.readFloat();
|
||||
float z = buffer.readFloat();
|
||||
return new LightningArcParticleData(new Vec3f(x, y, z));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
return LightningArcFX.TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeFloat(target.x);
|
||||
buffer.writeFloat(target.y);
|
||||
buffer.writeFloat(target.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameters() {
|
||||
return String.format(Locale.ROOT, "%.2f %.2f %.2f", target.x, target.y, target.z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class LightningFX extends SpriteTexturedParticle
|
||||
this.regen();
|
||||
}
|
||||
|
||||
private LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final int maxAge )
|
||||
protected LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final int maxAge )
|
||||
{
|
||||
super( w, x, y, z, r, g, b );
|
||||
this.precomputedSteps = new double[LightningFX.STEPS][3];
|
||||
|
||||
@@ -19,26 +19,37 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.particle.BreakingParticle;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.render.textures.ParticleTextures;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
public class MatterCannonFX extends BreakingParticle
|
||||
{
|
||||
|
||||
private final TextureAtlasSprite particleTextureIndex;
|
||||
public static final BasicParticleType TYPE = new BasicParticleType(false);
|
||||
|
||||
public MatterCannonFX( final World par1World, final double par2, final double par4, final double par6, final ItemStack par8Item )
|
||||
static {
|
||||
TYPE.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx");
|
||||
}
|
||||
|
||||
public MatterCannonFX( final World par1World, final double x, final double y, final double z, IAnimatedSprite sprite )
|
||||
{
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 1;
|
||||
@@ -48,7 +59,7 @@ public class MatterCannonFX extends BreakingParticle
|
||||
this.motionX = 0.0f;
|
||||
this.motionY = 0.0f;
|
||||
this.motionZ = 0.0f;
|
||||
this.particleTextureIndex = ParticleTextures.BlockMatterCannonParticle;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
}
|
||||
|
||||
public void fromItem( final AEPartLocation d )
|
||||
@@ -78,49 +89,17 @@ public class MatterCannonFX extends BreakingParticle
|
||||
this.particleAlpha *= 0.59f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Factory implements IParticleFactory<BasicParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
public Particle makeParticle(BasicParticleType data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new MatterCannonFX(world, x, y, z, spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle( final BufferBuilder par1Tessellator, final Entity p_180434_2_, final float par2, final float par3, final float par4, final float par5, final float par6, final float par7 )
|
||||
{
|
||||
final float f6 = this.particleTextureIndex.getMinU();
|
||||
final float f7 = this.particleTextureIndex.getMaxU();
|
||||
final float f8 = this.particleTextureIndex.getMinV();
|
||||
final float f9 = this.particleTextureIndex.getMaxV();
|
||||
final float f10 = 0.05F * this.particleScale;
|
||||
|
||||
final float f11 = (float) ( this.prevPosX + ( this.posX - this.prevPosX ) * par2 - interpPosX );
|
||||
final float f12 = (float) ( this.prevPosY + ( this.posY - this.prevPosY ) * par2 - interpPosY );
|
||||
final float f13 = (float) ( this.prevPosZ + ( this.posZ - this.prevPosZ ) * par2 - interpPosZ );
|
||||
final float f14 = 1.0F;
|
||||
|
||||
int i = this.getBrightnessForRender( par2 );
|
||||
int j = i >> 16 & 65535;
|
||||
int k = i & 65535;
|
||||
|
||||
par1Tessellator.pos( f11 - par3 * f10 - par6 * f10, f12 - par4 * f10, f13 - par5 * f10 - par7 * f10 )
|
||||
.tex( f7, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( f11 - par3 * f10 + par6 * f10, f12 + par4 * f10, f13 - par5 * f10 + par7 * f10 )
|
||||
.tex( f7, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( f11 + par3 * f10 + par6 * f10, f12 + par4 * f10, f13 + par5 * f10 + par7 * f10 )
|
||||
.tex( f6, f8 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
par1Tessellator.pos( f11 + par3 * f10 - par6 * f10, f12 - par4 * f10, f13 + par5 * f10 - par7 * f10 )
|
||||
.tex( f6, f9 )
|
||||
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
|
||||
.lightmap( j, k )
|
||||
.endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,48 +9,41 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
|
||||
/**
|
||||
* Model wrapper for the biometric card item model, which combines a base card layer with a "visual hash" of the player
|
||||
* name
|
||||
*/
|
||||
public class BiometricCardModel implements IUnbakedModel
|
||||
public class BiometricCardModel implements IModelGeometry<BiometricCardModel>
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/biometric_card" );
|
||||
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/biometric_card_hash" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.singletonList( MODEL_BASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
public Collection<Material> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
return Collections.singleton( TEXTURE );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform transformIn, ItemOverrideList overrides, ResourceLocation locationIn )
|
||||
{
|
||||
TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
|
||||
TextureAtlasSprite texture = spriteGetter.apply( TEXTURE );
|
||||
|
||||
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
|
||||
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, transformIn, spriteGetter );
|
||||
|
||||
return new BiometricCardBakedModel( baseModel, texture );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
|
||||
|
||||
/**
|
||||
* Manages built-in models.
|
||||
*/
|
||||
public class BuiltInModelLoader implements IModelLoader
|
||||
{
|
||||
|
||||
private final Map<String, IUnbakedModel> builtInModels;
|
||||
|
||||
public BuiltInModelLoader( Map<String, IUnbakedModel> builtInModels )
|
||||
{
|
||||
this.builtInModels = ImmutableMap.copyOf( builtInModels );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts( ResourceLocation modelLocation )
|
||||
{
|
||||
if( !modelLocation.getNamespace().equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.builtInModels.containsKey( modelLocation.getResourcePath() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel( ResourceLocation modelLocation ) throws Exception
|
||||
{
|
||||
return this.builtInModels.get( modelLocation.getResourcePath() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload( IResourceManager resourceManager )
|
||||
{
|
||||
for( IModel model : this.builtInModels.values() )
|
||||
{
|
||||
if( model instanceof IResourceManagerReloadListener )
|
||||
{
|
||||
( (IResourceManagerReloadListener) model ).onResourceManagerReload( resourceManager );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,24 +10,22 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
|
||||
/**
|
||||
* A color applicator uses the base model, and extends it with additional layers that are colored according to the
|
||||
* selected color of the applicator.
|
||||
*/
|
||||
public class ColorApplicatorModel implements IUnbakedModel
|
||||
public class ColorApplicatorModel implements IModelGeometry<ColorApplicatorModel>
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_colored" );
|
||||
@@ -37,27 +35,18 @@ public class ColorApplicatorModel implements IUnbakedModel
|
||||
private static final Material TEXTURE_BRIGHT = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_bright" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.singletonList( MODEL_BASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Arrays.asList( TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
{
|
||||
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter );
|
||||
|
||||
TextureAtlasSprite texDark = spriteGetterIn.apply( TEXTURE_DARK );
|
||||
TextureAtlasSprite texMedium = spriteGetterIn.apply( TEXTURE_MEDIUM );
|
||||
TextureAtlasSprite texBright = spriteGetterIn.apply( TEXTURE_BRIGHT );
|
||||
TextureAtlasSprite texDark = spriteGetter.apply( TEXTURE_DARK );
|
||||
TextureAtlasSprite texMedium = spriteGetter.apply( TEXTURE_MEDIUM );
|
||||
TextureAtlasSprite texBright = spriteGetter.apply( TEXTURE_BRIGHT );
|
||||
|
||||
return new ColorApplicatorBakedModel( baseModel, transformIn, texDark, texMedium, texBright );
|
||||
return new ColorApplicatorBakedModel( baseModel, modelTransform, texDark, texMedium, texBright );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,53 +19,48 @@
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.DelegateBakedModel;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.block.storage.BlockDrive;
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class DriveBakedModel implements IBakedModel
|
||||
public class DriveBakedModel extends DelegateBakedModel
|
||||
{
|
||||
private final IBakedModel bakedBase;
|
||||
private final Map<DriveSlotState, IBakedModel> bakedCells;
|
||||
|
||||
public DriveBakedModel( IBakedModel bakedBase, Map<DriveSlotState, IBakedModel> bakedCells )
|
||||
{
|
||||
super(bakedBase);
|
||||
this.bakedBase = bakedBase;
|
||||
this.bakedCells = bakedCells;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
{
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
|
||||
List<BakedQuad> result = new ArrayList<>();
|
||||
List<BakedQuad> result = new ArrayList<>(this.bakedBase.getQuads(state, side, rand, extraData));
|
||||
|
||||
result.addAll( this.bakedBase.getQuads( state, side, rand ) );
|
||||
DriveSlotsState slotsState = extraData.getData( TileDrive.SLOTS_STATE );
|
||||
|
||||
if( side == null && state instanceof IExtendedBlockState )
|
||||
if( side == null && slotsState != null )
|
||||
{
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
DriveSlotsState slotsState = extState.getValue( BlockDrive.SLOTS_STATE );
|
||||
|
||||
for( int row = 0; row < 5; row++ )
|
||||
{
|
||||
for( int col = 0; col < 2; col++ )
|
||||
@@ -82,12 +77,12 @@ public class DriveBakedModel implements IBakedModel
|
||||
float xOffset = -col * 7 / 16.0f;
|
||||
float yOffset = -row * 3 / 16.0f;
|
||||
|
||||
transform.setTranslation( new Vector3f( xOffset, yOffset, 0 ) );
|
||||
transform.setTranslation( xOffset, yOffset, 0 );
|
||||
|
||||
MatrixVertexTransformer transformer = new MatrixVertexTransformer( transform );
|
||||
for( BakedQuad bakedQuad : bakedCell.getQuads( state, null, rand ) )
|
||||
for( BakedQuad bakedQuad : bakedCell.getQuads( state, null, rand, extraData ) )
|
||||
{
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( bakedQuad.getFormat() );
|
||||
BakedQuadBuilder builder = new BakedQuadBuilder();
|
||||
transformer.setParent( builder );
|
||||
transformer.setVertexFormat( builder.getVertexFormat() );
|
||||
bakedQuad.pipe( transformer );
|
||||
@@ -100,39 +95,4 @@ public class DriveBakedModel implements IBakedModel
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return this.bakedBase.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return this.bakedBase.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return this.bakedBase.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.bakedBase.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return this.bakedBase.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return this.bakedBase.getOverrides();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,28 +19,19 @@
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
|
||||
|
||||
public class DriveModel implements IModel
|
||||
public class DriveModel implements IModelGeometry<DriveModel>
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( "appliedenergistics2:block/drive_base" );
|
||||
@@ -53,45 +44,23 @@ public class DriveModel implements IModel
|
||||
DriveSlotState.FULL, new ResourceLocation( "appliedenergistics2:block/drive_cell_full" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return ImmutableList.<ResourceLocation>builder().add( MODEL_BASE ).addAll( MODELS_CELLS.values() ).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
EnumMap<DriveSlotState, IBakedModel> cellModels = new EnumMap<>( DriveSlotState.class );
|
||||
|
||||
// Load the base model and the model for each cell state.
|
||||
IModel baseModel;
|
||||
try
|
||||
for( DriveSlotState slotState : MODELS_CELLS.keySet() )
|
||||
{
|
||||
baseModel = ModelLoaderRegistry.getModel( MODEL_BASE );
|
||||
for( DriveSlotState slotState : MODELS_CELLS.keySet() )
|
||||
{
|
||||
IModel model = ModelLoaderRegistry.getModel( MODELS_CELLS.get( slotState ) );
|
||||
cellModels.put( slotState, model.bake( state, format, bakedTextureGetter ) );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
IBakedModel cellModel = bakery.getBakedModel( MODELS_CELLS.get( slotState ), modelTransform, spriteGetter );
|
||||
cellModels.put( slotState, cellModel );
|
||||
}
|
||||
|
||||
IBakedModel bakedBase = baseModel.bake( state, format, bakedTextureGetter );
|
||||
return new DriveBakedModel( bakedBase, cellModels );
|
||||
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter );
|
||||
return new DriveBakedModel( baseModel, cellModels );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package appeng.client.render.model;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
|
||||
public class GlassModelLoader implements IModelLoader<GlassModel> {
|
||||
|
||||
public static final GlassModelLoader INSTANCE = new GlassModelLoader();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlassModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
return new GlassModel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,47 +9,40 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
|
||||
/**
|
||||
* Model wrapper for the memory card item model, which combines a base card layer with a "visual hash" of the part/tile.
|
||||
*/
|
||||
public class MemoryCardModel implements IUnbakedModel
|
||||
public class MemoryCardModel implements IModelGeometry<MemoryCardModel>
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card" );
|
||||
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.singletonList( MODEL_BASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
public Collection<Material> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
return Collections.singleton( TEXTURE );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
|
||||
TextureAtlasSprite texture = spriteGetter.apply( TEXTURE );
|
||||
|
||||
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
|
||||
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter );
|
||||
|
||||
return new MemoryCardBakedModel( baseModel, texture );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
|
||||
|
||||
/**
|
||||
* Allows the built-in sky compass model the be loaded from JSON.
|
||||
*/
|
||||
public class SkyCompassModelLoader implements IModelLoader<SkyCompassModel> {
|
||||
|
||||
public static final SkyCompassModelLoader INSTANCE = new SkyCompassModelLoader();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkyCompassModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
return new SkyCompassModel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,50 +19,43 @@
|
||||
package appeng.client.render.spatial;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.block.spatial.BlockSpatialPylon;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.tile.spatial.TileSpatialPylon;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
/**
|
||||
* The baked model that will be used for rendering the spatial pylon.
|
||||
*/
|
||||
class SpatialPylonBakedModel implements IBakedModel
|
||||
class SpatialPylonBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
|
||||
private final Map<SpatialPylonTextureType, TextureAtlasSprite> textures;
|
||||
|
||||
private final VertexFormat format;
|
||||
|
||||
SpatialPylonBakedModel( VertexFormat format, Map<SpatialPylonTextureType, TextureAtlasSprite> textures )
|
||||
SpatialPylonBakedModel( Map<SpatialPylonTextureType, TextureAtlasSprite> textures )
|
||||
{
|
||||
this.textures = ImmutableMap.copyOf( textures );
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
{
|
||||
int flags = this.getFlags( state );
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
int flags = this.getFlags( extraData );
|
||||
|
||||
CubeBuilder builder = new CubeBuilder( this.format );
|
||||
CubeBuilder builder = new CubeBuilder();
|
||||
|
||||
if( flags != 0 )
|
||||
{
|
||||
@@ -162,16 +155,10 @@ class SpatialPylonBakedModel implements IBakedModel
|
||||
return builder.getOutput();
|
||||
}
|
||||
|
||||
private int getFlags( BlockState state )
|
||||
private int getFlags( IModelData modelData )
|
||||
{
|
||||
if( !( state instanceof IExtendedBlockState ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
|
||||
return extState.getValue( BlockSpatialPylon.STATE );
|
||||
Integer flags = modelData.getData(TileSpatialPylon.STATE);
|
||||
return flags != null ? flags : 0;
|
||||
}
|
||||
|
||||
private static SpatialPylonTextureType getTextureTypeFromSideOutside( int flags, Direction ori, Direction dir )
|
||||
@@ -222,6 +209,11 @@ class SpatialPylonBakedModel implements IBakedModel
|
||||
return SpatialPylonTextureType.BASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
@@ -246,12 +238,6 @@ class SpatialPylonBakedModel implements IBakedModel
|
||||
return this.textures.get( SpatialPylonTextureType.DIM );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
|
||||
@@ -19,62 +19,45 @@
|
||||
package appeng.client.render.spatial;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
class SpatialPylonModel implements IModel
|
||||
public class SpatialPylonModel implements IModelGeometry<SpatialPylonModel>
|
||||
{
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Arrays.stream( SpatialPylonTextureType.values() ).map( SpatialPylonModel::getTexturePath ).collect( Collectors.toList() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
Map<SpatialPylonTextureType, TextureAtlasSprite> textures = new EnumMap<>( SpatialPylonTextureType.class );
|
||||
|
||||
for( SpatialPylonTextureType type : SpatialPylonTextureType.values() )
|
||||
{
|
||||
ResourceLocation loc = getTexturePath( type );
|
||||
textures.put( type, bakedTextureGetter.apply( loc ) );
|
||||
textures.put( type, spriteGetter.apply(getTexturePath( type )) );
|
||||
}
|
||||
|
||||
return new SpatialPylonBakedModel( format, textures );
|
||||
return new SpatialPylonBakedModel( textures );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Arrays.stream( SpatialPylonTextureType.values() )
|
||||
.map( SpatialPylonModel::getTexturePath )
|
||||
.collect( Collectors.toList() );
|
||||
}
|
||||
|
||||
private static ResourceLocation getTexturePath( SpatialPylonTextureType type )
|
||||
private static Material getTexturePath( SpatialPylonTextureType type )
|
||||
{
|
||||
return new ResourceLocation( AppEng.MOD_ID, "blocks/spatial_pylon/" + type.name().toLowerCase() );
|
||||
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "blocks/spatial_pylon/" + type.name().toLowerCase() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.textures;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
|
||||
|
||||
public class ParticleTextures
|
||||
{
|
||||
public static TextureAtlasSprite BlockEnergyParticle;
|
||||
public static TextureAtlasSprite BlockMatterCannonParticle;
|
||||
|
||||
public static void registerSprite( TextureStitchEvent.Pre event )
|
||||
{
|
||||
BlockEnergyParticle = event.getMap().registerSprite( new ResourceLocation( "appliedenergistics2:particles/energy" ) );
|
||||
BlockMatterCannonParticle = event.getMap().registerSprite( new ResourceLocation( "appliedenergistics2:particles/matter_cannon" ) );
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.inventory.container.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -89,7 +86,7 @@ public abstract class AEBaseContainer extends Container
|
||||
private final HashMap<Integer, SyncData> syncData = new HashMap<>();
|
||||
private boolean isContainerValid = true;
|
||||
private String customName;
|
||||
private ContainerOpenContext openContext;
|
||||
private ContainerLocator locator;
|
||||
private IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
private IEnergySource powerSrc;
|
||||
private boolean sentCustomName;
|
||||
@@ -1060,6 +1057,7 @@ public abstract class AEBaseContainer extends Container
|
||||
|
||||
private void sendCustomName()
|
||||
{
|
||||
// FIXME: Trash this, this is handled by NamedContainerProvider now
|
||||
if( !this.sentCustomName )
|
||||
{
|
||||
this.sentCustomName = true;
|
||||
@@ -1096,16 +1094,9 @@ public abstract class AEBaseContainer extends Container
|
||||
|
||||
if( this.getCustomName() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance()
|
||||
.sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ),
|
||||
(ServerPlayerEntity) this.getPlayerInventory().player );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
NetworkHandler.instance()
|
||||
.sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ),
|
||||
(ServerPlayerEntity) this.getPlayerInventory().player );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1242,14 +1233,14 @@ public abstract class AEBaseContainer extends Container
|
||||
this.isContainerValid = isContainerValid;
|
||||
}
|
||||
|
||||
public ContainerOpenContext getOpenContext()
|
||||
public ContainerLocator getLocator()
|
||||
{
|
||||
return this.openContext;
|
||||
return this.locator;
|
||||
}
|
||||
|
||||
public void setOpenContext( final ContainerOpenContext openContext )
|
||||
public void setLocator(final ContainerLocator locator)
|
||||
{
|
||||
this.openContext = openContext;
|
||||
this.locator = locator;
|
||||
}
|
||||
|
||||
public IEnergySource getPowerSource()
|
||||
@@ -1261,4 +1252,5 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
this.powerSrc = powerSrc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container;
|
||||
|
||||
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
/**
|
||||
* Describes how a container the player has opened was originally
|
||||
* located. This can be one of three ways:
|
||||
*
|
||||
* <ul>
|
||||
* <li>A tile entity at a given block position.</li>
|
||||
* <li>A part (i.e. cable bus part) at the side of a given block position.</li>
|
||||
* <li>An item held by the player.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public final class ContainerLocator {
|
||||
|
||||
private enum Type {
|
||||
ITEM,
|
||||
BLOCK,
|
||||
PART
|
||||
}
|
||||
|
||||
private final Type type;
|
||||
private final int itemIndex;
|
||||
private final int dimensionId;
|
||||
private final BlockPos blockPos;
|
||||
private final AEPartLocation side;
|
||||
|
||||
private ContainerLocator(Type type, int itemIndex, int dimensionId, BlockPos blockPos, AEPartLocation side) {
|
||||
this.type = type;
|
||||
this.itemIndex = itemIndex;
|
||||
this.dimensionId = dimensionId;
|
||||
this.blockPos = blockPos;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public static ContainerLocator forTileEntity(TileEntity te) {
|
||||
if (te.getWorld() == null) {
|
||||
throw new IllegalArgumentException("Cannot open a tile entity that is not in a world");
|
||||
}
|
||||
int dimensionId = te.getWorld().getDimension().getType().getId();
|
||||
return new ContainerLocator(Type.BLOCK, -1, dimensionId, te.getPos(), null);
|
||||
}
|
||||
|
||||
public static ContainerLocator forTileEntitySide(TileEntity te, Direction side) {
|
||||
if (te.getWorld() == null) {
|
||||
throw new IllegalArgumentException("Cannot open a tile entity that is not in a world");
|
||||
}
|
||||
int dimensionId = te.getWorld().getDimension().getType().getId();
|
||||
return new ContainerLocator(Type.PART, -1, dimensionId, te.getPos(), AEPartLocation.fromFacing(side));
|
||||
}
|
||||
|
||||
public static ContainerLocator forHand(Hand hand) {
|
||||
// FIXME can we get an inventory location for the hand?
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public static ContainerLocator forPart(AEBasePart part) {
|
||||
IPartHost host = part.getHost();
|
||||
DimensionalCoord pos = host.getLocation();
|
||||
return new ContainerLocator(
|
||||
Type.PART,
|
||||
-1,
|
||||
pos.getWorld().getDimension().getType().getId(),
|
||||
pos.getBlockPos(),
|
||||
part.getSide()
|
||||
);
|
||||
}
|
||||
|
||||
public boolean hasItemIndex() {
|
||||
return type == Type.ITEM;
|
||||
}
|
||||
|
||||
public int getItemIndex() {
|
||||
Preconditions.checkState(type == Type.ITEM);
|
||||
return itemIndex;
|
||||
}
|
||||
|
||||
public int getDimensionId() {
|
||||
return dimensionId;
|
||||
}
|
||||
|
||||
public boolean hasBlockPos() {
|
||||
return type == Type.BLOCK || type == Type.PART;
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos() {
|
||||
Preconditions.checkState(type == Type.BLOCK || type == Type.PART);
|
||||
return blockPos;
|
||||
}
|
||||
|
||||
public boolean hasSide() {
|
||||
return type == Type.PART;
|
||||
}
|
||||
|
||||
public AEPartLocation getSide() {
|
||||
Preconditions.checkState(type == Type.PART);
|
||||
return side;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
switch (type) {
|
||||
case ITEM:
|
||||
buf.writeByte(0);
|
||||
buf.writeInt(itemIndex);
|
||||
break;
|
||||
case BLOCK:
|
||||
buf.writeByte(1);
|
||||
buf.writeInt(dimensionId);
|
||||
buf.writeBlockPos(blockPos);
|
||||
break;
|
||||
case PART:
|
||||
buf.writeByte(2);
|
||||
buf.writeInt(dimensionId);
|
||||
buf.writeBlockPos(blockPos);
|
||||
buf.writeByte(side.ordinal());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported ContainerLocator type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
public static ContainerLocator read(PacketBuffer buf) {
|
||||
byte type = buf.readByte();
|
||||
switch (type) {
|
||||
case 0:
|
||||
return new ContainerLocator(
|
||||
Type.ITEM,
|
||||
buf.readInt(),
|
||||
-1,
|
||||
null,
|
||||
null
|
||||
);
|
||||
case 1:
|
||||
return new ContainerLocator(
|
||||
Type.BLOCK,
|
||||
-1,
|
||||
buf.readInt(),
|
||||
buf.readBlockPos(),
|
||||
null
|
||||
);
|
||||
case 2:
|
||||
return new ContainerLocator(
|
||||
Type.PART,
|
||||
-1,
|
||||
buf.readInt(),
|
||||
buf.readBlockPos(),
|
||||
AEPartLocation.values()[buf.readByte()]
|
||||
);
|
||||
default:
|
||||
throw new DecoderException("ContainerLocator type out of range: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
|
||||
public class ContainerOpenContext
|
||||
{
|
||||
|
||||
private final boolean isItem;
|
||||
private World w;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private AEPartLocation side;
|
||||
|
||||
public ContainerOpenContext( final Object myItem )
|
||||
{
|
||||
final boolean isWorld = myItem instanceof IPart || myItem instanceof TileEntity;
|
||||
this.isItem = !isWorld;
|
||||
}
|
||||
|
||||
public TileEntity getTile()
|
||||
{
|
||||
if( this.isItem )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.w.getTileEntity( new BlockPos( this.x, this.y, this.z ) );
|
||||
}
|
||||
|
||||
public AEPartLocation getSide()
|
||||
{
|
||||
return this.side;
|
||||
}
|
||||
|
||||
public void setSide( final AEPartLocation side )
|
||||
{
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
private int getZ()
|
||||
{
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public void setZ( final int z )
|
||||
{
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
private int getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY( final int y )
|
||||
{
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
private int getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX( final int x )
|
||||
{
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
private World getWorld()
|
||||
{
|
||||
return this.w;
|
||||
}
|
||||
|
||||
public void setWorld( final World w )
|
||||
{
|
||||
this.w = w;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package appeng.container;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows opening containers generically.
|
||||
*/
|
||||
public final class ContainerOpener {
|
||||
|
||||
private ContainerOpener() {
|
||||
}
|
||||
|
||||
private static final Map<ContainerType<? extends AEBaseContainer>, Opener<?>> registry = new HashMap<>();
|
||||
|
||||
public static <T extends AEBaseContainer> void addOpener(ContainerType<T> type, Opener<T> opener) {
|
||||
registry.put(type, opener);
|
||||
}
|
||||
|
||||
public static boolean openContainer(ContainerType<?> type, PlayerEntity player, ContainerLocator locator) {
|
||||
Opener<?> opener = registry.get(type);
|
||||
if (opener == null) {
|
||||
AELog.warn("Trying to open container for unknown container type {}", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
return opener.open(player, locator);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Opener<T extends AEBaseContainer> {
|
||||
|
||||
boolean open(PlayerEntity player, ContainerLocator locator);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user