Compare commits

..

1 Commits

Author SHA1 Message Date
Sebastian Hartte 2216c33f12 Be less defensive about copying item stacks in simulated extractions (but still catch obviously broken implementations).
Also fix looping over the same slot while simulating, and try to heuristically guess the maximum extraction from the slot given what getStackInSlot returned.
2020-10-10 20:13:36 +02:00
12 changed files with 164 additions and 98 deletions
+3 -3
View File
@@ -157,7 +157,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
@@ -192,7 +192,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
@@ -285,7 +285,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
+10 -10
View File
@@ -169,16 +169,16 @@ public class ClientHelper extends ServerHelper {
}
private void postPlayerRender(final RenderLivingEvent.Pre p) {
// FIXME final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get( p.getEntity().getEntityId() );
// FIXME if( player != null )
// FIXME {
// FIXME final AEColor col = player.myColor;
// FIXME final float r = 0xff & ( col.mediumVariant >> 16 );
// FIXME final float g = 0xff & ( col.mediumVariant >> 8 );
// FIXME final float b = 0xff & ( col.mediumVariant );
// FIXME // FIXME: This is most certainly not going to work!
// FIXME GlStateManager.color4f( r / 255.0f, g / 255.0f, b / 255.0f, 1.0f );
// FIXME }
// FIXME final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get( p.getEntity().getEntityId() );
// FIXME if( player != null )
// FIXME {
// FIXME final AEColor col = player.myColor;
// FIXME final float r = 0xff & ( col.mediumVariant >> 16 );
// FIXME final float g = 0xff & ( col.mediumVariant >> 8 );
// FIXME final float b = 0xff & ( col.mediumVariant );
// FIXME // FIXME: This is most certainly not going to work!
// FIXME GlStateManager.color4f( r / 255.0f, g / 255.0f, b / 255.0f, 1.0f );
// FIXME }
}
private void spawnVibrant(final World w, final double x, final double y, final double z) {
@@ -67,7 +67,8 @@ public class StackSizeRenderer {
final float inverseScaleFactor = 1.0f / scaleFactor;
final int offset = AEConfig.instance().isUseLargeFonts() ? 0 : -1;
TransformationMatrix tm = new TransformationMatrix(new Vector3f(0, 0, 300), // Taken from ItemRenderer.renderItemOverlayIntoGUI
TransformationMatrix tm = new TransformationMatrix(new Vector3f(0, 0, 300), // Taken from
// ItemRenderer.renderItemOverlayIntoGUI
null, new Vector3f(scaleFactor, scaleFactor, scaleFactor), null);
RenderSystem.disableBlend();
@@ -144,16 +144,16 @@ public class LightningFX extends SpriteTexturedParticle {
for (int layer = 0; layer < 2; layer++) {
if (layer == 0) {
scale = 0.04;
// FIXME offX *= 0.001;
// FIXME offY *= 0.001;
// FIXME offZ *= 0.001;
// FIXME offX *= 0.001;
// FIXME offY *= 0.001;
// FIXME offZ *= 0.001;
red = this.particleRed * j * 0.4f;
green = this.particleGreen * j * 0.25f;
blue = this.particleBlue * j * 0.45f;
} else {
// FIXME offX = 0;
// FIXME offY = 0;
// FIXME offZ = 0;
// FIXME offX = 0;
// FIXME offY = 0;
// FIXME offZ = 0;
scale = 0.02;
red = this.particleRed * j * 0.9f;
green = this.particleGreen * j * 0.65f;
+36
View File
@@ -177,6 +177,42 @@ public final class AppEng {
return this.registration.advancementTriggers;
}
// @EventHandler
// private void preInit( final FMLPreInitializationEvent event )
// {
// final Stopwatch watch = Stopwatch.createStarted();
// this.configDirectory = new File( event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2" );
//
// final File configFile = new File( this.configDirectory, "AppliedEnergistics2.cfg" );
// final File facadeFile = new File( this.configDirectory, "Facades.cfg" );
// final File versionFile = new File( this.configDirectory, "VersionChecker.cfg" );
// final File recipeFile = new File( this.configDirectory, "CustomRecipes.cfg" );
// final Configuration recipeConfiguration = new Configuration( recipeFile );
//
// AEConfig.init( configFile );
// FacadeConfig.init( facadeFile );
//
// AELog.info( "Pre Initialization ( started )" );
//
//
// for( final IntegrationType type : IntegrationType.values() )
// {
// IntegrationRegistry.INSTANCE.add( type );
// }
//
// this.registration.preInitialize( event );
//
// if( Platform.isClient() )
// {
// AppEng.proxy.preinit();
// }
//
// IntegrationRegistry.INSTANCE.preInit();
//
// AELog.info( "Pre Initialization ( ended after " + watch.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
//
// }
private void startService(final String serviceName, final Thread thread) {
thread.setName(serviceName);
thread.setPriority(Thread.MIN_PRIORITY);
+6 -6
View File
@@ -606,12 +606,12 @@ final class Registration {
blocks.energyCell().maybeItem().ifPresent(cell -> registries.charger().addChargeRate(cell, 8000d));
blocks.energyCellDense().maybeItem().ifPresent(cell -> registries.charger().addChargeRate(cell, 16000d));
// FIXME // add villager trading to black smiths for a few basic materials
// FIXME if( AEConfig.instance().isFeatureEnabled( AEFeature.VILLAGER_TRADING ) )
// FIXME {
// FIXME // TODO: VILLAGER TRADING
// FIXME // VillagerRegistry.instance().getRegisteredVillagers().registerVillageTradeHandler( 3, new AETrading() );
// FIXME }
// FIXME // add villager trading to black smiths for a few basic materials
// FIXME if( AEConfig.instance().isFeatureEnabled( AEFeature.VILLAGER_TRADING ) )
// FIXME {
// FIXME // TODO: VILLAGER TRADING
// FIXME // VillagerRegistry.instance().getRegisteredVillagers().registerVillageTradeHandler( 3, new AETrading() );
// FIXME }
final IMovableRegistry mr = registries.movable();
@@ -73,22 +73,22 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
this.addNewAttunement(blocks.energyCell(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyCellCreative(), TunnelType.FE_POWER);
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
/**
* EU tunnel items
*/
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 0 ), TunnelType.IC2_POWER ); // Copper cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 1 ), TunnelType.IC2_POWER ); // Glass fibre cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 2 ), TunnelType.IC2_POWER ); // Gold cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 3 ), TunnelType.IC2_POWER ); // HV cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 4 ), TunnelType.IC2_POWER ); // Tin cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 0 ), TunnelType.IC2_POWER ); // Copper cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 1 ), TunnelType.IC2_POWER ); // Glass fibre cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 2 ), TunnelType.IC2_POWER ); // Gold cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 3 ), TunnelType.IC2_POWER ); // HV cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 4 ), TunnelType.IC2_POWER ); // Tin cable
/**
* attune based on most redstone base items.
@@ -115,15 +115,15 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
this.addNewAttunement(new ItemStack(Blocks.HOPPER), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.CHEST), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.TRAPPED_CHEST), TunnelType.ITEM);
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 0 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 9 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 1 ), TunnelType.ITEM ); // itemduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 2 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 3 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 0 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 9 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 1 ), TunnelType.ITEM ); // itemduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 2 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 3 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// (opaque)
/**
@@ -133,18 +133,18 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
this.addNewAttunement(new ItemStack(Items.LAVA_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.MILK_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.WATER_BUCKET), TunnelType.FLUID);
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 6 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 0 ), TunnelType.FLUID ); // fluiduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 1 ), TunnelType.FLUID ); // fluiduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 2 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 3 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME // (opaque)
// FIXME
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 6 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 0 ), TunnelType.FLUID ); // fluiduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 1 ), TunnelType.FLUID ); // fluiduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 2 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 3 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME // (opaque)
// FIXME
for (final AEColor c : AEColor.values()) {
this.addNewAttunement(parts.cableGlass().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableCovered().stack(c, 1), TunnelType.ME);
@@ -106,37 +106,37 @@ class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipe> {
ingredients.setOutputs(VanillaTypes.ITEM, outputs);
}
// FIXME USE SPECIAL INGREDIENT TYPE
// FIXME @Override
// FIXME public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY )
// FIXME {
// FIXME
// FIXME FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
// FIXME
// FIXME int x = 118;
// FIXME
// FIXME final float scale = 0.85f;
// FIXME final float invScale = 1 / scale;
// FIXME GlStateManager.scale( scale, scale, 1 );
// FIXME
// FIXME if( this.recipe.getOptionalOutput() != null )
// FIXME {
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getOptionalChance() * 100 ) );
// FIXME float width = fr.getStringWidth( text ) * scale;
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
// FIXME x += 18;
// FIXME }
// FIXME
// FIXME if( this.recipe.getSecondOptionalOutput() != null )
// FIXME {
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getSecondOptionalChance() * 100 ) );
// FIXME float width = fr.getStringWidth( text ) * scale;
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
// FIXME }
// FIXME
// FIXME GlStateManager.scale( invScale, invScale, 1 );
// FIXME }
// FIXME USE SPECIAL INGREDIENT TYPE
// FIXME @Override
// FIXME public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY )
// FIXME {
// FIXME
// FIXME FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
// FIXME
// FIXME int x = 118;
// FIXME
// FIXME final float scale = 0.85f;
// FIXME final float invScale = 1 / scale;
// FIXME GlStateManager.scale( scale, scale, 1 );
// FIXME
// FIXME if( this.recipe.getOptionalOutput() != null )
// FIXME {
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getOptionalChance() * 100 ) );
// FIXME float width = fr.getStringWidth( text ) * scale;
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
// FIXME x += 18;
// FIXME }
// FIXME
// FIXME if( this.recipe.getSecondOptionalOutput() != null )
// FIXME {
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getSecondOptionalChance() * 100 ) );
// FIXME float width = fr.getStringWidth( text ) * scale;
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
// FIXME }
// FIXME
// FIXME GlStateManager.scale( invScale, invScale, 1 );
// FIXME }
}
@@ -47,7 +47,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
public AEBasePoweredItem(final DoubleSupplier powerCapacity, Properties props) {
super(props);
// FIXME this.setFull3D();
// FIXME this.setFull3D();
this.powerCapacity = powerCapacity;
}
@@ -122,6 +122,15 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
do {
extracted = this.itemHandler.extractItem(i, remainingCurrentSlot, simulate);
if (!extracted.isEmpty()) {
// In order to guard against broken IItemHandler implementations, we'll
// try to guess if the returned stack (especially in simulate mode) is
// the same that was returned by getStackInSlot. This is obviously not a
// precise science, but it would catch the previous Forge bug:
// https://github.com/MinecraftForge/MinecraftForge/pull/6580
if (extracted == stackInInventorySlot) {
extracted = extracted.copy();
}
if (extracted.getCount() > remainingCurrentSlot) {
// Something broke. It should never return more than we requested...
// We're going to silently eat the remainder
@@ -131,19 +140,28 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
extracted.setCount(remainingCurrentSlot);
}
// Heuristic for simulation: looping in case of simulations is pointless, since
// the
// state of the underlying inventory does not change after a simulated
// extraction
// To still support inventories that report stacks that are larger than
// maxStackSize,
// we use this heuristic
if (simulate && extracted.getCount() == extracted.getMaxStackSize()
&& remainingCurrentSlot > extracted.getMaxStackSize()) {
extracted.setCount(remainingCurrentSlot);
}
// We're just gonna use the first stack we get our hands on as the template for
// the rest.
// In case some stupid itemhandler (aka forge) returns an internal state we have
// to do a second
// expensive copy again.
if (gathered.isEmpty()) {
gathered = extracted.copy();
gathered = extracted;
} else {
gathered.grow(extracted.getCount());
}
remainingCurrentSlot -= extracted.getCount();
}
} while (!extracted.isEmpty() && remainingCurrentSlot > 0);
} while (!simulate && !extracted.isEmpty() && remainingCurrentSlot > 0);
remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot;
+5 -2
View File
@@ -1064,8 +1064,11 @@ public class Platform {
if (items != null && checkFuzzy) {
for (final IAEItemStack x : items) {
final ItemStack sh = x.getDefinition();
if ((Platform.itemComparisons().isEqualItemType(providedTemplate, sh))
&& !ItemStack.areItemsEqual(sh, output)) {
if ((Platform.itemComparisons().isEqualItemType(providedTemplate,
sh) /* FIXME || ae_req.sameOre( x ) */ ) && !ItemStack.areItemsEqual(sh, output)) { // Platform.isSameItemType(
// sh,
// providedTemplate
// )
final ItemStack cp = sh.copy();
cp.setCount(1);
ci.setInventorySlotContents(slot, cp);
@@ -90,6 +90,14 @@ public class ItemComparisonHelper {
return (percentDamagedOfA > mode.breakPoint) == (percentDamagedOfB > mode.breakPoint);
}
}
// FIXME
// final OreReference aOR = OreHelper.INSTANCE.getOre( a ).orElse( null );
// final OreReference bOR = OreHelper.INSTANCE.getOre( b ).orElse( null );
//
// if( OreHelper.INSTANCE.sameOre( aOR, bOR ) )
// {
// return true;
// }
return a.isItemEqual(b);
}