Fix client-side init code (checked for thread groups instead of dist).

More sky compass fixes.
This commit is contained in:
Sebastian Hartte
2020-06-03 18:49:22 +02:00
parent 64651feb3c
commit 6eb2a9504a
7 changed files with 64 additions and 52 deletions
@@ -83,7 +83,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
this.registryName = id;
this.blockSupplier = blockSupplier;
if( Platform.isClient() )
if( Platform.hasClientClasses() )
{
this.blockRendering = new BlockRendering();
this.itemRendering = new ItemRendering();
@@ -115,7 +115,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
@Override
public BlockDefinitionBuilder rendering( BlockRenderingCustomizer callback )
{
if( Platform.isClient() )
if( Platform.hasClientClasses() )
{
this.customizeForClient( callback );
}
@@ -180,7 +180,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
this.tileEntityDefinition.addBlock(block);
}
if( Platform.isClient() )
if( Platform.hasClientClasses() )
{
this.blockRendering.apply( this.factory, block );
@@ -70,7 +70,7 @@ public class FeatureFactory
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
this.bootstrapComponents = new HashMap<>();
if( Platform.isClient() )
if( Platform.hasClientClasses() )
{
this.modelOverrideComponent = new ModelOverrideComponent();
this.addBootstrapComponent( this.modelOverrideComponent );
@@ -83,7 +83,7 @@ public class FeatureFactory
{
this.defaultFeatures = defaultFeatures.clone();
this.bootstrapComponents = parent.bootstrapComponents;
if( Platform.isClient() )
if( Platform.hasClientClasses() )
{
this.modelOverrideComponent = parent.modelOverrideComponent;
this.builtInModelComponent = parent.builtInModelComponent;
@@ -66,7 +66,7 @@ class ItemDefinitionBuilder implements IItemBuilder
this.factory = factory;
this.registryName = registryName;
this.itemSupplier = itemSupplier;
if( Platform.isClient() )
if( Platform.hasClientClasses() )
{
// FIXME this.itemRendering = new ItemRendering();
}
@@ -104,7 +104,7 @@ class ItemDefinitionBuilder implements IItemBuilder
// FIXME @Override
// FIXME public IItemBuilder rendering( ItemRenderingCustomizer callback )
// FIXME {
// FIXME if( Platform.isClient() )
// FIXME if( Platform.hasClientClasses() )
// FIXME {
// FIXME this.customizeForClient( callback );
// FIXME }
@@ -148,7 +148,7 @@ class ItemDefinitionBuilder implements IItemBuilder
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, reg ) -> reg.register( item ) );
if( Platform.isClient() )
if( Platform.hasClientClasses() )
{
// 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) {
IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
IBakedModel pointerModel = bakery.getBakedModel(MODEL_POINTER, modelTransform, spriteGetter);
return new SkyCompassBakedModel( baseModel, pointerModel );
return new SkyCompassBakedModel(baseModel, pointerModel);
}
@Override
@@ -19,6 +19,7 @@
package appeng.client.render.tesr;
import appeng.client.render.FacingToRotation;
import appeng.client.render.model.SkyCompassModel;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
@@ -69,27 +70,26 @@ public class SkyCompassTESR extends TileEntityRenderer<TileSkyCompass>
BlockState blockState = te.getBlockState();
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()
.withInitial(SkyCompassBakedModel.ROTATION, getRotation(te))
.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 );
ms.pop();
+28 -20
View File
@@ -19,20 +19,17 @@
package appeng.tile;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.api.util.ICommonTile;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseTileBlock;
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 net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -44,15 +41,16 @@ import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
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 appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.api.util.IOrientable;
import appeng.core.features.IStackSrc;
import appeng.helpers.ICustomNameObject;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject
@@ -504,4 +502,14 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
{
this.customName = name;
}
@Nonnull
@Override
public IModelData getModelData() {
return new ModelDataMap.Builder()
.withInitial(AEBaseTileBlock.UP, up)
.withInitial(AEBaseTileBlock.FORWARD, forward)
.build();
}
}
+10 -5
View File
@@ -23,6 +23,7 @@ import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.definitions.IItemDefinition;
import appeng.api.features.AEFeature;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.implementations.items.IAEWrench;
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.DimensionalCoord;
import appeng.core.Api;
import appeng.api.features.AEFeature;
import appeng.core.stats.AeStats;
import appeng.fluids.util.AEFluidStack;
import appeng.util.helpers.ItemComparisonHelper;
import appeng.util.item.AEItemStack;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -64,12 +64,10 @@ import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.*;
import com.google.common.base.Preconditions;
import net.minecraftforge.registries.ForgeRegistries;
/**
* @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.
*/