mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 15:22:57 +00:00
Fix some sided issues for running on server
This commit is contained in:
1 parent
ddbc5e96f1
commit
007c036f54
21 files changed
+56
-14
No files matched your search
@@ -8,10 +8,15 @@ package forestry.api.apiculture;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
public interface IBeeModelProvider {
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerModels(Item item, IModelManager manager);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ModelResourceLocation getModel(EnumBeeType type);
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
/**
|
||||
* Provides icons, needed in some interfaces, most notably for bees and trees.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ISpriteProvider {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IStateMapperRegister {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerStateMapper();
|
||||
|
||||
}
|
||||
@@ -225,6 +225,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new AlvearyStateMapper(getAlvearyType()));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import forestry.api.apiculture.IBeeModelProvider;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.apiculture.items.ItemBeeGE;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class DefaultBeeModelProvider implements IBeeModelProvider {
|
||||
|
||||
public static final DefaultBeeModelProvider instance = new DefaultBeeModelProvider();
|
||||
@@ -33,19 +32,26 @@ public class DefaultBeeModelProvider implements IBeeModelProvider {
|
||||
|
||||
}
|
||||
|
||||
private static final ModelResourceLocation[] models = new ModelResourceLocation[EnumBeeType.values().length];
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static ModelResourceLocation[] models;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModels(Item item, IModelManager manager) {
|
||||
String beeIconDir = "bees/default/";
|
||||
EnumBeeType beeType = ((ItemBeeGE) item).getType();
|
||||
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
if (models == null) {
|
||||
models = new ModelResourceLocation[EnumBeeType.values().length];
|
||||
}
|
||||
|
||||
models[beeType.ordinal()] = manager.getModelLocation(beeTypeNameBase);
|
||||
manager.registerVariant(item, new ResourceLocation("forestry:" + beeTypeNameBase));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation getModel(EnumBeeType type) {
|
||||
return models[type.ordinal()];
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, IItemModelR
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, null));
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, getVariant()));
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, getVariant()));
|
||||
}
|
||||
|
||||
@@ -232,6 +232,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
String blockPath = isDouble() ? "slab/double" : "slab";
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, blockPath, getVariant()));
|
||||
|
||||
@@ -78,6 +78,7 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, IItemMode
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, null));
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new SaplingStateMapper());
|
||||
}
|
||||
|
||||
@@ -271,6 +271,7 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
|
||||
|
||||
/* STATES */
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new MachineStateMapper<>(machinePropertiesClass, TYPE, FACE));
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -245,7 +246,7 @@ public enum Fluids {
|
||||
private final int density, viscosity;
|
||||
@Nonnull
|
||||
private final Color color;
|
||||
|
||||
|
||||
private final ResourceLocation[] resources = new ResourceLocation[2];
|
||||
|
||||
Fluids(@Nonnull Color color) {
|
||||
@@ -257,7 +258,7 @@ public enum Fluids {
|
||||
this.color = color;
|
||||
this.density = density;
|
||||
this.viscosity = viscosity;
|
||||
|
||||
|
||||
resources[0] = new ForestryResource("blocks/liquid/" + getTag() + "_still");
|
||||
if (flowTextureExists()) {
|
||||
resources[1] = new ForestryResource("blocks/liquid/" + getTag() + "_flow");
|
||||
@@ -375,8 +376,10 @@ public enum Fluids {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean flowTextureExists() {
|
||||
if (FMLCommonHandler.instance().getSide() == Side.SERVER) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
ResourceLocation resourceLocation = new ForestryResource("blocks/liquid/" + getTag() + "_flow");
|
||||
IResourceManager resourceManager = Proxies.common.getClientInstance().getResourceManager();
|
||||
|
||||
@@ -106,11 +106,12 @@ public class ItemPipette extends ItemForestry implements IToolPipette {
|
||||
|
||||
/* Models */
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation[] models = new ModelResourceLocation[2];
|
||||
public ModelResourceLocation[] models;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
models = new ModelResourceLocation[2];
|
||||
models[0] = manager.getModelLocation("pipette.0");
|
||||
models[1] = manager.getModelLocation("pipette.1");
|
||||
manager.registerVariant(item, new ResourceLocation("forestry:pipette.0"));
|
||||
|
||||
@@ -105,7 +105,8 @@ public class ModelManager implements IModelManager {
|
||||
public ModelResourceLocation getModelLocation(String modID, String identifier) {
|
||||
return new ModelResourceLocation(modID + ":" + identifier, "inventory");
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerModels() {
|
||||
for (Block block : GameData.getBlockRegistry()) {
|
||||
if (block instanceof IItemModelRegister) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.animation.ITimeValue;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.models.ModelIndex;
|
||||
import forestry.core.tiles.TileBase;
|
||||
@@ -78,6 +79,9 @@ public class ProxyRender {
|
||||
public void registerModel(ModelIndex index) {
|
||||
}
|
||||
|
||||
public void registerModelCrate(ItemCrated crated) {
|
||||
}
|
||||
|
||||
public void registerStateMapper(Block block, IStateMapper mapper) {
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ import forestry.core.entities.EntityFXHoneydust;
|
||||
import forestry.core.entities.EntityFXIgnition;
|
||||
import forestry.core.entities.EntityFXSnow;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.models.ModelCrate;
|
||||
import forestry.core.models.ModelIndex;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.render.RenderAnalyzer;
|
||||
@@ -62,6 +64,7 @@ import forestry.core.tiles.TileBase;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
import forestry.core.tiles.TileMill;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class ProxyRenderClient extends ProxyRender {
|
||||
|
||||
@@ -135,6 +138,12 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
ModelManager.registerCustomModel(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModelCrate(ItemCrated crate) {
|
||||
ModelResourceLocation modelLocation = new ModelResourceLocation("forestry:crate-filled", StringUtil.cleanItemName(crate));
|
||||
registerModel(new ModelIndex(modelLocation, new ModelCrate()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerFluidStateMapper(Block block, final Fluids forestryFluid) {
|
||||
final ModelResourceLocation fluidLocation = new ModelResourceLocation("forestry:blockforestryfluid",
|
||||
|
||||
@@ -63,7 +63,7 @@ public class TextureManager implements ITextureManager {
|
||||
defaultIcons.put(str, icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static TextureAtlasSprite registerSprite(String identifier) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
return map.registerSprite(new ResourceLocation("forestry:" + identifier));
|
||||
|
||||
@@ -54,7 +54,7 @@ public enum BlockGreenhouseType {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static EnumMap<BlockGreenhouseSprites, TextureAtlasSprite> sprites = new EnumMap(BlockGreenhouseSprites.class);
|
||||
private static EnumMap<BlockGreenhouseSprites, TextureAtlasSprite> sprites;
|
||||
|
||||
private static enum BlockGreenhouseSprites{
|
||||
PLAIN, GLASS, GEARS("gears"), VALVE("valve"), FAN_OFF("fan.off"), FAN_ON("fan.on"), HEATER_OFF("heater.off"), HEATER_ON("heater.on"), DRYER("dryer"), CONTROL("control"), HATCH_DEFAULT("hatch"), HATCH_INPUT("hatch_input"), HATCH_OUTPUT("hatch_output");
|
||||
@@ -74,6 +74,7 @@ public enum BlockGreenhouseType {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerSprites() {
|
||||
sprites = new EnumMap<>(BlockGreenhouseSprites.class);
|
||||
for(BlockGreenhouseSprites sprite : BlockGreenhouseSprites.VALUES){
|
||||
if(sprite == BlockGreenhouseSprites.PLAIN){
|
||||
sprites.put(sprite, TextureManager.getSprite("minecraft", "blocks/brick"));
|
||||
|
||||
@@ -25,6 +25,8 @@ import net.minecraft.world.World;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ISpriteProvider;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -200,6 +202,7 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites() {
|
||||
String spriteName = getItemTexture();
|
||||
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
@@ -207,6 +210,7 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(short texUID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package forestry.storage;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -19,8 +18,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.models.ModelCrate;
|
||||
import forestry.core.models.ModelIndex;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.StringUtil;
|
||||
@@ -41,7 +38,7 @@ public class CrateRegistry implements ICrateRegistry {
|
||||
ItemCrated crate = new ItemCrated(stack, useOreDict);
|
||||
crate.setUnlocalizedName(uid);
|
||||
GameRegistry.registerItem(crate, StringUtil.cleanItemName(crate));
|
||||
Proxies.render.registerModel(new ModelIndex(new ModelResourceLocation("forestry:crate-filled", StringUtil.cleanItemName(crate)), new ModelCrate()));
|
||||
Proxies.render.registerModelCrate(crate);
|
||||
PluginStorage.registerCrate(crate);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user