Fixes sidedness issues that cropped up with 1.16 (#4533)
This commit is contained in:
@@ -45,14 +45,6 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
|
||||
|
||||
public AEBaseBlockItemChargeable(Block id, Properties props) {
|
||||
super(id, props);
|
||||
|
||||
ItemModelsProperties.func_239418_a_(this, new ResourceLocation("appliedenergistics2:fill_level"),
|
||||
(is, world, entity) -> {
|
||||
double curPower = getAECurrentPower(is);
|
||||
double maxPower = getAEMaxPower(is);
|
||||
|
||||
return (int) Math.round(100 * curPower / maxPower);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -38,8 +40,10 @@ import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseBlockItem;
|
||||
import appeng.block.AEBaseBlockItemChargeable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||
import appeng.core.AEItemGroup;
|
||||
@@ -149,6 +153,24 @@ class BlockDefinitionBuilder implements IBlockBuilder {
|
||||
item.setRegistryName(AppEng.MOD_ID, this.registryName);
|
||||
}
|
||||
|
||||
// Register the client-only item model property for chargeable items
|
||||
if (item instanceof AEBaseBlockItemChargeable) {
|
||||
AEBaseBlockItemChargeable chargeable = (AEBaseBlockItemChargeable) item;
|
||||
this.factory.addBootstrapComponent(new IClientSetupComponent() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void setup() {
|
||||
ItemModelsProperties.func_239418_a_(item, new ResourceLocation("appliedenergistics2:fill_level"),
|
||||
(is, world, entity) -> {
|
||||
double curPower = chargeable.getAECurrentPower(is);
|
||||
double maxPower = chargeable.getAEMaxPower(is);
|
||||
|
||||
return (int) Math.round(100 * curPower / maxPower);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Register the item and block with the game
|
||||
this.factory.addBootstrapComponent((IBlockRegistrationComponent) (side, registry) -> registry.register(block));
|
||||
if (item != null) {
|
||||
|
||||
@@ -30,10 +30,14 @@ import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.dispenser.IDispenseItemBehavior;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseBlockItemChargeable;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||
import appeng.core.AEItemGroup;
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class AppEng {
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, AEConfig.COMMON_SPEC);
|
||||
|
||||
proxy = DistExecutor.safeRunForDist(() -> ClientHelper::new, () -> ServerHelper::new);
|
||||
proxy = DistExecutor.unsafeRunForDist(() -> ClientHelper::new, () -> ServerHelper::new);
|
||||
|
||||
CreativeTab.init();
|
||||
new FacadeItemGroup(); // This call has a side-effect (adding it to the creative screen)
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
|
||||
package appeng.core.api.definitions;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
@@ -35,6 +38,8 @@ import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.ColoredItemDefinition;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
@@ -210,7 +215,22 @@ public final class ApiItems implements IItems {
|
||||
.addFeatures(AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS).build();
|
||||
this.colorApplicator = powerTools.item("color_applicator", ColorApplicatorItem::new).props(chargedDefaults)
|
||||
.addFeatures(AEFeature.COLOR_APPLICATOR).dispenserBehavior(BlockToolDispenseItemBehavior::new)
|
||||
.rendering(new ColorApplicatorItemRendering()).build();
|
||||
.bootstrap(item -> new IClientSetupComponent() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void setup() {
|
||||
ColorApplicatorItem colorApplicatorItem = (ColorApplicatorItem) item;
|
||||
ItemModelsProperties.func_239418_a_(item, new ResourceLocation(AppEng.MOD_ID, "colored"),
|
||||
(itemStack, world, entity) -> {
|
||||
// If the stack has no color, don't use the colored model since the impact of
|
||||
// calling getColor for every quad is extremely high, if the stack tries to
|
||||
// re-search its
|
||||
// inventory for a new paintball everytime
|
||||
AEColor col = colorApplicatorItem.getActiveColor(itemStack);
|
||||
return (col != null) ? 1 : 0;
|
||||
});
|
||||
}
|
||||
}).rendering(new ColorApplicatorItemRendering()).build();
|
||||
|
||||
this.biometricCard = registry.item("biometric_card", BiometricCardItem::new)
|
||||
.props(props -> props.maxStackSize(1)).features(AEFeature.SECURITY).build();
|
||||
@@ -278,7 +298,16 @@ public final class ApiItems implements IItems {
|
||||
this.certusCrystalSeed = registry
|
||||
.item("certus_crystal_seed",
|
||||
props -> new CrystalSeedItem(props, materials.purifiedCertusQuartzCrystal().item()))
|
||||
.features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
.bootstrap(item -> new IClientSetupComponent() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void setup() {
|
||||
// Expose the growth of the seed to the model system
|
||||
ItemModelsProperties.func_239418_a_(item, new ResourceLocation("appliedenergistics2:growth"),
|
||||
(is, w, p) -> CrystalSeedItem.getGrowthTicks(is)
|
||||
/ (float) CrystalSeedItem.GROWTH_TICKS_REQUIRED);
|
||||
}
|
||||
}).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||
this.fluixCrystalSeed = registry
|
||||
.item("fluix_crystal_seed",
|
||||
props -> new CrystalSeedItem(props, materials.purifiedFluixCrystal().item()))
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
|
||||
/**
|
||||
* The number of growth ticks required to finish growing.
|
||||
*/
|
||||
private static final int GROWTH_TICKS_REQUIRED = 600;
|
||||
public static final int GROWTH_TICKS_REQUIRED = 600;
|
||||
|
||||
/**
|
||||
* The item to convert to, when growth finishes.
|
||||
@@ -71,9 +71,6 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
|
||||
public CrystalSeedItem(Properties properties, IItemProvider grownItem) {
|
||||
super(properties);
|
||||
this.grownItem = Preconditions.checkNotNull(grownItem);
|
||||
// Expose the growth of the seed to the model system
|
||||
ItemModelsProperties.func_239418_a_(this, new ResourceLocation("appliedenergistics2:growth"),
|
||||
(is, w, p) -> getGrowthTicks(is) / (float) GROWTH_TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -88,7 +85,7 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
|
||||
}
|
||||
}
|
||||
|
||||
private static int getGrowthTicks(final ItemStack is) {
|
||||
public static int getGrowthTicks(final ItemStack is) {
|
||||
CompoundNBT tag = is.getTag();
|
||||
return tag != null ? tag.getInt(TAG_GROWTH_TICKS) : 0;
|
||||
}
|
||||
|
||||
@@ -107,15 +107,6 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
|
||||
public ColorApplicatorItem(Item.Properties props) {
|
||||
super(AEConfig.instance().getColorApplicatorBattery(), props);
|
||||
ItemModelsProperties.func_239418_a_(this, new ResourceLocation(AppEng.MOD_ID, "colored"),
|
||||
(itemStack, world, entity) -> {
|
||||
// If the stack has no color, don't use the colored model since the impact of
|
||||
// calling getColor for every quad is extremely high, if the stack tries to
|
||||
// re-search its
|
||||
// inventory for a new paintball everytime
|
||||
AEColor col = getActiveColor(itemStack);
|
||||
return (col != null) ? 1 : 0;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
import appeng.spatial.SpatialDimensionManager;
|
||||
import appeng.spatial.StorageSkyProperties;
|
||||
|
||||
@Mixin(DimensionRenderInfo.class)
|
||||
public class SkyPropertiesMixin {
|
||||
@@ -20,7 +21,7 @@ public class SkyPropertiesMixin {
|
||||
private static void byDimensionType(Optional<RegistryKey<DimensionType>> optional,
|
||||
CallbackInfoReturnable<DimensionRenderInfo> ci) {
|
||||
if (optional.orElse(null) == SpatialDimensionManager.STORAGE_DIMENSION_TYPE) {
|
||||
ci.setReturnValue(SpatialDimensionManager.STORAGE_SKY);
|
||||
ci.setReturnValue(StorageSkyProperties.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,10 @@ import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.world.DimensionRenderInfo;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.DimensionType;
|
||||
@@ -52,27 +50,6 @@ public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
public static final RegistryKey<DimensionType> STORAGE_DIMENSION_TYPE = RegistryKey
|
||||
.func_240903_a_(Registry.DIMENSION_TYPE_KEY, AppEng.makeId("storage_cell"));
|
||||
|
||||
// See the fabric version of this to get any idea what its doing
|
||||
public static final DimensionRenderInfo STORAGE_SKY = new DimensionRenderInfo(Float.NaN /* disables clouds */,
|
||||
false, DimensionRenderInfo.FogType.NONE /* we use a custom render mixin */, true, false) {
|
||||
|
||||
@Override
|
||||
public Vector3d func_230494_a_(Vector3d p_230494_1_, float p_230494_2_) {
|
||||
return Vector3d.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230493_a_(int p_230493_1_, int p_230493_2_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public float[] func_230492_a_(float p_230492_1_, float p_230492_2_) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
public static final ISpatialDimension INSTANCE = new SpatialDimensionManager();
|
||||
|
||||
private static final String DIM_ID_PREFIX = "spatial_";
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package appeng.spatial;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.world.DimensionRenderInfo;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class StorageSkyProperties {
|
||||
|
||||
// See the fabric version of this to get any idea what its doing
|
||||
public static final DimensionRenderInfo INSTANCE = new DimensionRenderInfo(Float.NaN /* disables clouds */, false,
|
||||
DimensionRenderInfo.FogType.NONE /* we use a custom render mixin */, true, false) {
|
||||
|
||||
@Override
|
||||
public Vector3d func_230494_a_(Vector3d p_230494_1_, float p_230494_2_) {
|
||||
return Vector3d.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230493_a_(int p_230493_1_, int p_230493_2_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public float[] func_230492_a_(float p_230492_1_, float p_230492_2_) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user