Skip to content

Commit

Permalink
Whoops, fix trigger sprite registration crashing dedicated servers
Browse files Browse the repository at this point in the history
  • Loading branch information
multiplemonomials committed Jan 5, 2018
1 parent 7422b8d commit 4ba3f7f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 34 deletions.
7 changes: 2 additions & 5 deletions src/main/java/buildcraft/additionalpipes/AdditionalPipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import buildcraft.additionalpipes.sound.APSounds;
import buildcraft.additionalpipes.test.TeleportManagerTest;
import buildcraft.additionalpipes.utils.Log;
import buildcraft.api.BCModules;
import buildcraft.api.statements.ITriggerInternal;
import buildcraft.api.statements.StatementManager;
import buildcraft.lib.registry.CreativeTabManager;
Expand Down Expand Up @@ -80,10 +79,7 @@ public class AdditionalPipes {

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{

System.err.println("buildcraft transport is loaded: " + BCModules.TRANSPORT.isLoaded());

{
PacketHandler.init();

configFile = event.getSuggestedConfigurationFile();
Expand All @@ -98,6 +94,7 @@ public void preInit(FMLPreInitializationEvent event)
APPipeDefintions.setFluidCapacities();

Log.info("Registering gates");
proxy.registerSprites();
triggerPipeClosed = new TriggerPipeClosed();
StatementManager.registerTriggerProvider(new GateProvider());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ public void registerRendering()
// do nothing
}

public void registerSprites()
{
// do nothing
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package buildcraft.additionalpipes;

import buildcraft.additionalpipes.item.ItemDogDeaggravator;
import buildcraft.additionalpipes.textures.Textures;
import buildcraft.lib.client.sprite.SpriteHolderRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
Expand Down Expand Up @@ -40,4 +42,10 @@ public void registerRendering()


}

@Override
public void registerSprites()
{
Textures.TRIGGER_PIPE_CLOSED = SpriteHolderRegistry.getHolder("additionalpipes:items/triggers/pipe_closed");
}
}
27 changes: 1 addition & 26 deletions src/main/java/buildcraft/additionalpipes/gates/APTrigger.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
package buildcraft.additionalpipes.gates;

import buildcraft.additionalpipes.AdditionalPipes;
import buildcraft.api.core.render.ISprite;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.StatementManager;
import buildcraft.lib.client.sprite.SpriteHolderRegistry;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SuppressWarnings("deprecation")
public abstract class APTrigger implements IStatement {

protected String id; //used as unique key in BC registry
protected String descriptionKey; //used for description translations
protected ResourceLocation texture;

private final String textureID;

@SideOnly(Side.CLIENT)
private ISprite sprite = null;

/**
*
* @param id the name of the trigger, without the "additionalpipes:" prefix. Also the name of the texture.
Expand All @@ -32,15 +22,7 @@ public APTrigger(String idWithoutPrefix)
descriptionKey = "trigger." + idWithoutPrefix;

this.id = AdditionalPipes.MODID + ":" + descriptionKey;
StatementManager.statements.put(this.id, this);
textureID = idWithoutPrefix;

if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
{
sprite = SpriteHolderRegistry.getHolder("additionalpipes:items/triggers/" + textureID);
}

}
StatementManager.statements.put(this.id, this); }

@Override
public String getUniqueTag()
Expand All @@ -54,12 +36,5 @@ public String getDescription()
return I18n.translateToLocal(descriptionKey);
}

@Override
@SideOnly(Side.CLIENT)
public ISprite getSprite()
{
return sprite;
}


}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package buildcraft.additionalpipes.gates;

import buildcraft.additionalpipes.pipes.PipeBehaviorClosed;
import buildcraft.additionalpipes.textures.Textures;
import buildcraft.additionalpipes.utils.Log;
import buildcraft.api.core.render.ISprite;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.ITriggerInternal;
import buildcraft.transport.tile.TilePipeHolder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class TriggerPipeClosed extends APTrigger implements ITriggerInternal {

Expand Down Expand Up @@ -59,7 +63,12 @@ public IStatement rotateLeft()
return this;
}


@Override
@SideOnly(Side.CLIENT)
public ISprite getSprite()
{
return Textures.TRIGGER_PIPE_CLOSED;
}

@Override
public IStatement[] getPossible()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package buildcraft.additionalpipes.textures;

import buildcraft.additionalpipes.gui.GuiJeweledPipe;
import buildcraft.api.core.render.ISprite;
import buildcraft.lib.client.sprite.SpriteHolderRegistry;
import net.minecraft.util.ResourceLocation;

public class Textures {
Expand All @@ -26,7 +28,8 @@ public class Textures {
GUI_OUTLINE_JEWELED[tabNumber - 1] = new ResourceLocation("additionalpipes", TEXTURE_PATH + "/gui/jeweled_gui_outline_" + tabNumber + ".png");
}
}



// gets set by MultiPlayerProxyClient.registerSprites()
public static ISprite TRIGGER_PIPE_CLOSED = SpriteHolderRegistry.getHolder("additionalpipes:items/triggers/pipe_closed");

}

0 comments on commit 4ba3f7f

Please sign in to comment.