More compile things

This commit is contained in:
covers1624
2020-06-02 15:12:30 +09:30
parent 404ef5624b
commit 3f5c299d09
111 changed files with 838 additions and 873 deletions
+17 -2
View File
@@ -24,15 +24,30 @@
package appeng.api.config; package appeng.api.config;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
public enum Actionable public enum Actionable
{ {
/** /**
* Perform the intended action. * Perform the intended action.
*/ */
MODULATE, MODULATE( FluidAction.EXECUTE ),
/** /**
* Pretend to perform the action. * Pretend to perform the action.
*/ */
SIMULATE SIMULATE( FluidAction.SIMULATE );
private final FluidAction fluidAction;
Actionable( FluidAction fluidAction )
{
this.fluidAction = fluidAction;
}
public FluidAction getFluidAction()
{
return fluidAction;
}
} }
@@ -29,6 +29,7 @@ import java.util.EnumSet;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.IAppEngApi; import appeng.api.IAppEngApi;
@@ -91,7 +92,7 @@ public interface IGridNode
* @return the world the node is located in * @return the world the node is located in
*/ */
@Nonnull @Nonnull
World getWorld(); IWorld getWorld();
/** /**
* @return a set of the connected sides, INTERNAL represents an invisible connection * @return a set of the connected sides, INTERNAL represents an invisible connection
@@ -169,4 +170,4 @@ public interface IGridNode
* @param playerID new player id * @param playerID new player id
*/ */
void setPlayerID( int playerID ); void setPlayerID( int playerID );
} }
@@ -3,6 +3,7 @@ package appeng.api.parts;
import java.util.List; import java.util.List;
import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -11,5 +12,5 @@ import net.minecraft.client.renderer.model.BakedQuad;
public interface IPartBakedModel public interface IPartBakedModel
{ {
List<BakedQuad> getPartQuads( @Nullable Long partFlags, long rand ); List<BakedQuad> getPartQuads( @Nullable Long partFlags, Random rand );
} }
@@ -26,7 +26,7 @@ package appeng.api.parts;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -46,7 +46,8 @@ public interface IPartHelper
* *
* @return true if placing was successful * @return true if placing was successful
*/ */
ActionResult<?> placeBus( ItemStack is, BlockPos pos, Direction side, PlayerEntity player, Hand hand, World world ); //TODO, this should probably take ItemStack + ItemUseContext
ActionResultType placeBus( ItemStack is, BlockPos pos, Direction side, PlayerEntity player, Hand hand, World world );
/** /**
* @return the render mode * @return the render mode
@@ -75,6 +75,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
//TODO, pass generic up here for Container
public abstract class AEBaseGui extends ContainerScreen<AEBaseContainer> public abstract class AEBaseGui extends ContainerScreen<AEBaseContainer>
{ {
private final List<InternalSlotME> meSlots = new ArrayList<>(); private final List<InternalSlotME> meSlots = new ArrayList<>();
@@ -71,7 +71,7 @@ public class GuiUpgradeable extends AEBaseGui
protected boolean hasToolbox() protected boolean hasToolbox()
{ {
return ( (ContainerUpgradeable) this.inventorySlots ).hasToolbox(); return ( (ContainerUpgradeable) this.container ).hasToolbox();
} }
@Override @Override
@@ -22,6 +22,7 @@ package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.RenderItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -30,13 +31,13 @@ import net.minecraft.util.ResourceLocation;
public class GuiTabButton extends Button implements ITooltip public class GuiTabButton extends Button implements ITooltip
{ {
private final RenderItem itemRenderer; private final ItemRenderer itemRenderer;
private final String message; private final String message;
private int hideEdge = 0; private int hideEdge = 0;
private int myIcon = -1; private int myIcon = -1;
private ItemStack myItem; private ItemStack myItem;
public GuiTabButton( final int x, final int y, final int ico, final String message, final RenderItem ir ) public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir )
{ {
super( 0, 0, 16, "" ); super( 0, 0, 16, "" );
@@ -58,7 +59,7 @@ public class GuiTabButton extends Button implements ITooltip
* @param message mouse over message * @param message mouse over message
* @param ir renderer * @param ir renderer
*/ */
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final RenderItem ir ) public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir )
{ {
super( 0, 0, 16, "" ); super( 0, 0, 16, "" );
this.x = x; this.x = x;
@@ -21,15 +21,18 @@ package appeng.client.render;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import net.minecraft.client.renderer.block.model.IBakedModel; 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.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation; 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.client.render.cablebus.FacadeBuilder; import appeng.client.render.cablebus.FacadeBuilder;
import appeng.core.AppEng; import appeng.core.AppEng;
@@ -39,47 +42,29 @@ import appeng.core.AppEng;
* The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other * The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other
* than the cable anchor. * than the cable anchor.
*/ */
public class FacadeItemModel implements IModel public class FacadeItemModel implements IUnbakedModel
{ {
// We use this to get the default item transforms and make our lives easier // 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/facade_base" ); private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/facade_base" );
private IModel getBaseModel()
{
try
{
return ModelLoaderRegistry.getModel( MODEL_BASE );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
@Override @Override
public Collection<ResourceLocation> getDependencies() public Collection<ResourceLocation> getDependencies()
{ {
return Collections.emptyList(); return Collections.singleton( MODEL_BASE );
} }
@Override @Override
public Collection<ResourceLocation> getTextures() public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
{ {
IBakedModel bakedBaseModel = this.getBaseModel().bake( state, format, bakedTextureGetter ); IBakedModel bakedBaseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
FacadeBuilder facadeBuilder = new FacadeBuilder(); FacadeBuilder facadeBuilder = new FacadeBuilder();
return new FacadeDispatcherBakedModel( bakedBaseModel, facadeBuilder ); return new FacadeDispatcherBakedModel( bakedBaseModel, facadeBuilder );
} }
@Override
public IModelState getDefaultState()
{
return this.getBaseModel().getDefaultState();
}
} }
@@ -29,13 +29,10 @@ import com.google.common.base.Preconditions;
import net.minecraft.client.renderer.Vector4f; import net.minecraft.client.renderer.Vector4f;
import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
import appeng.client.render.VertexFormats;
/** /**
@@ -44,8 +41,6 @@ import appeng.client.render.VertexFormats;
public class CubeBuilder public class CubeBuilder
{ {
private VertexFormat format;
private final List<BakedQuad> output; private final List<BakedQuad> output;
private final EnumMap<Direction, TextureAtlasSprite> textures = new EnumMap<>( Direction.class ); private final EnumMap<Direction, TextureAtlasSprite> textures = new EnumMap<>( Direction.class );
@@ -62,15 +57,14 @@ public class CubeBuilder
private boolean renderFullBright; private boolean renderFullBright;
public CubeBuilder( VertexFormat format, List<BakedQuad> output ) public CubeBuilder( List<BakedQuad> output )
{ {
this.output = output; this.output = output;
this.format = format;
} }
public CubeBuilder( VertexFormat format ) public CubeBuilder()
{ {
this( format, new ArrayList<>( 6 ) ); this( new ArrayList<>( 6 ) );
} }
public void addCube( float x1, float y1, float z1, float x2, float y2, float z2 ) public void addCube( float x1, float y1, float z1, float x2, float y2, float z2 )
@@ -82,49 +76,15 @@ public class CubeBuilder
y2 /= 16.0f; y2 /= 16.0f;
z2 /= 16.0f; z2 /= 16.0f;
// If brightness is forced to specific values, extend the vertex format to contain the multi-texturing lightmap
// offset
VertexFormat savedFormat = null;
if( this.renderFullBright )
{
savedFormat = this.format;
this.format = VertexFormats.getFormatWithLightMap( this.format );
}
for( Direction face : this.drawFaces ) for( Direction face : this.drawFaces )
{ {
this.putFace( face, x1, y1, z1, x2, y2, z2 ); this.putFace( face, x1, y1, z1, x2, y2, z2 );
} }
// Restore old format
if( savedFormat != null )
{
this.format = savedFormat;
}
} }
public void addQuad( Direction face, float x1, float y1, float z1, float x2, float y2, float z2 ) public void addQuad( Direction face, float x1, float y1, float z1, float x2, float y2, float z2 )
{ {
// If brightness is forced to specific values, extend the vertex format to contain the multi-texturing lightmap
// offset
VertexFormat savedFormat = null;
if( this.renderFullBright )
{
savedFormat = this.format;
this.format = new VertexFormat( savedFormat );
if( !this.format.getElements().contains( DefaultVertexFormats.TEX_2S ) )
{
this.format.addElement( DefaultVertexFormats.TEX_2S );
}
}
this.putFace( face, x1, y1, z1, x2, y2, z2 ); this.putFace( face, x1, y1, z1, x2, y2, z2 );
// Restore old format
if( savedFormat != null )
{
this.format = savedFormat;
}
} }
private static final class UvVector private static final class UvVector
@@ -140,8 +100,7 @@ public class CubeBuilder
TextureAtlasSprite texture = this.textures.get( face ); TextureAtlasSprite texture = this.textures.get( face );
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( this.format ); BakedQuadBuilder builder = new BakedQuadBuilder( texture );
builder.setTexture( texture );
builder.setQuadOrientation( face ); builder.setQuadOrientation( face );
builder.setQuadTint( -1 ); builder.setQuadTint( -1 );
builder.setApplyDiffuseLighting( true ); builder.setApplyDiffuseLighting( true );
@@ -152,10 +111,10 @@ public class CubeBuilder
Vector4f customUv = this.customUv.get( face ); Vector4f customUv = this.customUv.get( face );
if( customUv != null ) if( customUv != null )
{ {
uv.u1 = texture.getInterpolatedU( customUv.x ); uv.u1 = texture.getInterpolatedU( customUv.getX() );
uv.v1 = texture.getInterpolatedV( customUv.y ); uv.v1 = texture.getInterpolatedV( customUv.getY() );
uv.u2 = texture.getInterpolatedU( customUv.z ); uv.u2 = texture.getInterpolatedU( customUv.getZ() );
uv.v2 = texture.getInterpolatedV( customUv.w ); uv.v2 = texture.getInterpolatedV( customUv.getW() );
} }
else if( this.useStandardUV ) else if( this.useStandardUV )
{ {
@@ -303,7 +262,7 @@ public class CubeBuilder
} }
// uv.u1, uv.v1 // uv.u1, uv.v1
private void putVertexTL( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv ) private void putVertexTL( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
{ {
float u, v; float u, v;
@@ -332,7 +291,7 @@ public class CubeBuilder
} }
// uv.u2, uv.v1 // uv.u2, uv.v1
private void putVertexTR( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv ) private void putVertexTR( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
{ {
float u, v; float u, v;
@@ -360,7 +319,7 @@ public class CubeBuilder
} }
// uv.u2, uv.v2 // uv.u2, uv.v2
private void putVertexBR( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv ) private void putVertexBR( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
{ {
float u; float u;
@@ -391,7 +350,7 @@ public class CubeBuilder
} }
// uv.u1, uv.v2 // uv.u1, uv.v2
private void putVertexBL( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv ) private void putVertexBL( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
{ {
float u; float u;
@@ -421,13 +380,14 @@ public class CubeBuilder
this.putVertex( builder, face, x, y, z, u, v ); this.putVertex( builder, face, x, y, z, u, v );
} }
private void putVertex( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, float u, float v ) private void putVertex( BakedQuadBuilder builder, Direction face, float x, float y, float z, float u, float v )
{ {
VertexFormat format = builder.getVertexFormat(); VertexFormat format = builder.getVertexFormat();
for( int i = 0; i < format.getElementCount(); i++ ) List<VertexFormatElement> elements = format.getElements();
for( int i = 0; i < elements.size(); i++ )
{ {
VertexFormatElement e = format.getElement( i ); VertexFormatElement e = elements.get( i );
switch( e.getUsage() ) switch( e.getUsage() )
{ {
case POSITION: case POSITION:
@@ -449,7 +409,7 @@ public class CubeBuilder
{ {
builder.put( i, u, v ); builder.put( i, u, v );
} }
else else if( e.getIndex() == 2 && renderFullBright )
{ {
// Force Brightness to 15, this is for full bright mode // Force Brightness to 15, this is for full bright mode
// this vertex element will only be present in that case // this vertex element will only be present in that case
@@ -4,6 +4,7 @@ package appeng.client.render.cablebus;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
@@ -11,10 +12,9 @@ import com.google.common.cache.CacheBuilder;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
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.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import appeng.api.parts.IPartBakedModel; import appeng.api.parts.IPartBakedModel;
@@ -24,7 +24,6 @@ import appeng.util.Platform;
public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedModel public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedModel
{ {
private final VertexFormat format;
private final TextureAtlasSprite texture; private final TextureAtlasSprite texture;
private final static Cache<Long, List<BakedQuad>> modelCache = CacheBuilder.newBuilder().maximumSize( 100 ).build(); private final static Cache<Long, List<BakedQuad>> modelCache = CacheBuilder.newBuilder().maximumSize( 100 ).build();
@@ -36,14 +35,13 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
{ 10, 4, 2 } { 10, 4, 2 }
}; };
public P2PTunnelFrequencyBakedModel( final VertexFormat format, final TextureAtlasSprite texture ) public P2PTunnelFrequencyBakedModel( final TextureAtlasSprite texture )
{ {
this.format = format;
this.texture = texture; this.texture = texture;
} }
@Override @Override
public List<BakedQuad> getPartQuads( Long partFlags, long rand ) public List<BakedQuad> getPartQuads( Long partFlags, Random rand )
{ {
try try
{ {
@@ -66,7 +64,7 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
} }
@Override @Override
public List<BakedQuad> getQuads( BlockState state, Direction side, long rand ) public List<BakedQuad> getQuads( BlockState state, Direction side, Random rand )
{ {
if( side != null ) if( side != null )
{ {
@@ -78,7 +76,7 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
private List<BakedQuad> getQuadsForFrequency( final short frequency, final boolean active ) private List<BakedQuad> getQuadsForFrequency( final short frequency, final boolean active )
{ {
final AEColor[] colors = Platform.p2p().toColors( frequency ); final AEColor[] colors = Platform.p2p().toColors( frequency );
final CubeBuilder cb = new CubeBuilder( this.format ); final CubeBuilder cb = new CubeBuilder();
cb.setTexture( this.texture ); cb.setTexture( this.texture );
cb.useStandardUV(); cb.useStandardUV();
@@ -122,6 +120,12 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
return false; return false;
} }
@Override
public boolean func_230044_c_()
{
return false;//TODO
}
@Override @Override
public boolean isBuiltInRenderer() public boolean isBuiltInRenderer()
{ {
@@ -1,43 +1,54 @@
package appeng.client.render.cablebus; package appeng.client.render.cablebus;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.block.model.IBakedModel; 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.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.common.model.IModelState;
import appeng.core.AppEng; import appeng.core.AppEng;
public class P2PTunnelFrequencyModel implements IModel public class P2PTunnelFrequencyModel implements IUnbakedModel
{ {
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" ); private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" ) );
@Override @Override
public Collection<ResourceLocation> getTextures() public Collection<ResourceLocation> getDependencies()
{ {
return Collections.singletonList( TEXTURE ); return Collections.emptyList();
} }
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public Collection<Material> getTextures( 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 )
{ {
try try
{ {
final TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE ); final TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
return new P2PTunnelFrequencyBakedModel( format, texture ); return new P2PTunnelFrequencyBakedModel( texture );
} }
catch( Exception e ) catch( Exception e )
{ {
throw new RuntimeException( e ); throw new RuntimeException( e );
} }
} }
} }
@@ -1,34 +1,29 @@
package appeng.client.render.model; package appeng.client.render.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.blaze3d.matrix.MatrixStack;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.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.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.client.model.data.EmptyModelData;
import appeng.api.implementations.items.IBiometricCard; import appeng.api.implementations.items.IBiometricCard;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
@@ -39,8 +34,6 @@ import appeng.core.AELog;
class BiometricCardBakedModel implements IBakedModel class BiometricCardBakedModel implements IBakedModel
{ {
private final VertexFormat format;
private final IBakedModel baseModel; private final IBakedModel baseModel;
private final TextureAtlasSprite texture; private final TextureAtlasSprite texture;
@@ -51,14 +44,13 @@ class BiometricCardBakedModel implements IBakedModel
private final ImmutableList<BakedQuad> generalQuads; private final ImmutableList<BakedQuad> generalQuads;
BiometricCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture ) BiometricCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture )
{ {
this( format, baseModel, texture, 0, createCache() ); this( baseModel, texture, 0, createCache() );
} }
private BiometricCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture, int hash, Cache<Integer, BiometricCardBakedModel> modelCache ) private BiometricCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture, int hash, Cache<Integer, BiometricCardBakedModel> modelCache )
{ {
this.format = format;
this.baseModel = baseModel; this.baseModel = baseModel;
this.texture = texture; this.texture = texture;
this.hash = hash; this.hash = hash;
@@ -68,16 +60,14 @@ class BiometricCardBakedModel implements IBakedModel
private static Cache<Integer, BiometricCardBakedModel> createCache() private static Cache<Integer, BiometricCardBakedModel> createCache()
{ {
return CacheBuilder.newBuilder() return CacheBuilder.newBuilder().maximumSize( 100 ).build();
.maximumSize( 100 )
.build();
} }
@Override @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 )
{ {
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand ); List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand, EmptyModelData.INSTANCE );
if( side != null ) if( side != null )
{ {
@@ -92,7 +82,7 @@ class BiometricCardBakedModel implements IBakedModel
private List<BakedQuad> buildGeneralQuads() private List<BakedQuad> buildGeneralQuads()
{ {
CubeBuilder builder = new CubeBuilder( this.format ); CubeBuilder builder = new CubeBuilder();
builder.setTexture( this.texture ); builder.setTexture( this.texture );
@@ -125,8 +115,7 @@ class BiometricCardBakedModel implements IBakedModel
else else
{ {
final float scale = 0.3f / 255.0f; final float scale = 0.3f / 255.0f;
builder.setColorRGB( ( ( col.blackVariant >> 16 ) & 0xff ) * scale, ( ( col.blackVariant >> 8 ) & 0xff ) * scale, builder.setColorRGB( ( ( col.blackVariant >> 16 ) & 0xff ) * scale, ( ( col.blackVariant >> 8 ) & 0xff ) * scale, ( col.blackVariant & 0xff ) * scale );
( col.blackVariant & 0xff ) * scale );
} }
builder.addCube( 4 + x, 6 + y, 7.5f, 4 + x + 1, 6 + y + 1, 8.5f ); builder.addCube( 4 + x, 6 + y, 7.5f, 4 + x + 1, 6 + y + 1, 8.5f );
@@ -147,6 +136,12 @@ class BiometricCardBakedModel implements IBakedModel
return this.baseModel.isGui3d(); return this.baseModel.isGui3d();
} }
@Override
public boolean func_230044_c_()
{
return false;//TODO
}
@Override @Override
public boolean isBuiltInRenderer() public boolean isBuiltInRenderer()
{ {
@@ -168,10 +163,10 @@ class BiometricCardBakedModel implements IBakedModel
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {
return new ItemOverrideList( Collections.emptyList() ) return new ItemOverrideList()
{ {
@Override @Override
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity ) public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
{ {
String username = ""; String username = "";
if( stack.getItem() instanceof IBiometricCard ) if( stack.getItem() instanceof IBiometricCard )
@@ -199,8 +194,7 @@ class BiometricCardBakedModel implements IBakedModel
try try
{ {
return BiometricCardBakedModel.this.modelCache.get( hash, return BiometricCardBakedModel.this.modelCache.get( hash, () -> new BiometricCardBakedModel( BiometricCardBakedModel.this.baseModel, BiometricCardBakedModel.this.texture, hash, BiometricCardBakedModel.this.modelCache ) );
() -> new BiometricCardBakedModel( BiometricCardBakedModel.this.format, BiometricCardBakedModel.this.baseModel, BiometricCardBakedModel.this.texture, hash, BiometricCardBakedModel.this.modelCache ) );
} }
catch( ExecutionException e ) catch( ExecutionException e )
{ {
@@ -212,15 +206,15 @@ class BiometricCardBakedModel implements IBakedModel
} }
@Override @Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type ) public boolean doesHandlePerspectives()
{ {
// Delegate to the base model if possible return true;
if( this.baseModel instanceof IBakedModel ) }
{
IBakedModel pam = this.baseModel; @Override
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type ); public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
return Pair.of( this, pair.getValue() ); {
} baseModel.handlePerspective( cameraTransformType, mat );
return Pair.of( this, TRSRTransformation.identity().getMatrix() ); return this;
} }
} }
@@ -1,19 +1,22 @@
package appeng.client.render.model; package appeng.client.render.model;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.block.model.IBakedModel; 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.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation; 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; import appeng.core.AppEng;
@@ -22,11 +25,11 @@ import appeng.core.AppEng;
* Model wrapper for the biometric card item model, which combines a base card layer with a "visual hash" of the player * Model wrapper for the biometric card item model, which combines a base card layer with a "visual hash" of the player
* name * name
*/ */
public class BiometricCardModel implements IModel public class BiometricCardModel implements IUnbakedModel
{ {
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/biometric_card" ); private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/biometric_card" );
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "items/biometric_card_hash" ); private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/biometric_card_hash" ) );
@Override @Override
public Collection<ResourceLocation> getDependencies() public Collection<ResourceLocation> getDependencies()
@@ -35,37 +38,19 @@ public class BiometricCardModel implements IModel
} }
@Override @Override
public Collection<ResourceLocation> getTextures() public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
{ {
return Collections.singletonList( TEXTURE ); return Collections.singleton( TEXTURE );
} }
@Nullable
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
{ {
TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE ); TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter ); IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
return new BiometricCardBakedModel( format, baseModel, texture ); return new BiometricCardBakedModel( baseModel, texture );
}
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
// Load the base model
try
{
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity();
} }
} }
@@ -1,27 +1,24 @@
package appeng.client.render.model; package appeng.client.render.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.matrix.MatrixStack;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.IModelTransform;
import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraftforge.client.model.PerspectiveMapWrapper; import net.minecraftforge.client.model.PerspectiveMapWrapper;
import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.client.model.data.EmptyModelData;
class ColorApplicatorBakedModel implements IBakedModel class ColorApplicatorBakedModel implements IBakedModel
@@ -29,16 +26,16 @@ class ColorApplicatorBakedModel implements IBakedModel
private final IBakedModel baseModel; private final IBakedModel baseModel;
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms; private final IModelTransform transforms;
private final EnumMap<Direction, List<BakedQuad>> quadsBySide; private final EnumMap<Direction, List<BakedQuad>> quadsBySide;
private final List<BakedQuad> generalQuads; private final List<BakedQuad> generalQuads;
ColorApplicatorBakedModel( IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright ) ColorApplicatorBakedModel( IBakedModel baseModel, IModelTransform transforms, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright )
{ {
this.baseModel = baseModel; this.baseModel = baseModel;
this.transforms = map; this.transforms = transforms;
// Put the tint indices in... Since this is an item model, we are ignoring rand // Put the tint indices in... Since this is an item model, we are ignoring rand
this.generalQuads = this.fixQuadTint( null, texDark, texMedium, texBright ); this.generalQuads = this.fixQuadTint( null, texDark, texMedium, texBright );
@@ -51,21 +48,21 @@ class ColorApplicatorBakedModel implements IBakedModel
private List<BakedQuad> fixQuadTint( Direction facing, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright ) private List<BakedQuad> fixQuadTint( Direction facing, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright )
{ {
List<BakedQuad> quads = this.baseModel.getQuads( null, facing, 0 ); List<BakedQuad> quads = this.baseModel.getQuads( null, facing, new Random( 0 ), EmptyModelData.INSTANCE );
List<BakedQuad> result = new ArrayList<>( quads.size() ); List<BakedQuad> result = new ArrayList<>( quads.size() );
for( BakedQuad quad : quads ) for( BakedQuad quad : quads )
{ {
int tint; int tint;
if( quad.getSprite() == texDark ) if( quad.func_187508_a() == texDark )
{ {
tint = 1; tint = 1;
} }
else if( quad.getSprite() == texMedium ) else if( quad.func_187508_a() == texMedium )
{ {
tint = 2; tint = 2;
} }
else if( quad.getSprite() == texBright ) else if( quad.func_187508_a() == texBright )
{ {
tint = 3; tint = 3;
} }
@@ -75,8 +72,7 @@ class ColorApplicatorBakedModel implements IBakedModel
continue; continue;
} }
BakedQuad newQuad = new BakedQuad( quad.getVertexData(), tint, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad BakedQuad newQuad = new BakedQuad( quad.getVertexData(), tint, quad.getFace(), quad.func_187508_a(), quad.shouldApplyDiffuseLighting() );
.getFormat() );
result.add( newQuad ); result.add( newQuad );
} }
@@ -84,7 +80,7 @@ class ColorApplicatorBakedModel implements IBakedModel
} }
@Override @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 )
{ {
if( side == null ) if( side == null )
{ {
@@ -105,6 +101,12 @@ class ColorApplicatorBakedModel implements IBakedModel
return this.baseModel.isGui3d(); return this.baseModel.isGui3d();
} }
@Override
public boolean func_230044_c_()
{
return false;//TODO
}
@Override @Override
public boolean isBuiltInRenderer() public boolean isBuiltInRenderer()
{ {
@@ -130,8 +132,8 @@ class ColorApplicatorBakedModel implements IBakedModel
} }
@Override @Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type ) public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
{ {
return PerspectiveMapWrapper.handlePerspective( this, this.transforms, type ); return PerspectiveMapWrapper.handlePerspective( this, transforms, cameraTransformType, mat );
} }
} }
@@ -1,24 +1,24 @@
package appeng.client.render.model; package appeng.client.render.model;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList; import com.mojang.datafixers.util.Pair;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; 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.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry; 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; import appeng.core.AppEng;
@@ -27,14 +27,14 @@ import appeng.core.AppEng;
* A color applicator uses the base model, and extends it with additional layers that are colored according to the * A color applicator uses the base model, and extends it with additional layers that are colored according to the
* selected color of the applicator. * selected color of the applicator.
*/ */
public class ColorApplicatorModel implements IModel public class ColorApplicatorModel implements IUnbakedModel
{ {
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_colored" ); private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_colored" );
private static final ResourceLocation TEXTURE_DARK = new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_dark" ); private static final Material TEXTURE_DARK = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_dark" ) );
private static final ResourceLocation TEXTURE_MEDIUM = new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_medium" ); private static final Material TEXTURE_MEDIUM = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_medium" ) );
private static final ResourceLocation TEXTURE_BRIGHT = new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_bright" ); private static final Material TEXTURE_BRIGHT = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_bright" ) );
@Override @Override
public Collection<ResourceLocation> getDependencies() public Collection<ResourceLocation> getDependencies()
@@ -43,44 +43,21 @@ public class ColorApplicatorModel implements IModel
} }
@Override @Override
public Collection<ResourceLocation> getTextures() public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
{ {
return ImmutableList.of( return Arrays.asList( TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK );
TEXTURE_DARK,
TEXTURE_MEDIUM,
TEXTURE_BRIGHT );
} }
@Nullable
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
{ {
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter ); IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
TextureAtlasSprite texDark = bakedTextureGetter.apply( TEXTURE_DARK ); TextureAtlasSprite texDark = spriteGetterIn.apply( TEXTURE_DARK );
TextureAtlasSprite texMedium = bakedTextureGetter.apply( TEXTURE_MEDIUM ); TextureAtlasSprite texMedium = spriteGetterIn.apply( TEXTURE_MEDIUM );
TextureAtlasSprite texBright = bakedTextureGetter.apply( TEXTURE_BRIGHT ); TextureAtlasSprite texBright = spriteGetterIn.apply( TEXTURE_BRIGHT );
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = PerspectiveMapWrapper.getTransforms( state ); return new ColorApplicatorBakedModel( baseModel, transformIn, texDark, texMedium, texBright );
return new ColorApplicatorBakedModel( baseModel, map, texDark, texMedium, texBright );
}
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
// Load the base model
try
{
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity();
} }
} }
@@ -1,4 +1,3 @@
package appeng.client.render.model; package appeng.client.render.model;
@@ -6,29 +5,29 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.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.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.client.model.data.EmptyModelData;
import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.IMemoryCard;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
@@ -43,8 +42,6 @@ class MemoryCardBakedModel implements IBakedModel
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
}; };
private final VertexFormat format;
private final IBakedModel baseModel; private final IBakedModel baseModel;
private final TextureAtlasSprite texture; private final TextureAtlasSprite texture;
@@ -55,14 +52,13 @@ class MemoryCardBakedModel implements IBakedModel
private final ImmutableList<BakedQuad> generalQuads; private final ImmutableList<BakedQuad> generalQuads;
MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture ) MemoryCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture )
{ {
this( format, baseModel, texture, DEFAULT_COLOR_CODE, createCache() ); this( baseModel, texture, DEFAULT_COLOR_CODE, createCache() );
} }
private MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, Cache<CacheKey, MemoryCardBakedModel> modelCache ) private MemoryCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, Cache<CacheKey, MemoryCardBakedModel> modelCache )
{ {
this.format = format;
this.baseModel = baseModel; this.baseModel = baseModel;
this.texture = texture; this.texture = texture;
this.colorCode = hash; this.colorCode = hash;
@@ -72,16 +68,14 @@ class MemoryCardBakedModel implements IBakedModel
private static Cache<CacheKey, MemoryCardBakedModel> createCache() private static Cache<CacheKey, MemoryCardBakedModel> createCache()
{ {
return CacheBuilder.newBuilder() return CacheBuilder.newBuilder().maximumSize( 100 ).build();
.maximumSize( 100 )
.build();
} }
@Override @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 )
{ {
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand ); List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand, EmptyModelData.INSTANCE );
if( side != null ) if( side != null )
{ {
@@ -96,7 +90,7 @@ class MemoryCardBakedModel implements IBakedModel
private List<BakedQuad> buildGeneralQuads() private List<BakedQuad> buildGeneralQuads()
{ {
CubeBuilder builder = new CubeBuilder( this.format ); CubeBuilder builder = new CubeBuilder();
builder.setTexture( this.texture ); builder.setTexture( this.texture );
@@ -126,6 +120,12 @@ class MemoryCardBakedModel implements IBakedModel
return this.baseModel.isGui3d(); return this.baseModel.isGui3d();
} }
@Override
public boolean func_230044_c_()
{
return false;//TODO
}
@Override @Override
public boolean isBuiltInRenderer() public boolean isBuiltInRenderer()
{ {
@@ -147,10 +147,10 @@ class MemoryCardBakedModel implements IBakedModel
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {
return new ItemOverrideList( Collections.emptyList() ) return new ItemOverrideList()
{ {
@Override @Override
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity ) public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
{ {
try try
{ {
@@ -160,7 +160,7 @@ class MemoryCardBakedModel implements IBakedModel
final AEColor[] colors = memoryCard.getColorCode( stack ); final AEColor[] colors = memoryCard.getColorCode( stack );
return MemoryCardBakedModel.this.modelCache.get( new CacheKey( colors ), return MemoryCardBakedModel.this.modelCache.get( new CacheKey( colors ),
() -> new MemoryCardBakedModel( MemoryCardBakedModel.this.format, MemoryCardBakedModel.this.baseModel, MemoryCardBakedModel.this.texture, colors, MemoryCardBakedModel.this.modelCache ) ); () -> new MemoryCardBakedModel( MemoryCardBakedModel.this.baseModel, MemoryCardBakedModel.this.texture, colors, MemoryCardBakedModel.this.modelCache ) );
} }
} }
catch( ExecutionException e ) catch( ExecutionException e )
@@ -171,20 +171,13 @@ class MemoryCardBakedModel implements IBakedModel
return MemoryCardBakedModel.this; return MemoryCardBakedModel.this;
} }
}; };
} }
@Override @Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type ) public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
{ {
// Delegate to the base model if possible baseModel.handlePerspective( cameraTransformType, mat );
if( this.baseModel instanceof IBakedModel ) return this;
{
IBakedModel pam = this.baseModel;
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type );
return Pair.of( this, pair.getValue() );
}
return Pair.of( this, TRSRTransformation.identity().getMatrix() );
} }
private static class CacheKey private static class CacheKey
@@ -223,6 +216,5 @@ class MemoryCardBakedModel implements IBakedModel
CacheKey other = (CacheKey) obj; CacheKey other = (CacheKey) obj;
return Arrays.equals( this.key, other.key ); return Arrays.equals( this.key, other.key );
} }
} }
} }
@@ -1,19 +1,22 @@
package appeng.client.render.model; package appeng.client.render.model;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.block.model.IBakedModel; 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.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation; 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; import appeng.core.AppEng;
@@ -21,11 +24,11 @@ import appeng.core.AppEng;
/** /**
* Model wrapper for the memory card item model, which combines a base card layer with a "visual hash" of the part/tile. * 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 IModel public class MemoryCardModel implements IUnbakedModel
{ {
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card" ); private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card" );
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" ); private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" ) );
@Override @Override
public Collection<ResourceLocation> getDependencies() public Collection<ResourceLocation> getDependencies()
@@ -34,37 +37,19 @@ public class MemoryCardModel implements IModel
} }
@Override @Override
public Collection<ResourceLocation> getTextures() public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
{ {
return Collections.singletonList( TEXTURE ); return Collections.singleton( TEXTURE );
} }
@Nullable
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
{ {
TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE ); TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter ); IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
return new MemoryCardBakedModel( format, baseModel, texture ); return new MemoryCardBakedModel( baseModel, texture );
}
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
// Load the base model
try
{
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity().toItemTransform();
} }
} }
+17 -11
View File
@@ -19,6 +19,7 @@
package appeng.core; package appeng.core;
import java.lang.annotation.ElementType;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@@ -28,7 +29,10 @@ import java.util.stream.Collectors;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.minecraftforge.fml.common.discovery.ASMDataTable; import org.objectweb.asm.Type;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.forgespi.language.ModFileScanData;
import appeng.api.AEInjectable; import appeng.api.AEInjectable;
import appeng.api.AEPlugin; import appeng.api.AEPlugin;
@@ -40,28 +44,30 @@ import appeng.api.AEPlugin;
class PluginLoader class PluginLoader
{ {
public void loadPlugins( Collection<Object> injectables, ASMDataTable asmDataTable ) public void loadPlugins( Collection<Object> injectables )
{ {
Map<Class<?>, Object> injectableMap = mapInjectables( injectables ); Map<Class<?>, Object> injectableMap = mapInjectables( injectables );
findAndInstantiatePlugins( asmDataTable, injectableMap ); findAndInstantiatePlugins( injectableMap );
} }
private static void findAndInstantiatePlugins( ASMDataTable dataTable, Map<Class<?>, Object> injectableMap ) private static void findAndInstantiatePlugins( Map<Class<?>, Object> injectableMap )
{ {
Set<ASMDataTable.ASMData> allAnnotated = dataTable.getAll( AEPlugin.class.getCanonicalName() ); Type aType = Type.getType( AEPlugin.class );
Set<ModFileScanData.AnnotationData> allAnnotated = ModList.get().getAllScanData().stream().map( ModFileScanData::getAnnotations ).flatMap( Collection::stream ).filter( a -> a.getAnnotationType().equals( aType ) ).filter( a -> a.getTargetType() == ElementType.TYPE ).collect( Collectors.toSet() );
for( ASMDataTable.ASMData candidate : allAnnotated ) for( ModFileScanData.AnnotationData candidate : allAnnotated )
{ {
String cName = candidate.getMemberName();
Class<?> aClass; Class<?> aClass;
try try
{ {
aClass = Class.forName( candidate.getClassName() ); aClass = Class.forName( cName );
} }
catch( ClassNotFoundException e ) catch( ClassNotFoundException e )
{ {
AELog.error( e, "Couldn't find annotated AE plugin class " + candidate.getClassName() ); AELog.error( e, "Couldn't find annotated AE plugin class " + cName );
throw new RuntimeException( "Couldn't find annotated AE plugin class " + candidate.getClassName(), e ); throw new RuntimeException( "Couldn't find annotated AE plugin class " + cName, e );
} }
// Try instantiating the plugin // Try instantiating the plugin
@@ -72,8 +78,8 @@ class PluginLoader
} }
catch( Exception e ) catch( Exception e )
{ {
AELog.error( e, "Unable to instantiate AE plugin " + candidate.getClassName() ); AELog.error( e, "Unable to instantiate AE plugin " + cName );
throw new RuntimeException( "Unable to instantiate AE plugin " + candidate.getClassName(), e ); throw new RuntimeException( "Unable to instantiate AE plugin " + cName, e );
} }
} }
} }
+2 -2
View File
@@ -21,7 +21,7 @@ package appeng.core.api;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -37,7 +37,7 @@ public class ApiPart implements IPartHelper
{ {
@Override @Override
public ActionResult placeBus( final ItemStack is, final BlockPos pos, final Direction side, final PlayerEntity player, final Hand hand, final World w ) public ActionResultType placeBus( final ItemStack is, final BlockPos pos, final Direction side, final PlayerEntity player, final Hand hand, final World w )
{ {
return PartPlacement.place( is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0 ); return PartPlacement.place( is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0 );
} }
@@ -31,10 +31,11 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.registries.ForgeRegistries;
import appeng.api.AEApi;
import appeng.api.config.TunnelType; import appeng.api.config.TunnelType;
import appeng.api.definitions.IBlocks; import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
@@ -43,6 +44,7 @@ import appeng.api.definitions.IParts;
import appeng.api.features.IP2PTunnelRegistry; import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.capabilities.Capabilities; import appeng.capabilities.Capabilities;
import appeng.core.Api;
public final class P2PTunnelRegistry implements IP2PTunnelRegistry public final class P2PTunnelRegistry implements IP2PTunnelRegistry
@@ -257,10 +259,10 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
} }
@Nonnull @Nonnull
private ItemStack getModItem( final String modID, final String name, final int meta ) private ItemStack getModItem( final String modID, final String name )
{ {
final Item item = Item.getByNameOrId( modID + ":" + name ); final Item item = ForgeRegistries.ITEMS.getValue( new ResourceLocation( modID + ":" + name ) );
if( item == null ) if( item == null )
{ {
@@ -30,6 +30,7 @@ import appeng.api.AEApi;
import appeng.api.features.ILocatable; import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistry; import appeng.api.features.IWirelessTermRegistry;
import appeng.core.Api;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.util.Platform; import appeng.util.Platform;
@@ -15,6 +15,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.Api;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.util.Platform; import appeng.util.Platform;
@@ -27,6 +27,7 @@ import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.ISaveProvider; import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.core.Api;
import appeng.items.storage.ItemCreativeStorageCell; import appeng.items.storage.ItemCreativeStorageCell;
import appeng.me.storage.CreativeCellInventory; import appeng.me.storage.CreativeCellInventory;
@@ -20,6 +20,8 @@ package appeng.core.localization;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
public enum ButtonToolTips public enum ButtonToolTips
@@ -162,14 +164,15 @@ public enum ButtonToolTips
this.root = r; this.root = r;
} }
@Deprecated
public String getLocal() public String getLocal()
{ {
return I18n.format( this.getTranslationKey() ); return getTranslationKey().getFormattedText();
} }
public String getTranslationKey() public ITextComponent getTranslationKey()
{ {
return this.root + '.' + this.toString(); return new TranslationTextComponent( this.root + '.' + this.toString() );
} }
} }
@@ -33,6 +33,7 @@ import net.minecraft.advancements.ICriterionTrigger;
import net.minecraft.advancements.PlayerAdvancements; import net.minecraft.advancements.PlayerAdvancements;
import net.minecraft.advancements.criterion.CriterionInstance; import net.minecraft.advancements.criterion.CriterionInstance;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng; import appeng.core.AppEng;
@@ -98,7 +99,7 @@ public class AppEngAdvancementTrigger implements ICriterionTrigger<AppEngAdvance
} }
@Override @Override
public void trigger( PlayerEntity parPlayer ) public void trigger( ServerPlayerEntity parPlayer )
{ {
AppEngAdvancementTrigger.Listeners l = this.listeners.get( parPlayer.getAdvancements() ); AppEngAdvancementTrigger.Listeners l = this.listeners.get( parPlayer.getAdvancements() );
@@ -20,10 +20,11 @@ package appeng.core.stats;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@FunctionalInterface @FunctionalInterface
public interface IAdvancementTrigger public interface IAdvancementTrigger
{ {
void trigger( PlayerEntity parPlayer ); void trigger( ServerPlayerEntity parPlayer );
} }
@@ -21,11 +21,10 @@ package appeng.core.stats;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.minecraft.advancements.critereon.ItemPredicate; import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.JSONUtils; import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.advancements.critereon.ItemPredicates;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.items.parts.ItemPart; import appeng.items.parts.ItemPart;
@@ -65,6 +64,6 @@ public class PartItemPredicate extends ItemPredicate
public static void register() public static void register()
{ {
ItemPredicates.register( new ResourceLocation( AppEng.MOD_ID, "part" ), PartItemPredicate::deserialize ); ItemPredicate.register( new ResourceLocation( AppEng.MOD_ID, "part" ), PartItemPredicate::deserialize );
} }
} }
@@ -84,6 +84,7 @@ import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.ContainerVibrationChamber; import appeng.container.implementations.ContainerVibrationChamber;
import appeng.container.implementations.ContainerWireless; import appeng.container.implementations.ContainerWireless;
import appeng.container.implementations.ContainerWirelessTerm; import appeng.container.implementations.ContainerWirelessTerm;
import appeng.core.Api;
import appeng.fluids.container.ContainerFluidFormationPlane; import appeng.fluids.container.ContainerFluidFormationPlane;
import appeng.fluids.container.ContainerFluidIO; import appeng.fluids.container.ContainerFluidIO;
import appeng.fluids.container.ContainerFluidInterface; import appeng.fluids.container.ContainerFluidInterface;
@@ -43,7 +43,7 @@ public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implement
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet ); final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet );
pack.clientPacketData( manager, Minecraft.getInstance().player ); pack.clientPacketData( manager, Minecraft.getInstance().player );
} }
catch( final InstantiationException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e ) catch( final IllegalArgumentException e )
{ {
AELog.debug( e ); AELog.debug( e );
} }
@@ -42,7 +42,7 @@ public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase imp
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet ); final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet );
pack.serverPacketData( manager, player ); pack.serverPacketData( manager, player );
} }
catch( final InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) catch( final IllegalArgumentException e )
{ {
AELog.debug( e ); AELog.debug( e );
} }
@@ -54,7 +54,7 @@ public class PacketCompassResponse extends AppEngPacket
public PacketCompassResponse( final PacketCompassRequest req, final boolean hasResult, final boolean spin, final double radians ) public PacketCompassResponse( final PacketCompassRequest req, final boolean hasResult, final boolean spin, final double radians )
{ {
final PacketBuffer data = new ( Unpooled.buffer() ); final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() ); data.writeInt( this.getPacketID() );
data.writeLong( this.attunement = req.attunement ); data.writeLong( this.attunement = req.attunement );
@@ -24,9 +24,9 @@ import java.io.IOException;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@@ -272,7 +272,7 @@ public class PacketValueConfig extends AppEngPacket
} }
else if( this.Name.equals( "CraftingStatus" ) && this.Value.equals( "Clear" ) ) else if( this.Name.equals( "CraftingStatus" ) && this.Value.equals( "Clear" ) )
{ {
final GuiScreen gs = Minecraft.getInstance().currentScreen; final Screen gs = Minecraft.getInstance().currentScreen;
if( gs instanceof GuiCraftingCPU ) if( gs instanceof GuiCraftingCPU )
{ {
( (GuiCraftingCPU) gs ).clearItems(); ( (GuiCraftingCPU) gs ).clearItems();
@@ -19,6 +19,7 @@
package appeng.core.worlddata; package appeng.core.worlddata;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@@ -86,6 +87,6 @@ class PlayerMappingsInitializer
*/ */
public Map<Integer, UUID> getPlayerMappings() public Map<Integer, UUID> getPlayerMappings()
{ {
return this.playerMappings; return Collections.emptyMap(); //this.playerMappings; //FIXME
} }
} }
@@ -45,6 +45,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.hooks.TickHandler; import appeng.hooks.TickHandler;
@@ -36,6 +36,7 @@ import appeng.api.networking.security.IActionSource;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.me.cluster.implementations.CraftingCPUCluster;
@@ -38,6 +38,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.core.Api;
import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.util.Platform; import appeng.util.Platform;
@@ -28,6 +28,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.util.inv.ItemListIgnoreCrafting; import appeng.util.inv.ItemListIgnoreCrafting;
@@ -33,7 +33,7 @@ import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
public class BlockCubeGenerator extends AEBaseTileBlock public class BlockCubeGenerator extends AEBaseTileBlock<TileCubeGenerator>
{ {
public BlockCubeGenerator() public BlockCubeGenerator()
@@ -50,7 +50,7 @@ public class BlockCubeGenerator extends AEBaseTileBlock
tcg.click( player ); tcg.click( player );
} }
return true; return ActionResultType.SUCCESS;
} }
} }
@@ -33,7 +33,7 @@ import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
public class BlockPhantomNode extends AEBaseTileBlock public class BlockPhantomNode extends AEBaseTileBlock<TilePhantomNode>
{ {
public BlockPhantomNode() public BlockPhantomNode()
@@ -46,7 +46,7 @@ public class BlockPhantomNode extends AEBaseTileBlock
{ {
final TilePhantomNode tpn = this.getTileEntity( w, pos ); final TilePhantomNode tpn = this.getTileEntity( w, pos );
tpn.triggerCrashMode(); tpn.triggerCrashMode();
return true; return ActionResultType.SUCCESS;
} }
} }
@@ -41,7 +41,7 @@ public class GuiFluidFormationPlane extends GuiUpgradeable
final int yo = 23 + 6; final int yo = 23 + 6;
final IAEFluidTank config = this.plane.getConfig(); final IAEFluidTank config = this.plane.getConfig();
final ContainerFluidFormationPlane container = (ContainerFluidFormationPlane) this.inventorySlots; final ContainerFluidFormationPlane container = (ContainerFluidFormationPlane) this.container;
for( int y = 0; y < 7; y++ ) for( int y = 0; y < 7; y++ )
{ {
@@ -63,7 +63,7 @@ public class GuiFluidFormationPlane extends GuiUpgradeable
@Override @Override
protected void addButtons() protected void addButtons()
{ {
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 ) );
} }
@Override @Override
@@ -51,7 +51,7 @@ public class GuiFluidIO extends GuiUpgradeable
{ {
super.init(); super.init();
final ContainerFluidIO container = (ContainerFluidIO) this.inventorySlots; final ContainerFluidIO container = (ContainerFluidIO) this.container;
final IAEFluidTank inv = this.bus.getConfig(); final IAEFluidTank inv = this.bus.getConfig();
final int y = 40; final int y = 40;
final int x = 80; final int x = 80;
@@ -68,7 +68,7 @@ public class GuiFluidInterface extends GuiUpgradeable
this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) ); this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) );
} }
this.priority = new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ); this.priority = new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer );
this.addButton( this.priority ); this.addButton( this.priority );
} }
@@ -1,16 +1,19 @@
package appeng.fluids.client.gui.widgets; package appeng.fluids.client.gui.widgets;
import java.util.Collections; import java.util.Collections;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
@@ -44,15 +47,16 @@ public class GuiFluidSlot extends GuiCustomSlot
RenderSystem.disableLighting(); RenderSystem.disableLighting();
RenderSystem.disableBlend(); RenderSystem.disableBlend();
final Fluid fluid = fs.getFluid(); final Fluid fluid = fs.getFluid();
mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE ); final FluidAttributes attributes = fluid.getAttributes();
final TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() ); mc.getTextureManager().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE );
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture() );
// Set color for dynamic fluids // Set color for dynamic fluids
// Convert int color to RGB // Convert int color to RGB
final float red = ( fluid.getColor() >> 16 & 255 ) / 255.0F; final float red = ( attributes.getColor() >> 16 & 255 ) / 255.0F;
final float green = ( fluid.getColor() >> 8 & 255 ) / 255.0F; final float green = ( attributes.getColor() >> 8 & 255 ) / 255.0F;
final float blue = ( fluid.getColor() & 255 ) / 255.0F; final float blue = ( attributes.getColor() & 255 ) / 255.0F;
RenderSystem.color4f( red, green, blue ); RenderSystem.color3f( red, green, blue );
this.drawTexturedModalRect( this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight() ); this.drawTexturedModalRect( this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight() );
} }
@@ -62,7 +66,7 @@ public class GuiFluidSlot extends GuiCustomSlot
public boolean canClick( final PlayerEntity player ) public boolean canClick( final PlayerEntity player )
{ {
final ItemStack mouseStack = player.inventory.getItemStack(); final ItemStack mouseStack = player.inventory.getItemStack();
return mouseStack.isEmpty() || mouseStack.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null ); return mouseStack.isEmpty() || mouseStack.getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY ).isPresent();
} }
@Override @Override
@@ -74,11 +78,10 @@ public class GuiFluidSlot extends GuiCustomSlot
} }
else if( mouseButton == 0 ) else if( mouseButton == 0 )
{ {
final FluidStack fluid = FluidUtil.getFluidContained( clickStack ); final LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained( clickStack );
if( fluid != null ) fluidOpt.ifPresent( fluid -> {
{
this.setFluidStack( AEFluidStack.fromFluidStack( fluid ) ); this.setFluidStack( AEFluidStack.fromFluidStack( fluid ) );
} } );
} }
} }
@@ -88,7 +91,7 @@ public class GuiFluidSlot extends GuiCustomSlot
final IAEFluidStack fluid = this.getFluidStack(); final IAEFluidStack fluid = this.getFluidStack();
if( fluid != null ) if( fluid != null )
{ {
return fluid.getFluidStack().getLocalizedName(); return I18n.format( fluid.getFluidStack().getTranslationKey() );
} }
return null; return null;
} }
@@ -6,8 +6,9 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
@@ -32,7 +33,7 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable im
public abstract IAEFluidTank getFluidConfigInventory(); public abstract IAEFluidTank getFluidConfigInventory();
private FluidSyncHelper getSynchHelper() private FluidSyncHelper getSyncHelper()
{ {
if( this.sync == null ) if( this.sync == null )
{ {
@@ -44,11 +45,11 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable im
@Override @Override
protected ItemStack transferStackToContainer( ItemStack input ) protected ItemStack transferStackToContainer( ItemStack input )
{ {
FluidStack fs = FluidUtil.getFluidContained( input ); LazyOptional<FluidStack> fsOpt = FluidUtil.getFluidContained( input );
if( fs != null ) if( fsOpt.isPresent() )
{ {
final IAEFluidTank t = this.getFluidConfigInventory(); final IAEFluidTank t = this.getFluidConfigInventory();
final IAEFluidStack stack = AEFluidStack.fromFluidStack( fs ); final IAEFluidStack stack = AEFluidStack.fromFluidStack( fsOpt.orElse( null ) );
for( int i = 0; i < t.getSlots(); ++i ) for( int i = 0; i < t.getSlots(); ++i )
{ {
if( t.getFluidInSlot( i ) == null && this.isValidForConfig( i, stack ) ) if( t.getFluidInSlot( i ) == null && this.isValidForConfig( i, stack ) )
@@ -86,7 +87,7 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable im
{ {
if( Platform.isServer() ) if( Platform.isServer() )
{ {
this.getSynchHelper().sendDiff( this.listeners ); this.getSyncHelper().sendDiff( this.listeners );
// clear out config items that are no longer valid (eg capacity upgrade removed) // clear out config items that are no longer valid (eg capacity upgrade removed)
final IAEFluidTank t = this.getFluidConfigInventory(); final IAEFluidTank t = this.getFluidConfigInventory();
@@ -105,13 +106,13 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable im
public void addListener( IContainerListener listener ) public void addListener( IContainerListener listener )
{ {
super.addListener( listener ); super.addListener( listener );
this.getSynchHelper().sendFull( Collections.singleton( listener ) ); this.getSyncHelper().sendFull( Collections.singleton( listener ) );
} }
@Override @Override
public void receiveFluidSlots( Map<Integer, IAEFluidStack> fluids ) public void receiveFluidSlots( Map<Integer, IAEFluidStack> fluids )
{ {
this.getSynchHelper().readPacket( fluids ); this.getSyncHelper().readPacket( fluids );
} }
} }
@@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.container.IContainerListener;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
@@ -1,8 +1,7 @@
package appeng.fluids.container; package appeng.fluids.container;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -22,7 +21,7 @@ public class ContainerFluidLevelEmitter extends ContainerFluidConfigurable
private final PartFluidLevelEmitter lvlEmitter; private final PartFluidLevelEmitter lvlEmitter;
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
private GuiTextField textField; private TextFieldWidget textField;
@GuiSync( 3 ) @GuiSync( 3 )
public long EmitterValue = -1; public long EmitterValue = -1;
@@ -33,7 +32,7 @@ public class ContainerFluidLevelEmitter extends ContainerFluidConfigurable
} }
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
public void setTextField( final GuiTextField level ) public void setTextField( final TextFieldWidget level )
{ {
this.textField = level; this.textField = level;
this.textField.setText( String.valueOf( this.EmitterValue ) ); this.textField.setText( String.valueOf( this.EmitterValue ) );
@@ -36,6 +36,7 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.core.Api;
import appeng.fluids.parts.PartFluidStorageBus; import appeng.fluids.parts.PartFluidStorageBus;
import appeng.fluids.util.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform; import appeng.util.Platform;
@@ -21,19 +21,19 @@ package appeng.fluids.container;
import java.io.IOException; import java.io.IOException;
import java.nio.BufferOverflowException; import java.nio.BufferOverflowException;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IContainerListener; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerMultiplier;
import appeng.api.config.Settings; import appeng.api.config.Settings;
@@ -60,6 +60,7 @@ import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEFluidInventoryUpdate; import appeng.core.sync.packets.PacketMEFluidInventoryUpdate;
import appeng.core.sync.packets.PacketTargetFluidStack; import appeng.core.sync.packets.PacketTargetFluidStack;
@@ -358,12 +359,13 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
return; return;
} }
final IFluidHandlerItem fh = FluidUtil.getFluidHandler( held ); final LazyOptional<IFluidHandlerItem> fhOpt = FluidUtil.getFluidHandler( held );
if( fh == null ) if( !fhOpt.isPresent() )
{ {
// only fluid handlers items // only fluid handlers items
return; return;
} }
IFluidHandlerItem fh = fhOpt.orElse( null );
if( action == InventoryAction.FILL_ITEM && this.clientRequestedTargetFluid != null ) if( action == InventoryAction.FILL_ITEM && this.clientRequestedTargetFluid != null )
{ {
@@ -371,7 +373,7 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
// Check how much we can store in the item // Check how much we can store in the item
stack.setStackSize( Integer.MAX_VALUE ); stack.setStackSize( Integer.MAX_VALUE );
int amountAllowed = fh.fill( stack.getFluidStack(), false ); int amountAllowed = fh.fill( stack.getFluidStack(), FluidAction.SIMULATE );
stack.setStackSize( amountAllowed ); stack.setStackSize( amountAllowed );
// Check if we can pull out of the system // Check if we can pull out of the system
@@ -382,7 +384,7 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
} }
// How much could fit into the container // How much could fit into the container
final int canFill = fh.fill( canPull.getFluidStack(), false ); final int canFill = fh.fill( canPull.getFluidStack(), FluidAction.SIMULATE );
if( canFill == 0 ) if( canFill == 0 )
{ {
return; return;
@@ -399,7 +401,7 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
} }
// Actually fill // Actually fill
final int used = fh.fill( pulled.getFluidStack(), true ); final int used = fh.fill( pulled.getFluidStack(), FluidAction.EXECUTE );
if( used != canFill ) if( used != canFill )
{ {
@@ -412,37 +414,35 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
else if( action == InventoryAction.EMPTY_ITEM ) else if( action == InventoryAction.EMPTY_ITEM )
{ {
// See how much we can drain from the item // See how much we can drain from the item
final FluidStack extract = fh.drain( Integer.MAX_VALUE, false ); final FluidStack extract = fh.drain( Integer.MAX_VALUE, FluidAction.SIMULATE );
if( extract == null || extract.amount < 1 ) if( extract == null || extract.getAmount() < 1 )
{ {
return; return;
} }
// Check if we can push into the system // Check if we can push into the system
final IAEFluidStack notStorable = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ), final IAEFluidStack notStorable = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ), this.getActionSource(), Actionable.SIMULATE );
this.getActionSource(), Actionable.SIMULATE );
if( notStorable != null && notStorable.getStackSize() > 0 ) if( notStorable != null && notStorable.getStackSize() > 0 )
{ {
final int toStore = (int) ( extract.amount - notStorable.getStackSize() ); final int toStore = (int) ( extract.getAmount() - notStorable.getStackSize() );
final FluidStack storable = fh.drain( toStore, false ); final FluidStack storable = fh.drain( toStore, FluidAction.SIMULATE );
if( storable == null || storable.amount == 0 ) if( storable == null || storable.getAmount() == 0 )
{ {
return; return;
} }
else else
{ {
extract.amount = storable.amount; extract.setAmount( storable.getAmount() );
} }
} }
// Actually drain // Actually drain
final FluidStack drained = fh.drain( extract, true ); final FluidStack drained = fh.drain( extract, FluidAction.EXECUTE );
extract.amount = drained.amount; extract.setAmount( drained.getAmount() );
final IAEFluidStack notInserted = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ), final IAEFluidStack notInserted = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ), this.getActionSource() );
this.getActionSource() );
if( notInserted != null && notInserted.getStackSize() > 0 ) if( notInserted != null && notInserted.getStackSize() > 0 )
{ {
@@ -26,6 +26,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@@ -57,6 +58,7 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities; import appeng.capabilities.Capabilities;
import appeng.core.Api;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory; import appeng.fluids.util.IAEFluidInventory;
@@ -403,7 +405,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
// make sure strange things didn't happen... // make sure strange things didn't happen...
final FluidStack canExtract = this.tanks.drain( slot, toStore.getFluidStack(), false ); final FluidStack canExtract = this.tanks.drain( slot, toStore.getFluidStack(), false );
if( canExtract == null || canExtract.amount != toStore.getStackSize() ) if( canExtract == null || canExtract.getAmount() != toStore.getStackSize() )
{ {
changed = true; changed = true;
} }
@@ -417,7 +419,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
// extract items! // extract items!
changed = true; changed = true;
final FluidStack removed = this.tanks.drain( slot, toStore.getFluidStack(), true ); final FluidStack removed = this.tanks.drain( slot, toStore.getFluidStack(), true );
if( removed == null || toStore.getStackSize() != removed.amount ) if( removed == null || toStore.getStackSize() != removed.getAmount() )
{ {
throw new IllegalStateException( "bad attempt at managing tanks. ( drain )" ); throw new IllegalStateException( "bad attempt at managing tanks. ( drain )" );
} }
@@ -494,7 +496,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
public void writeToNBT( final CompoundNBT data ) public void writeToNBT( final CompoundNBT data )
{ {
data.setInteger( "priority", this.priority ); data.putInt( "priority", this.priority );
this.tanks.writeToNBT( data, "storage" ); this.tanks.writeToNBT( data, "storage" );
this.config.writeToNBT( data, "config" ); this.config.writeToNBT( data, "config" );
} }
@@ -503,7 +505,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
{ {
this.config.readFromNBT( data, "config" ); this.config.readFromNBT( data, "config" );
this.tanks.readFromNBT( data, "storage" ); this.tanks.readFromNBT( data, "storage" );
this.priority = data.getInteger( "priority" ); this.priority = data.getInt( "priority" );
this.readConfig(); this.readConfig();
} }
@@ -23,6 +23,8 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
@@ -51,13 +53,14 @@ public class FluidCellConfig extends CellConfig
{ {
super.insertItem( slot, stack, simulate ); super.insertItem( slot, stack, simulate );
} }
FluidStack fluid = FluidUtil.getFluidContained( stack ); LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained( stack );
if( fluid == null || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() ) if( !fluidOpt.isPresent() || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() )
{ {
return stack; return stack;
} }
FluidStack fluid = fluidOpt.orElse( null );
fluid.amount = FluidAttributes.BUCKET_VOLUME; fluid.setAmount( FluidAttributes.BUCKET_VOLUME );
ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get(); ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get();
FluidDummyItem item = (FluidDummyItem) is.getItem(); FluidDummyItem item = (FluidDummyItem) is.getItem();
item.setFluidStack( is, fluid ); item.setFluidStack( is, fluid );
@@ -71,13 +74,14 @@ public class FluidCellConfig extends CellConfig
{ {
super.setStackInSlot( slot, stack ); super.setStackInSlot( slot, stack );
} }
FluidStack fluid = FluidUtil.getFluidContained( stack ); LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained( stack );
if( fluid == null || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() ) if( !fluidOpt.isPresent() || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() )
{ {
return; return;
} }
FluidStack fluid = fluidOpt.orElse( null );
fluid.amount = FluidAttributes.BUCKET_VOLUME; fluid.setAmount( FluidAttributes.BUCKET_VOLUME );
ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get(); ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get();
FluidDummyItem item = (FluidDummyItem) is.getItem(); FluidDummyItem item = (FluidDummyItem) is.getItem();
item.setFluidStack( is, fluid ); item.setFluidStack( is, fluid );
@@ -91,12 +95,14 @@ public class FluidCellConfig extends CellConfig
{ {
super.isItemValid( slot, stack ); super.isItemValid( slot, stack );
} }
FluidStack fluid = FluidUtil.getFluidContained( stack ); LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained( stack );
if( fluid == null || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() ) if( !fluidOpt.isPresent() || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() )
{ {
return false; return false;
} }
fluid.amount = FluidAttributes.BUCKET_VOLUME; FluidStack fluid = fluidOpt.orElse( null );
fluid.setAmount( FluidAttributes.BUCKET_VOLUME );
ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get(); ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get();
FluidDummyItem item = (FluidDummyItem) is.getItem(); FluidDummyItem item = (FluidDummyItem) is.getItem();
item.setFluidStack( is, fluid ); item.setFluidStack( is, fluid );
@@ -7,7 +7,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.container.IContainerListener;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
@@ -27,6 +27,7 @@ import appeng.api.AEApi;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.core.Api;
import appeng.fluids.helper.FluidCellConfig; import appeng.fluids.helper.FluidCellConfig;
import appeng.items.materials.MaterialType; import appeng.items.materials.MaterialType;
import appeng.items.storage.AbstractStorageCell; import appeng.items.storage.AbstractStorageCell;
@@ -114,4 +115,4 @@ public final class BasicFluidStorageCell extends AbstractStorageCell<IAEFluidSta
} }
} ); } );
} }
} }
@@ -28,9 +28,7 @@ import java.util.Map;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor; import appeng.api.networking.storage.IBaseMonitor;
@@ -41,6 +39,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.AEFluidStack;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.helpers.IGridProxyable; import appeng.me.helpers.IGridProxyable;
@@ -75,9 +74,9 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
FluidStack fluidStack = input.getFluidStack(); FluidStack fluidStack = input.getFluidStack();
// Insert // Insert
int wasFillled = this.fluidHandler.fill( fluidStack, type != Actionable.SIMULATE ); int wasFillled = this.fluidHandler.fill( fluidStack, type.getFluidAction() );
int remaining = fluidStack.amount - wasFillled; int remaining = fluidStack.getAmount() - wasFillled;
if( fluidStack.amount == remaining ) if( fluidStack.getAmount() == remaining )
{ {
// The stack was unmodified, target tank is full // The stack was unmodified, target tank is full
return input; return input;
@@ -95,7 +94,7 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
} }
} }
fluidStack.amount = remaining; fluidStack.setAmount( remaining );
return AEFluidStack.fromFluidStack( fluidStack ); return AEFluidStack.fromFluidStack( fluidStack );
} }
@@ -104,10 +103,9 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
public IAEFluidStack extractItems( IAEFluidStack request, Actionable mode, IActionSource src ) public IAEFluidStack extractItems( IAEFluidStack request, Actionable mode, IActionSource src )
{ {
FluidStack requestedFluidStack = request.getFluidStack(); FluidStack requestedFluidStack = request.getFluidStack();
final boolean doDrain = ( mode == Actionable.MODULATE );
// Drain the fluid from the tank // Drain the fluid from the tank
FluidStack gathered = this.fluidHandler.drain( requestedFluidStack, doDrain ); FluidStack gathered = this.fluidHandler.drain( requestedFluidStack, mode.getFluidAction() );
if( gathered == null ) if( gathered == null )
{ {
// If nothing was pulled from the tank, return null // If nothing was pulled from the tank, return null
@@ -204,8 +202,7 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
public List<IAEFluidStack> update() public List<IAEFluidStack> update()
{ {
final List<IAEFluidStack> changes = new ArrayList<>(); final List<IAEFluidStack> changes = new ArrayList<>();
final IFluidTankProperties[] tankProperties = this.fluidHandler.getTankProperties(); final int slots = fluidHandler.getTanks();
final int slots = tankProperties.length;
// Make room for new slots // Make room for new slots
if( slots > this.cachedAeStacks.length ) if( slots > this.cachedAeStacks.length )
@@ -217,7 +214,7 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
{ {
// Save the old stuff // Save the old stuff
final IAEFluidStack oldAEFS = this.cachedAeStacks[slot]; final IAEFluidStack oldAEFS = this.cachedAeStacks[slot];
final FluidStack newFS = tankProperties[slot].getContents(); final FluidStack newFS = fluidHandler.getFluidInTank( slot );
this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes ); this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes );
} }
@@ -263,12 +260,12 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
private void handleStackSizeChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List<IAEFluidStack> changes ) private void handleStackSizeChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List<IAEFluidStack> changes )
{ {
// Still the same fluid, but amount might have changed // Still the same fluid, but amount might have changed
final long diff = newFS.amount - oldAeFS.getStackSize(); final long diff = newFS.getAmount() - oldAeFS.getStackSize();
if( diff != 0 ) if( diff != 0 )
{ {
final IAEFluidStack stack = oldAeFS.copy(); final IAEFluidStack stack = oldAeFS.copy();
stack.setStackSize( newFS.amount ); stack.setStackSize( newFS.getAmount() );
this.cachedAeStacks[slot] = stack; this.cachedAeStacks[slot] = stack;
@@ -24,8 +24,10 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
@@ -103,12 +105,16 @@ public class PartFluidExportBus extends PartSharedFluidBus
} }
final TileEntity te = this.getConnectedTE(); final TileEntity te = this.getConnectedTE();
LazyOptional<IFluidHandler> fhOpt = LazyOptional.empty();
if( te != null && te.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ) ) if( te != null )
{
te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() );
}
if( fhOpt.isPresent() )
{ {
try try
{ {
final IFluidHandler fh = te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ); final IFluidHandler fh = fhOpt.orElse( null );
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory( this.getChannel() ); final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory( this.getChannel() );
if( fh != null ) if( fh != null )
@@ -126,7 +132,7 @@ public class PartFluidExportBus extends PartSharedFluidBus
if( out != null ) if( out != null )
{ {
int wasInserted = fh.fill( out.getFluidStack(), true ); int wasInserted = fh.fill( out.getFluidStack(), FluidAction.EXECUTE );
if( wasInserted > 0 ) if( wasInserted > 0 )
{ {
@@ -7,7 +7,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -18,10 +17,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.templates.FluidTank;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
@@ -40,6 +40,7 @@ import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.Api;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory; import appeng.fluids.util.IAEFluidInventory;
@@ -124,10 +125,10 @@ public class PartFluidFormationPlane extends PartAbstractFormationPlane<IAEFluid
if( type == Actionable.MODULATE ) if( type == Actionable.MODULATE )
{ {
final FluidStack fs = input.getFluidStack(); final FluidStack fs = input.getFluidStack();
fs.amount = FluidAttributes.BUCKET_VOLUME; fs.setAmount( FluidAttributes.BUCKET_VOLUME );
final FluidTank tank = new FluidTank( fs, FluidAttributes.BUCKET_VOLUME ); final FluidTank tank = new FluidTank( FluidAttributes.BUCKET_VOLUME, e -> e.isFluidEqual( fs ) );
if( !FluidUtil.tryPlaceFluid( null, w, pos, tank, fs ) ) if( !FluidUtil.tryPlaceFluid( null, w, Hand.MAIN_HAND, pos, tank, fs ) )
{ {
return input; return input;
} }
@@ -24,9 +24,11 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
@@ -98,17 +100,21 @@ public class PartFluidImportBus extends PartSharedFluidBus
} }
final TileEntity te = this.getConnectedTE(); final TileEntity te = this.getConnectedTE();
LazyOptional<IFluidHandler> fhOpt = LazyOptional.empty();
if( te != null && te.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ) ) if( te != null )
{
te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() );
}
if( fhOpt.isPresent() )
{ {
try try
{ {
final IFluidHandler fh = te.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite() ); final IFluidHandler fh = fhOpt.orElse( null );
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory( this.getChannel() ); final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory( this.getChannel() );
if( fh != null ) if( fh != null )
{ {
final FluidStack fluidStack = fh.drain( this.calculateAmountToSend(), false ); final FluidStack fluidStack = fh.drain( this.calculateAmountToSend(), FluidAction.SIMULATE );
if( this.filterEnabled() && !this.isInFilter( fluidStack ) ) if( this.filterEnabled() && !this.isInFilter( fluidStack ) )
{ {
@@ -126,7 +132,7 @@ public class PartFluidImportBus extends PartSharedFluidBus
aeFluidStack.decStackSize( notInserted.getStackSize() ); aeFluidStack.decStackSize( notInserted.getStackSize() );
} }
fh.drain( aeFluidStack.getFluidStack(), true ); fh.drain( aeFluidStack.getFluidStack(), FluidAction.EXECUTE );
return TickRateModulation.FASTER; return TickRateModulation.FASTER;
} }
@@ -32,7 +32,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkChannelsChanged; import appeng.api.networking.events.MENetworkChannelsChanged;
@@ -49,6 +48,7 @@ import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.fluids.helper.DualityFluidInterface; import appeng.fluids.helper.DualityFluidInterface;
@@ -7,6 +7,7 @@ import java.util.Random;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
@@ -37,6 +38,7 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.AEFluidInventory;
@@ -22,7 +22,6 @@ package appeng.fluids.parts;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -33,10 +32,10 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude; import appeng.api.config.IncludeExclude;
@@ -63,6 +62,7 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.capabilities.Capabilities; import appeng.capabilities.Capabilities;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
@@ -118,7 +118,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
{ {
Direction targetSide = this.getSide().getFacing().getOpposite(); Direction targetSide = this.getSide().getFacing().getOpposite();
// Prioritize a handler to directly link to another ME network // Prioritize a handler to directly link to another ME network
IStorageMonitorableAccessor accessor = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ); IStorageMonitorableAccessor accessor = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ).orElse( null );
if( accessor != null ) if( accessor != null )
{ {
IStorageMonitorable inventory = accessor.getInventory( this.source ); IStorageMonitorable inventory = accessor.getInventory( this.source );
@@ -135,7 +135,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
} }
// Check via cap for IItemHandler // Check via cap for IItemHandler
IFluidHandler handlerExt = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide ); IFluidHandler handlerExt = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide ).orElse( null );
if( handlerExt != null ) if( handlerExt != null )
{ {
return new FluidHandlerAdapter( handlerExt, this ); return new FluidHandlerAdapter( handlerExt, this );
@@ -195,9 +195,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
@Override @Override
protected void resetCache( final boolean fullReset ) protected void resetCache( final boolean fullReset )
{ {
if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost() if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote )
.getTile()
.getWorld().isRemote )
{ {
return; return;
} }
@@ -267,9 +265,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
{ {
if( this.getProxy().isActive() ) if( this.getProxy().isActive() )
{ {
this.getProxy() this.getProxy().getStorage().postAlterationOfStoredItems( Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
.getStorage()
.postAlterationOfStoredItems( Api.INSTANCE.storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
} }
} }
catch( final GridAccessException e ) catch( final GridAccessException e )
@@ -333,8 +329,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{ {
this.handler.setPartitionList( this.handler.setPartitionList( new FuzzyPriorityList<IAEFluidStack>( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
new FuzzyPriorityList<IAEFluidStack>( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
} }
else else
{ {
@@ -431,16 +426,17 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
final Direction targetSide = this.getSide().getFacing().getOpposite(); final Direction targetSide = this.getSide().getFacing().getOpposite();
if( target.hasCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) ) LazyOptional<IStorageMonitorableAccessor> accessorOpt = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide );
if( accessorOpt.isPresent() )
{ {
return Objects.hash( target, target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) ); return Objects.hash( target, accessorOpt.orElse( null ) );
} }
final IFluidHandler fluidHandler = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide ); final IFluidHandler fluidHandler = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide ).orElse( null );
if( fluidHandler != null ) if( fluidHandler != null )
{ {
return Objects.hash( target, fluidHandler, fluidHandler.getTankProperties().length ); return Objects.hash( target, fluidHandler, fluidHandler.getTanks() );
} }
return 0; return 0;
@@ -25,12 +25,12 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.RedstoneMode; import appeng.api.config.RedstoneMode;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.IGridTickable;
@@ -38,6 +38,7 @@ import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.parts.IPartCollisionHelper; import appeng.api.parts.IPartCollisionHelper;
import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.core.Api;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
@@ -130,7 +131,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
{ {
final World w = self.getWorld(); final World w = self.getWorld();
if( w.getChunkProvider().getLoadedChunk( pos.getX() >> 4, pos.getZ() >> 4 ) != null ) if( w.getChunkProvider().isChunkLoaded( new ChunkPos( pos ) ) )
{ {
return w.getTileEntity( pos ); return w.getTileEntity( pos );
} }
@@ -23,7 +23,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import appeng.api.AEApi;
import appeng.api.implementations.tiles.IChestOrDrive; import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.ICellGuiHandler; import appeng.api.storage.ICellGuiHandler;
import appeng.api.storage.ICellHandler; import appeng.api.storage.ICellHandler;
@@ -32,6 +31,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.Api;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.util.Platform; import appeng.util.Platform;
@@ -43,6 +43,7 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.core.Api;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.fluids.helper.DualityFluidInterface; import appeng.fluids.helper.DualityFluidInterface;
import appeng.fluids.helper.IFluidInterfaceHost; import appeng.fluids.helper.IFluidInterfaceHost;
+4 -3
View File
@@ -21,7 +21,7 @@ package appeng.hooks;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -31,8 +31,9 @@ import net.minecraft.world.World;
public interface IBlockTool public interface IBlockTool
{ {
// Workaround for dispenser logic. // Workaround for dispenser logic.
ActionResult onItemUse( ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ); //TODO ItemUseContext
ActionResultType onItemUse( ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ );
ActionResult onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ); ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ );
} }
+4 -2
View File
@@ -35,6 +35,7 @@ import com.google.common.base.Stopwatch;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.Phase;
@@ -49,6 +50,7 @@ import appeng.api.parts.CableRenderMode;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.packets.PacketPaintedEntity; import appeng.core.sync.packets.PacketPaintedEntity;
import appeng.crafting.CraftingJob; import appeng.crafting.CraftingJob;
@@ -64,7 +66,7 @@ public class TickHandler
public static final TickHandler INSTANCE = new TickHandler(); public static final TickHandler INSTANCE = new TickHandler();
private final Queue<IWorldCallable<?>> serverQueue = new ArrayDeque<>(); private final Queue<IWorldCallable<?>> serverQueue = new ArrayDeque<>();
private final Multimap<World, CraftingJob> craftingJobs = LinkedListMultimap.create(); private final Multimap<World, CraftingJob> craftingJobs = LinkedListMultimap.create();
private final WeakHashMap<World, Queue<IWorldCallable<?>>> callQueue = new WeakHashMap<>(); private final WeakHashMap<IWorld, Queue<IWorldCallable<?>>> callQueue = new WeakHashMap<>();
private final HandlerRep server = new HandlerRep(); private final HandlerRep server = new HandlerRep();
private final HandlerRep client = new HandlerRep(); private final HandlerRep client = new HandlerRep();
private final HashMap<Integer, PlayerColor> cliPlayerColors = new HashMap<>(); private final HashMap<Integer, PlayerColor> cliPlayerColors = new HashMap<>();
@@ -80,7 +82,7 @@ public class TickHandler
return this.cliPlayerColors; return this.cliPlayerColors;
} }
public void addCallable( final World w, final IWorldCallable<?> c ) public void addCallable( final IWorld w, final IWorldCallable<?> c )
{ {
if( w == null ) if( w == null )
{ {
@@ -38,14 +38,12 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.ActionResultType;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -86,7 +84,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
@Override @Override
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips ) public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{ {
super.addInformation( stack, world, lines, advancedTooltips ); super.addInformation( stack, world, lines, advancedTooltips );
@@ -98,7 +96,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
if( mt == MaterialType.NAME_PRESS ) if( mt == MaterialType.NAME_PRESS )
{ {
final CompoundNBT c = stack.getOrCreateTag(); final CompoundNBT c = stack.getOrCreateTag();
lines.add( c.getString( "InscribeName" ) ); lines.add( c.getString( "InscribeName" ) );
} }
@@ -223,16 +221,18 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
} }
@Override @Override
public EnumActionResult onItemUseFirst( final PlayerEntity player, final World world, final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand ) public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
{ {
PlayerEntity player = context.getPlayer();
Hand hand = context.getHand();
if( player.isShiftKeyDown() ) if( player.isShiftKeyDown() )
{ {
final TileEntity te = world.getTileEntity( pos ); final TileEntity te = context.getWorld().getTileEntity( context.getPos() );
IItemHandler upgrades = null; IItemHandler upgrades = null;
if( te instanceof IPartHost ) if( te instanceof IPartHost )
{ {
final SelectedPart sp = ( (IPartHost) te ).selectPart( new Vec3d( hitX, hitY, hitZ ) ); final SelectedPart sp = ( (IPartHost) te ).selectPart( context.getHitVec() );
if( sp.part instanceof IUpgradeableHost ) if( sp.part instanceof IUpgradeableHost )
{ {
upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" ); upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" );
@@ -252,17 +252,17 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
{ {
if( player.world.isRemote ) if( player.world.isRemote )
{ {
return EnumActionResult.PASS; return ActionResultType.PASS;
} }
final InventoryAdaptor ad = new AdaptorItemHandler( upgrades ); final InventoryAdaptor ad = new AdaptorItemHandler( upgrades );
player.setHeldItem( hand, ad.addItems( player.getHeldItem( hand ) ) ); player.setHeldItem( hand, ad.addItems( player.getHeldItem( hand ) ) );
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
} }
} }
return super.onItemUseFirst( player, world, pos, side, hitX, hitY, hitZ, hand ); return super.onItemUseFirst( stack, context );
} }
@Override @Override
@@ -279,18 +279,14 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
try try
{ {
eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ) eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack );
.newInstance( w, location.getPosX(),
location.getPosY(), location.getPosZ(), itemstack );
} }
catch( final Throwable t ) catch( final Throwable t )
{ {
throw new IllegalStateException( t ); throw new IllegalStateException( t );
} }
eqi.motionX = location.motionX; eqi.setMotion( location.getMotion() );
eqi.motionY = location.motionY;
eqi.motionZ = location.motionZ;
if( location instanceof ItemEntity && eqi instanceof ItemEntity ) if( location instanceof ItemEntity && eqi instanceof ItemEntity )
{ {
@@ -379,5 +375,4 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
return o1.compareTo( o2 ); return o1.compareTo( o2 );
} }
} }
} }
@@ -22,7 +22,7 @@ package appeng.items.materials;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Set; import java.util.Set;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -163,7 +163,8 @@ public enum MaterialType
public ItemStack stack( final int size ) public ItemStack stack( final int size )
{ {
return new ItemStack( this.getItemInstance(), size, this.getDamageValue() ); //FIXME
return new ItemStack( this.getItemInstance(), size/*, this.getDamageValue()*/ );
} }
Set<AEFeature> getFeature() Set<AEFeature> getFeature()
@@ -33,6 +33,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -41,6 +42,7 @@ import appeng.api.AEApi;
import appeng.api.definitions.IMaterials; import appeng.api.definitions.IMaterials;
import appeng.api.implementations.items.IGrowableCrystal; import appeng.api.implementations.items.IGrowableCrystal;
import appeng.api.recipes.ResolverResult; import appeng.api.recipes.ResolverResult;
import appeng.core.Api;
import appeng.core.localization.ButtonToolTips; import appeng.core.localization.ButtonToolTips;
import appeng.entity.EntityGrowingCrystal; import appeng.entity.EntityGrowingCrystal;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
@@ -92,13 +94,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
{ {
if( is.hasTag() ) if( is.hasTag() )
{ {
return is.getTag().getInteger( "progress" ); return is.getTag().getInt( "progress" );
} }
else else
{ {
final int progress; final int progress;
final CompoundNBT comp = is.getOrCreateTag(); final CompoundNBT comp = is.getOrCreateTag();
comp.setInteger( "progress", progress = is.getDamage() ); comp.putInt( "progress", progress = is.getDamage() );
is.setItemDamage( ( is.getDamage() / SINGLE_OFFSET ) * SINGLE_OFFSET ); is.setItemDamage( ( is.getDamage() / SINGLE_OFFSET ) * SINGLE_OFFSET );
return progress; return progress;
} }
@@ -148,7 +150,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
private void setProgress( final ItemStack is, final int newDamage ) private void setProgress( final ItemStack is, final int newDamage )
{ {
final CompoundNBT comp = is.getOrCreateTag(); final CompoundNBT comp = is.getOrCreateTag();
comp.setInteger( "progress", newDamage ); comp.putInt( "progress", newDamage );
is.setItemDamage( is.getDamage() / LEVEL_OFFSET * LEVEL_OFFSET ); is.setItemDamage( is.getDamage() / LEVEL_OFFSET * LEVEL_OFFSET );
} }
@@ -162,9 +164,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips ) public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{ {
lines.add( ButtonToolTips.DoesntDespawn.getLocal() ); lines.add( ButtonToolTips.DoesntDespawn.getTranslationKey() );
final int progress = getProgress( stack ) % SINGLE_OFFSET; final int progress = getProgress( stack ) % SINGLE_OFFSET;
lines.add( Math.floor( (float) progress / (float) ( SINGLE_OFFSET / 100 ) ) + "%" ); lines.add( new StringTextComponent( Math.floor( (float) progress / (float) ( SINGLE_OFFSET / 100 ) ) + "%" ) );
super.addInformation( stack, world, lines, advancedTooltips ); super.addInformation( stack, world, lines, advancedTooltips );
} }
@@ -227,9 +229,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
{ {
final EntityGrowingCrystal egc = new EntityGrowingCrystal( world, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack ); final EntityGrowingCrystal egc = new EntityGrowingCrystal( world, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack );
egc.motionX = location.motionX; egc.setMotion( location.getMotion() );
egc.motionY = location.motionY;
egc.motionZ = location.motionZ;
// Cannot read the pickup delay of the original item, so we // Cannot read the pickup delay of the original item, so we
// use the pickup delay used for items dropped by a player instead // use the pickup delay used for items dropped by a player instead
@@ -22,7 +22,7 @@ package appeng.items.misc;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -27,21 +27,20 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.AEApi;
import appeng.api.implementations.ICraftingPatternItem; import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.helpers.InvalidPatternHelper; import appeng.helpers.InvalidPatternHelper;
@@ -65,13 +64,13 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
{ {
this.clearPattern( player.getHeldItem( hand ), player ); this.clearPattern( player.getHeldItem( hand ), player );
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
} }
@Override @Override
public EnumActionResult onItemUseFirst( final PlayerEntity player, final World world, final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand ) public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
{ {
return this.clearPattern( player.getHeldItem( hand ), player ) ? EnumActionResult.SUCCESS : EnumActionResult.PASS; return this.clearPattern( stack, context.getPlayer() ) ? ActionResultType.SUCCESS : ActionResultType.PASS;
} }
private boolean clearPattern( final ItemStack stack, final PlayerEntity player ) private boolean clearPattern( final ItemStack stack, final PlayerEntity player )
@@ -104,7 +103,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
@Override @Override
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips ) public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{ {
final ICraftingPatternDetails details = this.getPatternForItem( stack, world ); final ICraftingPatternDetails details = this.getPatternForItem( stack, world );
@@ -150,7 +149,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
if( stack.hasDisplayName() ) if( stack.hasDisplayName() )
{ {
stack.removeSubCompound( "display" ); stack.removeChildTag( "display" );
} }
final boolean isCrafting = details.isCraftable(); final boolean isCrafting = details.isCraftable();
@@ -19,7 +19,8 @@
package appeng.items.misc; package appeng.items.misc;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
@@ -28,10 +28,12 @@ import net.minecraft.block.BlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumBlockRenderType;
@@ -71,9 +73,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
} }
@Override @Override
public EnumActionResult onItemUseFirst( final PlayerEntity player, final World world, final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand ) public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
{ {
return Api.INSTANCE.partHelper().placeBus( player.getHeldItem( hand ), pos, side, player, hand, world ); return Api.INSTANCE.partHelper().placeBus( stack, context.getPos(), context.getFace(), context.getPlayer(), context.getHand(), context.getWorld() );
} }
@Override @Override
@@ -37,6 +37,8 @@ import com.google.common.base.Preconditions;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@@ -49,6 +51,7 @@ import appeng.api.implementations.items.IItemGroup;
import appeng.api.parts.IPart; import appeng.api.parts.IPart;
import appeng.api.parts.IPartItem; import appeng.api.parts.IPartItem;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.core.Api;
import appeng.core.features.ActivityState; import appeng.core.features.ActivityState;
import appeng.core.features.ItemStackSrc; import appeng.core.features.ItemStackSrc;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
@@ -152,14 +155,16 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
} }
@Override @Override
public EnumActionResult onItemUse( final PlayerEntity player, final World w, final BlockPos pos, final Hand hand, final Direction side, final float hitX, final float hitY, final float hitZ ) public ActionResultType onItemUse( ItemUseContext context )
{ {
if( this.getTypeByStack( player.getHeldItem( hand ) ) == PartType.INVALID_TYPE ) PlayerEntity player = context.getPlayer();
ItemStack held = player.getHeldItem( context.getHand() );
if( this.getTypeByStack( held ) == PartType.INVALID_TYPE )
{ {
return EnumActionResult.FAIL; return ActionResultType.FAIL;
} }
return Api.INSTANCE.partHelper().placeBus( player.getHeldItem( hand ), pos, side, player, hand, w ); return Api.INSTANCE.partHelper().placeBus( held, context.getPos(), context.getFace(), player, context.getHand(), context.getWorld() );
} }
@Override @Override
@@ -24,7 +24,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -26,7 +26,9 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@@ -48,6 +50,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
@@ -162,7 +165,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
public ActionResult<ItemStack> onItemRightClick( final World world, final PlayerEntity player, final Hand hand ) public ActionResult<ItemStack> onItemRightClick( final World world, final PlayerEntity player, final Hand hand )
{ {
this.disassembleDrive( player.getHeldItem( hand ), world, player ); this.disassembleDrive( player.getHeldItem( hand ), world, player );
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
} }
private boolean disassembleDrive( final ItemStack stack, final World world, final PlayerEntity player ) private boolean disassembleDrive( final ItemStack stack, final World world, final PlayerEntity player )
@@ -206,9 +209,9 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
// drop empty storage cell case // drop empty storage cell case
this.dropEmptyStorageCellCase( ia, player ); this.dropEmptyStorageCellCase( ia, player );
if( player.inventoryContainer != null ) if( player.container != null )
{ {
player.inventoryContainer.detectAndSendChanges(); player.container.detectAndSendChanges();
} }
return true; return true;
@@ -221,9 +224,9 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
protected abstract void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player ); protected abstract void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player );
@Override @Override
public EnumActionResult onItemUseFirst( final PlayerEntity player, final World world, final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand ) public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
{ {
return this.disassembleDrive( player.getHeldItem( hand ), world, player ) ? EnumActionResult.SUCCESS : EnumActionResult.PASS; return this.disassembleDrive( stack, context.getWorld(), context.getPlayer() ) ? ActionResultType.SUCCESS : ActionResultType.PASS;
} }
@Override @Override
@@ -26,6 +26,7 @@ import appeng.api.AEApi;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.core.Api;
import appeng.items.materials.MaterialType; import appeng.items.materials.MaterialType;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
@@ -35,6 +35,7 @@ import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.ICellWorkbenchItem; import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.core.Api;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig; import appeng.items.contents.CellConfig;
@@ -110,7 +110,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
if( is.hasTag() ) if( is.hasTag() )
{ {
final CompoundNBT c = is.getTag(); final CompoundNBT c = is.getTag();
return new WorldCoord( c.getInteger( NBT_SIZE_X_KEY ), c.getInteger( NBT_SIZE_Y_KEY ), c.getInteger( NBT_SIZE_Z_KEY ) ); return new WorldCoord( c.getInt( NBT_SIZE_X_KEY ), c.getInt( NBT_SIZE_Y_KEY ), c.getInt( NBT_SIZE_Z_KEY ) );
} }
return new WorldCoord( 0, 0, 0 ); return new WorldCoord( 0, 0, 0 );
} }
@@ -121,7 +121,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
if( is.hasTag() ) if( is.hasTag() )
{ {
final CompoundNBT c = is.getTag(); final CompoundNBT c = is.getTag();
return c.getInteger( NBT_CELL_ID_KEY ); return c.getInt( NBT_CELL_ID_KEY );
} }
return -1; return -1;
} }
@@ -182,9 +182,9 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
{ {
final CompoundNBT c = is.getOrCreateTag(); final CompoundNBT c = is.getOrCreateTag();
c.setInteger( NBT_CELL_ID_KEY, id ); c.putInt( NBT_CELL_ID_KEY, id );
c.setInteger( NBT_SIZE_X_KEY, size.getX() ); c.putInt( NBT_SIZE_X_KEY, size.getX() );
c.setInteger( NBT_SIZE_Y_KEY, size.getY() ); c.putInt( NBT_SIZE_Y_KEY, size.getY() );
c.setInteger( NBT_SIZE_Z_KEY, size.getZ() ); c.putInt( NBT_SIZE_Z_KEY, size.getZ() );
} }
} }
@@ -107,7 +107,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
@Override @Override
public void setProfile( final ItemStack itemStack, final GameProfile profile ) public void setProfile( final ItemStack itemStack, final GameProfile profile )
{ {
final CompoundNBT tag = Platform.openNbtData( itemStack ); final CompoundNBT tag = itemStack.getOrCreateTag();
if( profile != null ) if( profile != null )
{ {
@@ -124,7 +124,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
@Override @Override
public GameProfile getProfile( final ItemStack is ) public GameProfile getProfile( final ItemStack is )
{ {
final CompoundNBT tag = Platform.openNbtData( is ); final CompoundNBT tag = is.getOrCreateTag();
if( tag.contains( "profile" ) ) if( tag.contains( "profile" ) )
{ {
return NBTUtil.readGameProfile( tag.getCompound( "profile" ) ); return NBTUtil.readGameProfile( tag.getCompound( "profile" ) );
@@ -135,7 +135,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
@Override @Override
public EnumSet<SecurityPermissions> getPermissions( final ItemStack is ) public EnumSet<SecurityPermissions> getPermissions( final ItemStack is )
{ {
final CompoundNBT tag = Platform.openNbtData( is ); final CompoundNBT tag = is.getOrCreateTag();
final EnumSet<SecurityPermissions> result = EnumSet.noneOf( SecurityPermissions.class ); final EnumSet<SecurityPermissions> result = EnumSet.noneOf( SecurityPermissions.class );
for( final SecurityPermissions sp : SecurityPermissions.values() ) for( final SecurityPermissions sp : SecurityPermissions.values() )
@@ -152,14 +152,14 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
@Override @Override
public boolean hasPermission( final ItemStack is, final SecurityPermissions permission ) public boolean hasPermission( final ItemStack is, final SecurityPermissions permission )
{ {
final CompoundNBT tag = Platform.openNbtData( is ); final CompoundNBT tag = is.getOrCreateTag();
return tag.getBoolean( permission.name() ); return tag.getBoolean( permission.name() );
} }
@Override @Override
public void removePermission( final ItemStack itemStack, final SecurityPermissions permission ) public void removePermission( final ItemStack itemStack, final SecurityPermissions permission )
{ {
final CompoundNBT tag = Platform.openNbtData( itemStack ); final CompoundNBT tag = itemStack.getOrCreateTag();
if( tag.contains( permission.name() ) ) if( tag.contains( permission.name() ) )
{ {
tag.remove( permission.name() ); tag.remove( permission.name() );
@@ -169,7 +169,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
@Override @Override
public void addPermission( final ItemStack itemStack, final SecurityPermissions permission ) public void addPermission( final ItemStack itemStack, final SecurityPermissions permission )
{ {
final CompoundNBT tag = Platform.openNbtData( itemStack ); final CompoundNBT tag = itemStack.getOrCreateTag();
tag.putBoolean( permission.name(), true ); tag.putBoolean( permission.name(), true );
} }
@@ -1,8 +1,7 @@
package appeng.items.tools; package appeng.items.tools;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -25,18 +25,15 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponent;
import net.minecraft.util.text.TextComponentUtils;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n; import net.minecraft.world.IWorldReader;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -54,18 +51,24 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{ {
private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] { private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] {
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
}; AEColor.TRANSPARENT,
AEColor.TRANSPARENT,
AEColor.TRANSPARENT,
AEColor.TRANSPARENT,
AEColor.TRANSPARENT,
AEColor.TRANSPARENT,
};
public ToolMemoryCard() public ToolMemoryCard()
{ {
this.setMaxStackSize( 1 ); super( new Properties().maxStackSize( 1 ) );
} }
@Override @Override
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips ) public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{ {
lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) ); lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) );
@@ -113,15 +116,15 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
@Override @Override
public void setMemoryCardContents( final ItemStack is, final String settingsName, final CompoundNBT data ) public void setMemoryCardContents( final ItemStack is, final String settingsName, final CompoundNBT data )
{ {
final CompoundNBT c = Platform.openNbtData( is ); final CompoundNBT c = is.getOrCreateTag();
c.setString( "Config", settingsName ); c.putString( "Config", settingsName );
c.setTag( "Data", data ); c.put( "Data", data );
} }
@Override @Override
public String getSettingsName( final ItemStack is ) public String getSettingsName( final ItemStack is )
{ {
final CompoundNBT c = Platform.openNbtData( is ); final CompoundNBT c = is.getOrCreateTag();
final String name = c.getString( "Config" ); final String name = c.getString( "Config" );
return name == null || name.isEmpty() ? GuiText.Blank.getUnlocalized() : name; return name == null || name.isEmpty() ? GuiText.Blank.getUnlocalized() : name;
} }
@@ -129,8 +132,8 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
@Override @Override
public CompoundNBT getData( final ItemStack is ) public CompoundNBT getData( final ItemStack is )
{ {
final CompoundNBT c = Platform.openNbtData( is ); final CompoundNBT c = is.getOrCreateTag();
CompoundNBT o = c.getCompoundTag( "Data" ); CompoundNBT o = c.getCompound( "Data" );
if( o == null ) if( o == null )
{ {
o = new CompoundNBT(); o = new CompoundNBT();
@@ -143,15 +146,21 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{ {
final CompoundNBT tag = this.getData( is ); final CompoundNBT tag = this.getData( is );
if( tag.hasKey( "colorCode" ) ) if( tag.contains( "colorCode" ) )
{ {
final int[] frequency = tag.getIntArray( "colorCode" ); final int[] frequency = tag.getIntArray( "colorCode" );
final AEColor[] colorArray = AEColor.values(); final AEColor[] colorArray = AEColor.values();
return new AEColor[] { return new AEColor[] {
colorArray[frequency[0]], colorArray[frequency[1]], colorArray[frequency[2]], colorArray[frequency[3]], colorArray[frequency[0]],
colorArray[frequency[4]], colorArray[frequency[5]], colorArray[frequency[6]], colorArray[frequency[7]], colorArray[frequency[1]],
}; colorArray[frequency[2]],
colorArray[frequency[3]],
colorArray[frequency[4]],
colorArray[frequency[5]],
colorArray[frequency[6]],
colorArray[frequency[7]],
};
} }
return DEFAULT_COLOR_CODE; return DEFAULT_COLOR_CODE;
@@ -187,19 +196,19 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
} }
@Override @Override
public EnumActionResult onItemUse( final PlayerEntity player, final World w, final BlockPos pos, final Hand hand, final Direction side, final float hx, final float hy, final float hz ) public ActionResultType onItemUse( ItemUseContext context )
{ {
if( player.isShiftKeyDown() ) if( context.getPlayer().isShiftKeyDown() )
{ {
if( !w.isRemote ) if( !context.getPlayer().world.isRemote )
{ {
this.clearCard( player, w, hand ); this.clearCard( context.getPlayer(), context.getWorld(), context.getHand() );
} }
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
else else
{ {
return super.onItemUse( player, w, pos, hand, side, hx, hy, hz ); return super.onItemUse( context );
} }
} }
@@ -215,11 +224,10 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
} }
return super.onItemRightClick( w, player, hand ); return super.onItemRightClick( w, player, hand );
} }
@Override @Override
public boolean doesSneakBypassUse( final ItemStack itemstack, final IBlockReader world, final BlockPos pos, final PlayerEntity player ) public boolean doesSneakBypassUse( ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player )
{ {
return true; return true;
} }
@@ -228,6 +236,6 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{ {
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem(); final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED ); mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
player.getHeldItem( hand ).setTagCompound( null ); player.getHeldItem( hand ).setTag( null );
} }
} }
@@ -1,8 +1,7 @@
package appeng.items.tools; package appeng.items.tools;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -21,17 +21,21 @@ package appeng.items.tools;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import appeng.api.implementations.guiobjects.IGuiItem; import appeng.api.implementations.guiobjects.IGuiItem;
import appeng.api.implementations.guiobjects.IGuiItemObject; import appeng.api.implementations.guiobjects.IGuiItemObject;
@@ -57,8 +61,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
public ToolNetworkTool() public ToolNetworkTool()
{ {
this.setMaxStackSize( 1 ); super(new Item.Properties().maxStackSize( 1 ).addToolType( ToolType.get("wrench"), 0 ));
this.setHarvestLevel( "wrench", 0 );
} }
@Override @Override
@@ -75,20 +78,20 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
{ {
final RayTraceResult mop = AppEng.proxy.getRTR(); final RayTraceResult mop = AppEng.proxy.getRTR();
if( mop == null || mop.typeOfHit == RayTraceResult.Type.MISS ) if( mop == null || mop.getType() == RayTraceResult.Type.MISS )
{ {
NetworkHandler.instance().sendToServer( new PacketClick( BlockPos.ORIGIN, null, 0, 0, 0, hand ) ); NetworkHandler.instance().sendToServer( new PacketClick( BlockPos.ZERO, null, 0, 0, 0, hand ) );
} }
} }
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
} }
@Override @Override
public EnumActionResult onItemUseFirst( final PlayerEntity player, final World world, final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand ) public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
{ {
final RayTraceResult mop = new RayTraceResult( new Vec3d( hitX, hitY, hitZ ), side, pos ); final RayTraceResult mop = new RayTraceResult( new Vec3d( hitX, hitY, hitZ ), side, pos );
final TileEntity te = world.getTileEntity( pos ); final TileEntity te = context.getWorld().getTileEntity( context.getPos() );
if( te instanceof IPartHost ) if( te instanceof IPartHost )
{ {
@@ -98,17 +101,17 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
{ {
if( part.part instanceof INetworkToolAgent && !( (INetworkToolAgent) part.part ).showNetworkInfo( mop ) ) if( part.part instanceof INetworkToolAgent && !( (INetworkToolAgent) part.part ).showNetworkInfo( mop ) )
{ {
return EnumActionResult.FAIL; return ActionResultType.FAIL;
} }
else if( player.isShiftKeyDown() ) else if( context.getPlayer().isShiftKeyDown() )
{ {
return EnumActionResult.PASS; return ActionResultType.PASS;
} }
} }
} }
else if( te instanceof INetworkToolAgent && !( (INetworkToolAgent) te ).showNetworkInfo( mop ) ) else if( te instanceof INetworkToolAgent && !( (INetworkToolAgent) te ).showNetworkInfo( mop ) )
{ {
return EnumActionResult.FAIL; return ActionResultType.FAIL;
} }
if( Platform.isClient() ) if( Platform.isClient() )
@@ -116,11 +119,11 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
NetworkHandler.instance().sendToServer( new PacketClick( pos, side, hitX, hitY, hitZ, hand ) ); NetworkHandler.instance().sendToServer( new PacketClick( pos, side, hitX, hitY, hitZ, hand ) );
} }
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
@Override @Override
public boolean doesSneakBypassUse( final ItemStack itemstack, final IBlockReader world, final BlockPos pos, final PlayerEntity player ) public boolean doesSneakBypassUse( ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player )
{ {
return true; return true;
} }
@@ -50,10 +50,10 @@ public class ToolChargedStaff extends AEBasePoweredItem
{ {
for( int x = 0; x < 2; x++ ) for( int x = 0; x < 2; x++ )
{ {
final AxisAlignedBB entityBoundingBox = target.getEntityBoundingBox(); final AxisAlignedBB entityBoundingBox = target.getBoundingBox();
final float dx = (float) ( Platform.getRandomFloat() * target.width + entityBoundingBox.minX ); final float dx = (float) ( Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minX );
final float dy = (float) ( Platform.getRandomFloat() * target.height + entityBoundingBox.minY ); final float dy = (float) ( Platform.getRandomFloat() * target.getHeight() + entityBoundingBox.minY );
final float dz = (float) ( Platform.getRandomFloat() * target.width + entityBoundingBox.minZ ); final float dz = (float) ( Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minZ );
AppEng.proxy.sendToAllNearExcept( null, dx, dy, dz, 32.0, target.world, new PacketLightning( dx, dy, dz ) ); AppEng.proxy.sendToAllNearExcept( null, dx, dy, dz, 32.0, target.world, new PacketLightning( dx, dy, dz ) );
} }
} }
@@ -26,6 +26,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import net.minecraft.item.SnowballItem;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.WordUtils;
@@ -68,6 +70,7 @@ import appeng.api.util.DimensionalCoord;
import appeng.block.networking.BlockCableBus; import appeng.block.networking.BlockCableBus;
import appeng.block.paint.BlockPaint; import appeng.block.paint.BlockPaint;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.helpers.IMouseWheelItem; import appeng.helpers.IMouseWheelItem;
import appeng.hooks.IBlockTool; import appeng.hooks.IBlockTool;
@@ -104,13 +107,13 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
} }
@Override @Override
public EnumActionResult onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ) public ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
{ {
return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ ); return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ );
} }
@Override @Override
public EnumActionResult onItemUse( ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ) public ActionResultType onItemUse( ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
{ {
final Block blk = w.getBlockState( pos ).getBlock(); final Block blk = w.getBlockState( pos ).getBlock();
@@ -137,11 +140,11 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) ) if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
{ {
return EnumActionResult.FAIL; return ActionResultType.FAIL;
} }
final double powerPerUse = 100; final double powerPerUse = 100;
if( !paintBall.isEmpty() && paintBall.getItem() instanceof ItemSnowball ) if( !paintBall.isEmpty() && paintBall.getItem() instanceof SnowballItem )
{ {
final TileEntity te = w.getTileEntity( pos ); final TileEntity te = w.getTileEntity( pos );
// clean cables. // clean cables.
@@ -153,7 +156,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
{ {
inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() ); inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse, Actionable.MODULATE ); this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
} }
} }
@@ -166,7 +169,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() ); inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse, Actionable.MODULATE ); this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
( (TilePaint) painted ).cleanSide( side.getOpposite() ); ( (TilePaint) painted ).cleanSide( side.getOpposite() );
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
} }
else if( !paintBall.isEmpty() ) else if( !paintBall.isEmpty() )
@@ -179,7 +182,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
{ {
inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() ); inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse, Actionable.MODULATE ); this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
} }
} }
@@ -190,7 +193,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
this.cycleColors( is, paintBall, 1 ); this.cycleColors( is, paintBall, 1 );
} }
return EnumActionResult.FAIL; return ActionResultType.FAIL;
} }
@Override @Override
@@ -220,7 +223,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
return null; return null;
} }
if( paintBall.getItem() instanceof ItemSnowball ) if( paintBall.getItem() instanceof SnowballItem )
{ {
return AEColor.TRANSPARENT; return AEColor.TRANSPARENT;
} }
@@ -251,7 +254,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
final CompoundNBT c = is.getTag(); final CompoundNBT c = is.getTag();
if( c != null && c.contains("color") ) if( c != null && c.contains("color") )
{ {
final CompoundNBT color = c.getCompoundTag( "color" ); final CompoundNBT color = c.getCompound( "color" );
final ItemStack oldColor = ItemStack.read(color); final ItemStack oldColor = ItemStack.read(color);
if( !oldColor.isEmpty() ) if( !oldColor.isEmpty() )
{ {
@@ -336,13 +339,13 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
final CompoundNBT data = is.getOrCreateTag(); final CompoundNBT data = is.getOrCreateTag();
if( newColor.isEmpty() ) if( newColor.isEmpty() )
{ {
data.removeTag( "color" ); data.remove( "color" );
} }
else else
{ {
final CompoundNBT color = new CompoundNBT(); final CompoundNBT color = new CompoundNBT();
newColor.write(color); newColor.write(color);
data.setTag( "color", color ); data.put( "color", color );
} }
} }
@@ -469,7 +472,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
} }
} }
if( requestedAddition.getItem() instanceof ItemSnowball ) if( requestedAddition.getItem() instanceof SnowballItem )
{ {
return false; return false;
} }
@@ -1,8 +1,7 @@
package appeng.items.tools.powered; package appeng.items.tools.powered;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -35,6 +35,7 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
@@ -216,11 +217,11 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
if( target == null ) if( target == null )
{ {
return new ActionResult<>( EnumActionResult.FAIL, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.FAIL, p.getHeldItem( hand ) );
} }
else else
{ {
if( target.typeOfHit == RayTraceResult.Type.BLOCK ) if( target.getType() == RayTraceResult.Type.BLOCK )
{ {
final BlockState state = w.getBlockState( target.getBlockPos() ); final BlockState state = w.getBlockState( target.getBlockPos() );
if( state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER ) if( state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER )
@@ -237,7 +238,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
} }
@Override @Override
public EnumActionResult onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ ) public ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
{ {
return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ ); return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ );
} }
@@ -20,7 +20,6 @@ package appeng.items.tools.powered;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@@ -34,9 +33,9 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -48,7 +47,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
@@ -62,6 +60,7 @@ import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
@@ -89,15 +88,11 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
@Override @Override
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips ) public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{ {
super.addInformation( stack, world, lines, advancedTooltips ); super.addInformation( stack, world, lines, advancedTooltips );
final ICellInventoryHandler<IAEItemStack> cdi = Api.INSTANCE final ICellInventoryHandler<IAEItemStack> cdi = Api.INSTANCE.registries().cell().getCellInventory( stack, null, Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
.registries()
.cell()
.getCellInventory( stack, null,
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.client().addCellInformation( cdi, lines ); Api.INSTANCE.client().addCellInformation( cdi, lines );
} }
@@ -115,15 +110,10 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
shots += cu.getInstalledUpgrades( Upgrades.SPEED ); shots += cu.getInstalledUpgrades( Upgrades.SPEED );
} }
final ICellInventoryHandler<IAEItemStack> inv = Api.INSTANCE final ICellInventoryHandler<IAEItemStack> inv = Api.INSTANCE.registries().cell().getCellInventory( p.getHeldItem( hand ), null, Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
.registries()
.cell()
.getCellInventory( p.getHeldItem( hand ), null,
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
if( inv != null ) if( inv != null )
{ {
final IItemList<IAEItemStack> itemList = inv final IItemList<IAEItemStack> itemList = inv.getAvailableItems( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList() );
.getAvailableItems( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList() );
IAEItemStack req = itemList.getFirstItem(); IAEItemStack req = itemList.getFirstItem();
if( req instanceof IAEItemStack ) if( req instanceof IAEItemStack )
{ {
@@ -135,23 +125,23 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
if( Platform.isClient() ) if( Platform.isClient() )
{ {
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
} }
aeAmmo.setStackSize( 1 ); aeAmmo.setStackSize( 1 );
final ItemStack ammo = aeAmmo.createItemStack(); final ItemStack ammo = aeAmmo.createItemStack();
if( ammo == null ) if( ammo == null )
{ {
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
} }
aeAmmo = inv.extractItems( aeAmmo, Actionable.MODULATE, new PlayerSource( p, null ) ); aeAmmo = inv.extractItems( aeAmmo, Actionable.MODULATE, new PlayerSource( p, null ) );
if( aeAmmo == null ) if( aeAmmo == null )
{ {
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
} }
final LookDirection dir = Platform.getPlayerRay( p, p.getEyeHeight() ); final LookDirection dir = Platform.getPlayerRay( p );
final Vec3d Vec3d = dir.getA(); final Vec3d Vec3d = dir.getA();
final Vec3d Vec3d1 = dir.getB(); final Vec3d Vec3d1 = dir.getB();
@@ -170,7 +160,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
{ {
this.shootPaintBalls( type, w, p, Vec3d, Vec3d1, direction, d0, d1, d2 ); this.shootPaintBalls( type, w, p, Vec3d, Vec3d1, direction, d0, d1, d2 );
} }
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
} }
else else
{ {
@@ -184,17 +174,16 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
{ {
p.sendMessage( PlayerMessages.AmmoDepleted.get() ); p.sendMessage( PlayerMessages.AmmoDepleted.get() );
} }
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
} }
} }
} }
return new ActionResult<>( EnumActionResult.FAIL, p.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.FAIL, p.getHeldItem( hand ) );
} }
private void shootPaintBalls( final ItemStack type, final World w, final PlayerEntity p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2 ) private void shootPaintBalls( final ItemStack type, final World w, final PlayerEntity p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2 )
{ {
final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 );
.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 );
Entity entity = null; Entity entity = null;
final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb ); final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
@@ -247,9 +236,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
try try
{ {
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1 ) ) );
new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos == null ? 32 : pos.hitVec
.squareDistanceTo( vec ) + 1 ) ) );
} }
catch( final Exception err ) catch( final Exception err )
{ {
@@ -263,7 +250,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final AEColor col = ipb.getColor( type ); final AEColor col = ipb.getColor( type );
// boolean lit = ipb.isLumen( type ); // boolean lit = ipb.isLumen( type );
if( pos.typeOfHit == RayTraceResult.Type.ENTITY ) if( pos.getType() == RayTraceResult.Type.ENTITY )
{ {
final int id = pos.entityHit.getEntityId(); final int id = pos.entityHit.getEntityId();
final PlayerColor marker = new PlayerColor( id, col, 20 * 30 ); final PlayerColor marker = new PlayerColor( id, col, 20 * 30 );
@@ -291,8 +278,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final Block whatsThere = w.getBlockState( hitPos ).getBlock(); final Block whatsThere = w.getBlockState( hitPos ).getBlock();
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) ) if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
{ {
Api.INSTANCE.definitions().blocks().paint().maybeBlock().ifPresent( paintBlock -> Api.INSTANCE.definitions().blocks().paint().maybeBlock().ifPresent( paintBlock -> {
{
w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 ); w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 );
} ); } );
} }
@@ -314,8 +300,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
{ {
hasDestroyed = false; hasDestroyed = false;
final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 );
.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 );
Entity entity = null; Entity entity = null;
final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb ); final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
@@ -367,9 +352,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
try try
{ {
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1 ) ) );
new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos == null ? 32 : pos.hitVec
.squareDistanceTo( vec ) + 1 ) ) );
} }
catch( final Exception err ) catch( final Exception err )
{ {
@@ -457,7 +440,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
@Override @Override
public FuzzyMode getFuzzyMode( final ItemStack is ) public FuzzyMode getFuzzyMode( final ItemStack is )
{ {
final String fz = Platform.openNbtData( is ).getString( "FuzzyMode" ); final String fz = is.getOrCreateTag().getString( "FuzzyMode" );
try try
{ {
return FuzzyMode.valueOf( fz ); return FuzzyMode.valueOf( fz );
@@ -471,7 +454,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
@Override @Override
public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode )
{ {
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); is.getOrCreateTag().putString( "FuzzyMode", fzMode.name() );
} }
@Override @Override
@@ -26,6 +26,7 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -47,6 +48,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.items.contents.CellConfig; import appeng.items.contents.CellConfig;
@@ -67,7 +69,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand ) public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand )
{ {
Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL ); Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL );
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
} }
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
@@ -21,19 +21,19 @@ package appeng.items.tools.powered;
import java.util.List; import java.util.List;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.client.resources.I18n; import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.config.SortDir; import appeng.api.config.SortDir;
@@ -42,6 +42,7 @@ import appeng.api.config.ViewItems;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
@@ -59,7 +60,7 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand ) public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand )
{ {
Api.INSTANCE.registries().wireless().openWirelessTerminalGui( player.getHeldItem( hand ), w, player ); Api.INSTANCE.registries().wireless().openWirelessTerminalGui( player.getHeldItem( hand ), w, player );
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) ); return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
} }
@OnlyIn( Dist.CLIENT ) @OnlyIn( Dist.CLIENT )
@@ -77,7 +78,7 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
if( stack.hasTag() ) if( stack.hasTag() )
{ {
final CompoundNBT tag = stack.getOrCreateTag(); final CompoundNBT tag = stack.getOrCreateTag();
if( tag != null ) if( tag != null )
{ {
final String encKey = tag.getString( "encryptionKey" ); final String encKey = tag.getString( "encryptionKey" );
@@ -119,9 +120,8 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
@Override @Override
public IConfigManager getConfigManager( final ItemStack target ) public IConfigManager getConfigManager( final ItemStack target )
{ {
final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) -> final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) -> {
{ final CompoundNBT data = target.getOrCreateTag();
final CompoundNBT data = target.getOrCreateTag();
manager.writeToNBT( data ); manager.writeToNBT( data );
} ); } );
@@ -129,23 +129,23 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
out.readFromNBT( target.getOrCreateTag().copy() ); out.readFromNBT( target.getOrCreateTag().copy() );
return out; return out;
} }
@Override @Override
public String getEncryptionKey( final ItemStack item ) public String getEncryptionKey( final ItemStack item )
{ {
final CompoundNBT tag = item.getOrCreateTag(); final CompoundNBT tag = item.getOrCreateTag();
return tag.getString( "encryptionKey" ); return tag.getString( "encryptionKey" );
} }
@Override @Override
public void setEncryptionKey( final ItemStack item, final String encKey, final String name ) public void setEncryptionKey( final ItemStack item, final String encKey, final String name )
{ {
final CompoundNBT tag = item.getOrCreateTag(); final CompoundNBT tag = item.getOrCreateTag();
tag.putString("encryptionKey", encKey); tag.putString( "encryptionKey", encKey );
tag.putString("name", name); tag.putString( "name", name );
} }
@Override @Override
@@ -50,10 +50,10 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
public AEBasePoweredItem( final double powerCapacity ) public AEBasePoweredItem( final double powerCapacity )
{ {
this.setMaxStackSize( 1 ); super(new Properties().maxStackSize( 1 ).maxDamage( 32 ));
this.setMaxDamage( 32 ); //FIXME
this.hasSubtypes = false; // this.hasSubtypes = false;
this.setFull3D(); // this.setFull3D();
this.powerCapacity = powerCapacity; this.powerCapacity = powerCapacity;
} }
+7 -6
View File
@@ -31,6 +31,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.exceptions.FailedConnectionException; import appeng.api.exceptions.FailedConnectionException;
@@ -285,7 +286,7 @@ public class GridNode implements IGridNode, IPathItem
} }
@Override @Override
public World getWorld() public IWorld getWorld()
{ {
return this.gridProxy.getLocation().getWorld(); return this.gridProxy.getLocation().getWorld();
} }
@@ -331,8 +332,8 @@ public class GridNode implements IGridNode, IPathItem
{ {
if( this.myGrid == null ) if( this.myGrid == null )
{ {
final CompoundNBT node = nodeData.getCompoundTag( name ); final CompoundNBT node = nodeData.getCompound( name );
this.playerID = node.getInteger( "p" ); this.playerID = node.getInt( "p" );
this.setLastSecurityKey( node.getLong( "k" ) ); this.setLastSecurityKey( node.getLong( "k" ) );
final long storageID = node.getLong( "g" ); final long storageID = node.getLong( "g" );
@@ -356,11 +357,11 @@ public class GridNode implements IGridNode, IPathItem
node.putLong( "k", this.getLastSecurityKey() ); node.putLong( "k", this.getLastSecurityKey() );
node.putLong( "g", this.myStorage.getID() ); node.putLong( "g", this.myStorage.getID() );
nodeData.setTag( name, node ); nodeData.put( name, node );
} }
else else
{ {
nodeData.removeTag( name ); nodeData.remove( name );
} }
} }
@@ -512,7 +513,7 @@ public class GridNode implements IGridNode, IPathItem
} }
} }
private IGridHost findGridHost( final World world, final int x, final int y, final int z ) private IGridHost findGridHost( final IWorld world, final int x, final int y, final int z )
{ {
final BlockPos pos = new BlockPos( x, y, z ); final BlockPos pos = new BlockPos( x, y, z );
if( world.isBlockLoaded( pos ) ) if( world.isBlockLoaded( pos ) )
+2 -1
View File
@@ -77,6 +77,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.crafting.CraftingJob; import appeng.crafting.CraftingJob;
import appeng.crafting.CraftingLink; import appeng.crafting.CraftingLink;
import appeng.crafting.CraftingLinkNexus; import appeng.crafting.CraftingLinkNexus;
@@ -470,7 +471,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
{ {
for( final IAEItemStack ais : this.craftableItems.keySet() ) for( final IAEItemStack ais : this.craftableItems.keySet() )
{ {
if( ais.getItem() == whatToCraft.getItem() && ( !ais.getItem().getHasSubtypes() || ais.getItemDamage() == whatToCraft.getItemDamage() ) ) if( ais.getItem() == whatToCraft.getItem() && ( !ais.getItem().isDamageable() || ais.getItemDamage() == whatToCraft.getItemDamage() ) )
{ {
// TODO: check if OK // TODO: check if OK
// TODO: this is slightly hacky, but fine as long as we only deal with itemstacks // TODO: this is slightly hacky, but fine as long as we only deal with itemstacks
+1
View File
@@ -50,6 +50,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.me.helpers.BaseActionSource; import appeng.me.helpers.BaseActionSource;
import appeng.me.helpers.GenericInterestManager; import appeng.me.helpers.GenericInterestManager;
import appeng.me.helpers.MachineSource; import appeng.me.helpers.MachineSource;
+1
View File
@@ -47,6 +47,7 @@ import appeng.api.networking.pathing.IPathingGrid;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.stats.IAdvancementTrigger; import appeng.core.stats.IAdvancementTrigger;
+1 -1
View File
@@ -26,7 +26,7 @@ import com.google.common.base.Preconditions;
import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory; import net.minecraft.crash.CrashReportCategory;
import net.minecraft.util.ReportedException; import net.minecraft.crash.ReportedException;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
+7 -7
View File
@@ -90,17 +90,17 @@ public class TickTracker implements Comparable<TickTracker>
part.addEntityCrashInfo( crashreportcategory ); part.addEntityCrashInfo( crashreportcategory );
} }
crashreportcategory.addCrashSection( "CurrentTickRate", this.getCurrentRate() ); crashreportcategory.addDetail( "CurrentTickRate", this.getCurrentRate() );
crashreportcategory.addCrashSection( "MinTickRate", this.getRequest().minTickRate ); crashreportcategory.addDetail( "MinTickRate", this.getRequest().minTickRate );
crashreportcategory.addCrashSection( "MaxTickRate", this.getRequest().maxTickRate ); crashreportcategory.addDetail( "MaxTickRate", this.getRequest().maxTickRate );
crashreportcategory.addCrashSection( "MachineType", this.getGridTickable().getClass().getName() ); crashreportcategory.addDetail( "MachineType", this.getGridTickable().getClass().getName() );
crashreportcategory.addCrashSection( "GridBlockType", this.getNode().getGridBlock().getClass().getName() ); crashreportcategory.addDetail( "GridBlockType", this.getNode().getGridBlock().getClass().getName() );
crashreportcategory.addCrashSection( "ConnectedSides", this.getNode().getConnectedSides() ); crashreportcategory.addDetail( "ConnectedSides", this.getNode().getConnectedSides() );
final DimensionalCoord dc = this.getNode().getGridBlock().getLocation(); final DimensionalCoord dc = this.getNode().getGridBlock().getLocation();
if( dc != null ) if( dc != null )
{ {
crashreportcategory.addCrashSection( "Location", dc ); crashreportcategory.addDetail( "Location", dc );
} }
} }
@@ -34,10 +34,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.hooks.BasicEventHooks;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerMultiplier;
@@ -65,6 +64,7 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.WorldCoord; import appeng.api.util.WorldCoord;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.crafting.CraftBranchFailure; import appeng.crafting.CraftBranchFailure;
import appeng.crafting.CraftingJob; import appeng.crafting.CraftingJob;
import appeng.crafting.CraftingLink; import appeng.crafting.CraftingLink;
@@ -390,7 +390,6 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
} }
} }
} }
} }
private void markDirty() private void markDirty()
@@ -779,9 +778,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( details.isCraftable() ) if( details.isCraftable() )
{ {
FMLCommonHandler.instance() BasicEventHooks.firePlayerCraftingEvent( Platform.getPlayer( (ServerWorld) getWorld() ), details.getOutput( ic, this.getWorld() ), ic );
.firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.getWorld() ),
details.getOutput( ic, this.getWorld() ), ic );
for( int x = 0; x < ic.getSizeInventory(); x++ ) for( int x = 0; x < ic.getSizeInventory(); x++ )
{ {
@@ -1003,19 +1000,18 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
final int hash = System.identityHashCode( this ); final int hash = System.identityHashCode( this );
final int hmm = this.finalOutput == null ? 0 : this.finalOutput.hashCode(); final int hmm = this.finalOutput == null ? 0 : this.finalOutput.hashCode();
return Long.toString( now, Character.MAX_RADIX ) + '-' + Integer.toString( hash, Character.MAX_RADIX ) + '-' + Integer.toString( hmm, return Long.toString( now, Character.MAX_RADIX ) + '-' + Integer.toString( hash, Character.MAX_RADIX ) + '-' + Integer.toString( hmm, Character.MAX_RADIX );
Character.MAX_RADIX );
} }
private CompoundNBT generateLinkData( final String craftingID, final boolean standalone, final boolean req ) private CompoundNBT generateLinkData( final String craftingID, final boolean standalone, final boolean req )
{ {
final CompoundNBT tag = new CompoundNBT(); final CompoundNBT tag = new CompoundNBT();
tag.putString("CraftID", craftingID); tag.putString( "CraftID", craftingID );
tag.putBoolean("canceled", false); tag.putBoolean( "canceled", false );
tag.putBoolean("done", false); tag.putBoolean( "done", false );
tag.putBoolean("standalone", standalone); tag.putBoolean( "standalone", standalone );
tag.putBoolean("req", req); tag.putBoolean( "req", req );
return tag; return tag;
} }
@@ -1144,16 +1140,16 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
public void writeToNBT( final CompoundNBT data ) public void writeToNBT( final CompoundNBT data )
{ {
data.setTag( "finalOutput", this.writeItem( this.finalOutput ) ); data.put( "finalOutput", this.writeItem( this.finalOutput ) );
data.setTag( "inventory", this.writeList( this.inventory.getItemList() ) ); data.put( "inventory", this.writeList( this.inventory.getItemList() ) );
data.putBoolean("waiting", this.waiting); data.putBoolean( "waiting", this.waiting );
data.putBoolean("isComplete", this.isComplete); data.putBoolean( "isComplete", this.isComplete );
if( this.myLastLink != null ) if( this.myLastLink != null )
{ {
final CompoundNBT link = new CompoundNBT(); final CompoundNBT link = new CompoundNBT();
this.myLastLink.writeToNBT( link ); this.myLastLink.writeToNBT( link );
data.setTag( "link", link ); data.put( "link", link );
} }
final ListNBT list = new ListNBT(); final ListNBT list = new ListNBT();
@@ -1161,11 +1157,11 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
{ {
final CompoundNBT item = this.writeItem( AEItemStack.fromItemStack( e.getKey().getPattern() ) ); final CompoundNBT item = this.writeItem( AEItemStack.fromItemStack( e.getKey().getPattern() ) );
item.putLong( "craftingProgress", e.getValue().value ); item.putLong( "craftingProgress", e.getValue().value );
list.appendTag( item ); list.add( item );
} }
data.setTag( "tasks", list ); data.put( "tasks", list );
data.setTag( "waitingFor", this.writeList( this.waitingFor ) ); data.put( "waitingFor", this.writeList( this.waitingFor ) );
data.putLong( "elapsedTime", this.getElapsedTime() ); data.putLong( "elapsedTime", this.getElapsedTime() );
data.putLong( "startItemCount", this.getStartItemCount() ); data.putLong( "startItemCount", this.getStartItemCount() );
@@ -1178,7 +1174,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( finalOutput2 != null ) if( finalOutput2 != null )
{ {
finalOutput2.write(out); finalOutput2.writeToNBT( out );
} }
return out; return out;
@@ -1190,7 +1186,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
for( final IAEItemStack ais : myList ) for( final IAEItemStack ais : myList )
{ {
out.appendTag( this.writeItem( ais ) ); out.add( this.writeItem( ais ) );
} }
return out; return out;
@@ -1214,8 +1210,8 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
public void readFromNBT( final CompoundNBT data ) public void readFromNBT( final CompoundNBT data )
{ {
this.finalOutput = AEItemStack.fromNBT( (CompoundNBT) data.getTag( "finalOutput" ) ); this.finalOutput = AEItemStack.fromNBT( data.getCompound( "finalOutput" ) );
for( final IAEItemStack ais : this.readList( (ListNBT) data.getTag( "inventory" ) ) ) for( final IAEItemStack ais : this.readList( data.getList( "inventory", 10 ) ) )
{ {
this.inventory.injectItems( ais, Actionable.MODULATE, this.machineSrc ); this.inventory.injectItems( ais, Actionable.MODULATE, this.machineSrc );
} }
@@ -1223,17 +1219,17 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.waiting = data.getBoolean( "waiting" ); this.waiting = data.getBoolean( "waiting" );
this.isComplete = data.getBoolean( "isComplete" ); this.isComplete = data.getBoolean( "isComplete" );
if( data.contains("link") ) if( data.contains( "link" ) )
{ {
final CompoundNBT link = data.getCompoundTag( "link" ); final CompoundNBT link = data.getCompound( "link" );
this.myLastLink = new CraftingLink( link, this ); this.myLastLink = new CraftingLink( link, this );
this.submitLink( this.myLastLink ); this.submitLink( this.myLastLink );
} }
final ListNBT list = data.getTagList( "tasks", 10 ); final ListNBT list = data.getList( "tasks", 10 );
for( int x = 0; x < list.tagCount(); x++ ) for( int x = 0; x < list.size(); x++ )
{ {
final CompoundNBT item = list.getCompoundTagAt( x ); final CompoundNBT item = list.getCompound( x );
final IAEItemStack pattern = AEItemStack.fromNBT( item ); final IAEItemStack pattern = AEItemStack.fromNBT( item );
if( pattern != null && pattern.getItem() instanceof ICraftingPatternItem ) if( pattern != null && pattern.getItem() instanceof ICraftingPatternItem )
{ {
@@ -1248,7 +1244,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
} }
} }
this.waitingFor = this.readList( (ListNBT) data.getTag( "waitingFor" ) ); this.waitingFor = this.readList( data.getList( "waitingFor", 10 ) );
for( final IAEItemStack is : this.waitingFor ) for( final IAEItemStack is : this.waitingFor )
{ {
this.postCraftingStatusChange( is.copy() ); this.postCraftingStatusChange( is.copy() );
@@ -1289,9 +1285,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
return out; return out;
} }
for( int x = 0; x < tag.tagCount(); x++ ) for( int x = 0; x < tag.size(); x++ )
{ {
final IAEItemStack ais = AEItemStack.fromNBT( tag.getCompoundTagAt( x ) ); final IAEItemStack ais = AEItemStack.fromNBT( tag.getCompound( x ) );
if( ais != null ) if( ais != null )
{ {
out.add( ais ); out.add( ais );
@@ -28,6 +28,7 @@ import appeng.api.AEApi;
import appeng.api.definitions.IBlockDefinition; import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks; import appeng.api.definitions.IBlocks;
import appeng.api.util.WorldCoord; import appeng.api.util.WorldCoord;
import appeng.core.Api;
import appeng.me.cluster.IAECluster; import appeng.me.cluster.IAECluster;
import appeng.me.cluster.IAEMultiBlock; import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.MBCalculator; import appeng.me.cluster.MBCalculator;
@@ -22,14 +22,13 @@ package appeng.me.cluster.implementations;
import java.util.Iterator; import java.util.Iterator;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import appeng.api.AEApi;
import appeng.api.events.LocatableEventAnnounce; import appeng.api.events.LocatableEventAnnounce;
import appeng.api.events.LocatableEventAnnounce.LocatableEvent; import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
import appeng.api.exceptions.FailedConnectionException; import appeng.api.exceptions.FailedConnectionException;
@@ -39,6 +38,7 @@ import appeng.api.networking.IGridNode;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.WorldCoord; import appeng.api.util.WorldCoord;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.me.cache.helpers.ConnectionWrapper; import appeng.me.cache.helpers.ConnectionWrapper;
import appeng.me.cluster.IAECluster; import appeng.me.cluster.IAECluster;
import appeng.tile.qnb.TileQuantumBridge; import appeng.tile.qnb.TileQuantumBridge;
@@ -156,10 +156,7 @@ public class QuantumCluster implements ILocatable, IAECluster
} }
} }
sideA.connection = sideB.connection = new ConnectionWrapper( Api.INSTANCE sideA.connection = sideB.connection = new ConnectionWrapper( Api.INSTANCE.grid().createGridConnection( sideA.getNode(), sideB.getNode() ) );
.grid()
.createGridConnection( sideA.getNode(),
sideB.getNode() ) );
} }
catch( final FailedConnectionException e ) catch( final FailedConnectionException e )
{ {
@@ -196,11 +193,11 @@ public class QuantumCluster implements ILocatable, IAECluster
final World theWorld = qc.center.getWorld(); final World theWorld = qc.center.getWorld();
if( !qc.isDestroyed ) if( !qc.isDestroyed )
{ {
final Chunk c = theWorld.getChunkFromBlockCoords( qc.center.getPos() ); ChunkPos cPos = new ChunkPos( qc.center.getPos() );
if( c.isLoaded() ) if( theWorld.getChunkProvider().isChunkLoaded( cPos ) )
{ {
final int id = theWorld.provider.getDimension(); final DimensionType id = theWorld.dimension.getType();
final World cur = DimensionManager.getWorld( id ); final World cur = theWorld.getServer().getWorld( id );
final TileEntity te = theWorld.getTileEntity( qc.center.getPos() ); final TileEntity te = theWorld.getTileEntity( qc.center.getPos() );
return te != qc.center || theWorld != cur; return te != qc.center || theWorld != cur;
@@ -265,14 +262,12 @@ public class QuantumCluster implements ILocatable, IAECluster
@Override @Override
public Iterator<IGridHost> getTiles() public Iterator<IGridHost> getTiles()
{ {
return new ChainedIterator<>( this.getRing()[0], this.getRing()[1], this.getRing()[2], this.getRing()[3], this.getRing()[4], this return new ChainedIterator<>( this.getRing()[0], this.getRing()[1], this.getRing()[2], this.getRing()[3], this.getRing()[4], this.getRing()[5], this.getRing()[6], this.getRing()[7], this.center );
.getRing()[5], this.getRing()[6], this.getRing()[7], this.center );
} }
public boolean isCorner( final TileQuantumBridge tileQuantumBridge ) public boolean isCorner( final TileQuantumBridge tileQuantumBridge )
{ {
return this.getRing()[0] == tileQuantumBridge || this.getRing()[2] == tileQuantumBridge || this.getRing()[4] == tileQuantumBridge || this return this.getRing()[0] == tileQuantumBridge || this.getRing()[2] == tileQuantumBridge || this.getRing()[4] == tileQuantumBridge || this.getRing()[6] == tileQuantumBridge;
.getRing()[6] == tileQuantumBridge;
} }
@Override @Override

Some files were not shown because too many files have changed in this diff Show More