Fix client-side init code (checked for thread groups instead of dist).
More sky compass fixes.
This commit is contained in:
@@ -83,7 +83,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
|||||||
this.registryName = id;
|
this.registryName = id;
|
||||||
this.blockSupplier = blockSupplier;
|
this.blockSupplier = blockSupplier;
|
||||||
|
|
||||||
if( Platform.isClient() )
|
if( Platform.hasClientClasses() )
|
||||||
{
|
{
|
||||||
this.blockRendering = new BlockRendering();
|
this.blockRendering = new BlockRendering();
|
||||||
this.itemRendering = new ItemRendering();
|
this.itemRendering = new ItemRendering();
|
||||||
@@ -115,7 +115,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
|||||||
@Override
|
@Override
|
||||||
public BlockDefinitionBuilder rendering( BlockRenderingCustomizer callback )
|
public BlockDefinitionBuilder rendering( BlockRenderingCustomizer callback )
|
||||||
{
|
{
|
||||||
if( Platform.isClient() )
|
if( Platform.hasClientClasses() )
|
||||||
{
|
{
|
||||||
this.customizeForClient( callback );
|
this.customizeForClient( callback );
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
|||||||
this.tileEntityDefinition.addBlock(block);
|
this.tileEntityDefinition.addBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Platform.isClient() )
|
if( Platform.hasClientClasses() )
|
||||||
{
|
{
|
||||||
this.blockRendering.apply( this.factory, block );
|
this.blockRendering.apply( this.factory, block );
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class FeatureFactory
|
|||||||
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
|
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
|
||||||
this.bootstrapComponents = new HashMap<>();
|
this.bootstrapComponents = new HashMap<>();
|
||||||
|
|
||||||
if( Platform.isClient() )
|
if( Platform.hasClientClasses() )
|
||||||
{
|
{
|
||||||
this.modelOverrideComponent = new ModelOverrideComponent();
|
this.modelOverrideComponent = new ModelOverrideComponent();
|
||||||
this.addBootstrapComponent( this.modelOverrideComponent );
|
this.addBootstrapComponent( this.modelOverrideComponent );
|
||||||
@@ -83,7 +83,7 @@ public class FeatureFactory
|
|||||||
{
|
{
|
||||||
this.defaultFeatures = defaultFeatures.clone();
|
this.defaultFeatures = defaultFeatures.clone();
|
||||||
this.bootstrapComponents = parent.bootstrapComponents;
|
this.bootstrapComponents = parent.bootstrapComponents;
|
||||||
if( Platform.isClient() )
|
if( Platform.hasClientClasses() )
|
||||||
{
|
{
|
||||||
this.modelOverrideComponent = parent.modelOverrideComponent;
|
this.modelOverrideComponent = parent.modelOverrideComponent;
|
||||||
this.builtInModelComponent = parent.builtInModelComponent;
|
this.builtInModelComponent = parent.builtInModelComponent;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
|||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.registryName = registryName;
|
this.registryName = registryName;
|
||||||
this.itemSupplier = itemSupplier;
|
this.itemSupplier = itemSupplier;
|
||||||
if( Platform.isClient() )
|
if( Platform.hasClientClasses() )
|
||||||
{
|
{
|
||||||
// FIXME this.itemRendering = new ItemRendering();
|
// FIXME this.itemRendering = new ItemRendering();
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
|||||||
// FIXME @Override
|
// FIXME @Override
|
||||||
// FIXME public IItemBuilder rendering( ItemRenderingCustomizer callback )
|
// FIXME public IItemBuilder rendering( ItemRenderingCustomizer callback )
|
||||||
// FIXME {
|
// FIXME {
|
||||||
// FIXME if( Platform.isClient() )
|
// FIXME if( Platform.hasClientClasses() )
|
||||||
// FIXME {
|
// FIXME {
|
||||||
// FIXME this.customizeForClient( callback );
|
// FIXME this.customizeForClient( callback );
|
||||||
// FIXME }
|
// FIXME }
|
||||||
@@ -148,7 +148,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
|||||||
|
|
||||||
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, reg ) -> reg.register( item ) );
|
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, reg ) -> reg.register( item ) );
|
||||||
|
|
||||||
if( Platform.isClient() )
|
if( Platform.hasClientClasses() )
|
||||||
{
|
{
|
||||||
// FIXME this.itemRendering.apply( this.factory, item );
|
// FIXME this.itemRendering.apply( this.factory, item );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ public class SkyCompassModel implements IModelGeometry<SkyCompassModel>
|
|||||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||||
IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||||
IBakedModel pointerModel = bakery.getBakedModel(MODEL_POINTER, modelTransform, spriteGetter);
|
IBakedModel pointerModel = bakery.getBakedModel(MODEL_POINTER, modelTransform, spriteGetter);
|
||||||
|
return new SkyCompassBakedModel(baseModel, pointerModel);
|
||||||
return new SkyCompassBakedModel( baseModel, pointerModel );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package appeng.client.render.tesr;
|
package appeng.client.render.tesr;
|
||||||
|
|
||||||
|
|
||||||
|
import appeng.client.render.FacingToRotation;
|
||||||
import appeng.client.render.model.SkyCompassModel;
|
import appeng.client.render.model.SkyCompassModel;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
@@ -69,27 +70,26 @@ public class SkyCompassTESR extends TileEntityRenderer<TileSkyCompass>
|
|||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModel( blockState );
|
IBakedModel model = blockRenderer.getBlockModelShapes().getModel( blockState );
|
||||||
|
|
||||||
|
// FIXME: Rotation was previously handled by an auto rotating model I think, but
|
||||||
|
// FIXME: Should be handled using matrices instead
|
||||||
|
Direction forward = te.getForward();
|
||||||
|
Direction up = te.getUp();
|
||||||
|
// This ensures the needle isn't flipped by the model rotator. Since the model is symmetrical, this should
|
||||||
|
// not affect the appearance
|
||||||
|
if( forward == Direction.UP || forward == Direction.DOWN )
|
||||||
|
{
|
||||||
|
up = Direction.NORTH;
|
||||||
|
}
|
||||||
|
// Flip forward/up for rendering, the base model is facing up without any rotation
|
||||||
|
ms.push();
|
||||||
|
ms.translate(0.5D, 0.5D, 0.5D);
|
||||||
|
FacingToRotation.get(up, forward).push(ms);
|
||||||
|
ms.translate(-0.5D, -0.5D, -0.5D);
|
||||||
|
|
||||||
ModelDataMap modelData = new ModelDataMap.Builder()
|
ModelDataMap modelData = new ModelDataMap.Builder()
|
||||||
.withInitial(SkyCompassBakedModel.ROTATION, getRotation(te))
|
.withInitial(SkyCompassBakedModel.ROTATION, getRotation(te))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ms.push();
|
|
||||||
// FIXME: Rotation was previously handled by an auto rotating model I think, but
|
|
||||||
// FIXME: Should be handled using matrices instead
|
|
||||||
// // Flip forward/up for rendering, the base model is facing up without any rotation
|
|
||||||
// Direction forward = exState.getValue( AEBaseTileBlock.FORWARD );
|
|
||||||
// Direction up = exState.getValue( AEBaseTileBlock.UP );
|
|
||||||
// // This ensures the needle isn't flipped by the model rotator. Since the model is symmetrical, this should
|
|
||||||
// // not affect the appearance
|
|
||||||
// if( forward == Direction.UP || forward == Direction.DOWN )
|
|
||||||
// {
|
|
||||||
// up = Direction.NORTH;
|
|
||||||
// }
|
|
||||||
// exState = exState.with( AEBaseTileBlock.FORWARD, up )
|
|
||||||
// .with( AEBaseTileBlock.UP, forward );
|
|
||||||
//
|
|
||||||
// buffer.setTranslation( x - pos.getX(), y - pos.getY(), z - pos.getZ() );
|
|
||||||
|
|
||||||
blockRenderer.getBlockModelRenderer().renderModel( ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn, combinedOverlayIn, modelData );
|
blockRenderer.getBlockModelRenderer().renderModel( ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn, combinedOverlayIn, modelData );
|
||||||
ms.pop();
|
ms.pop();
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,17 @@
|
|||||||
package appeng.tile;
|
package appeng.tile;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import appeng.api.util.ICommonTile;
|
||||||
import java.lang.ref.WeakReference;
|
import appeng.api.util.IConfigManager;
|
||||||
import java.util.HashMap;
|
import appeng.api.util.IConfigurableObject;
|
||||||
import java.util.List;
|
import appeng.api.util.IOrientable;
|
||||||
import java.util.Map;
|
import appeng.block.AEBaseTileBlock;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
|
import appeng.core.features.IStackSrc;
|
||||||
|
import appeng.helpers.ICustomNameObject;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
import appeng.util.SettingsFrom;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
@@ -44,15 +41,16 @@ import net.minecraft.tileentity.TileEntityType;
|
|||||||
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.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.model.data.IModelData;
|
||||||
|
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||||
|
|
||||||
import appeng.api.util.ICommonTile;
|
import javax.annotation.Nonnull;
|
||||||
import appeng.api.util.IConfigManager;
|
import javax.annotation.Nullable;
|
||||||
import appeng.api.util.IConfigurableObject;
|
import java.io.IOException;
|
||||||
import appeng.api.util.IOrientable;
|
import java.lang.ref.WeakReference;
|
||||||
import appeng.core.features.IStackSrc;
|
import java.util.HashMap;
|
||||||
import appeng.helpers.ICustomNameObject;
|
import java.util.List;
|
||||||
import appeng.util.Platform;
|
import java.util.Map;
|
||||||
import appeng.util.SettingsFrom;
|
|
||||||
|
|
||||||
|
|
||||||
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject
|
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject
|
||||||
@@ -504,4 +502,14 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||||||
{
|
{
|
||||||
this.customName = name;
|
this.customName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public IModelData getModelData() {
|
||||||
|
return new ModelDataMap.Builder()
|
||||||
|
.withInitial(AEBaseTileBlock.UP, up)
|
||||||
|
.withInitial(AEBaseTileBlock.FORWARD, forward)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import appeng.api.config.AccessRestriction;
|
|||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.PowerMultiplier;
|
import appeng.api.config.PowerMultiplier;
|
||||||
import appeng.api.definitions.IItemDefinition;
|
import appeng.api.definitions.IItemDefinition;
|
||||||
|
import appeng.api.features.AEFeature;
|
||||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||||
import appeng.api.implementations.items.IAEWrench;
|
import appeng.api.implementations.items.IAEWrench;
|
||||||
import appeng.api.networking.energy.IEnergySource;
|
import appeng.api.networking.energy.IEnergySource;
|
||||||
@@ -34,12 +35,11 @@ import appeng.api.storage.data.IAEStack;
|
|||||||
import appeng.api.util.AEPartLocation;
|
import appeng.api.util.AEPartLocation;
|
||||||
import appeng.api.util.DimensionalCoord;
|
import appeng.api.util.DimensionalCoord;
|
||||||
import appeng.core.Api;
|
import appeng.core.Api;
|
||||||
import appeng.api.features.AEFeature;
|
|
||||||
import appeng.core.stats.AeStats;
|
import appeng.core.stats.AeStats;
|
||||||
import appeng.fluids.util.AEFluidStack;
|
import appeng.fluids.util.AEFluidStack;
|
||||||
import appeng.util.helpers.ItemComparisonHelper;
|
import appeng.util.helpers.ItemComparisonHelper;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
@@ -64,12 +64,10 @@ import net.minecraftforge.common.util.FakePlayerFactory;
|
|||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
|
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
|
||||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author AlgorithmX2
|
* @author AlgorithmX2
|
||||||
@@ -340,6 +338,13 @@ public class Platform
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True if client-side classes (such as Renderers) are available.
|
||||||
|
*/
|
||||||
|
public static boolean hasClientClasses() {
|
||||||
|
return FMLEnvironment.dist.isClient();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns true if the code is on the client.
|
* returns true if the code is on the client.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user