forked from Vswe/SC2
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add railcraft compat for the two tracks #179
Draft
liach
wants to merge
1
commit into
TechReborn:1.12
Choose a base branch
from
liachmodded:feature/railcraft-compat
base: 1.12
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/vswe/stevescarts/compat/railcraft/CompatRailcraft.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package vswe.stevescarts.compat.railcraft; | ||
|
||
import mods.railcraft.api.core.IRailcraftModule; | ||
import mods.railcraft.api.core.RailcraftModule; | ||
import mods.railcraft.api.tracks.TrackRegistry; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.crafting.Ingredient; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.common.crafting.CraftingHelper; | ||
import net.minecraftforge.fml.common.registry.ForgeRegistries; | ||
import net.minecraftforge.fml.common.registry.GameRegistry; | ||
import vswe.stevescarts.Constants; | ||
import vswe.stevescarts.SCConfig; | ||
import vswe.stevescarts.blocks.BlockRailAdvDetector; | ||
import vswe.stevescarts.blocks.BlockRailJunction; | ||
import vswe.stevescarts.blocks.ModBlocks; | ||
import vswe.stevescarts.compat.railcraft.kit.KitAdvDetector; | ||
import vswe.stevescarts.compat.railcraft.kit.KitJunction; | ||
|
||
@RailcraftModule(value = Constants.MOD_ID + ":railcraft_compat", description = "Steves Carts Reborn Railcraft compatibility") | ||
public class CompatRailcraft implements IRailcraftModule { | ||
|
||
public static final String MOD_ID = "railcraft"; | ||
private static final ModuleEventHandler DISABLED = new ModuleEventHandler() { | ||
}; | ||
|
||
@Override | ||
public void checkPrerequisites() { | ||
} | ||
|
||
@Override | ||
public ModuleEventHandler getModuleEventHandler(boolean enabled) { | ||
return !SCConfig.railcraftCompat ? DISABLED : new ModuleEventHandler() { | ||
@Override | ||
public void construction() { | ||
RailcraftHook.init(); | ||
} | ||
|
||
@Override | ||
public void preInit() { | ||
TrackRegistry.TRACK_KIT.register(KitAdvDetector.KIT); | ||
TrackRegistry.TRACK_KIT.register(KitJunction.KIT); | ||
} | ||
|
||
@Override | ||
public void init() { | ||
KitAdvDetector.setAdvDetector((BlockRailAdvDetector) ModBlocks.ADVANCED_DETECTOR.getBlock()); | ||
Item partsItem = ForgeRegistries.ITEMS.getValue(new ResourceLocation(MOD_ID, "track_parts")); | ||
Ingredient parts = CraftingHelper.getIngredient(partsItem == null ? "ingotIron" : new ItemStack(partsItem)); | ||
Ingredient plank = CraftingHelper.getIngredient("plankWood"); | ||
Ingredient redstone = CraftingHelper.getIngredient("dustRedstone"); | ||
Ingredient stonePlate = CraftingHelper.getIngredient(Blocks.STONE_PRESSURE_PLATE); | ||
|
||
ItemStack advDetectorKit = KitAdvDetector.KIT.getTrackKitItem(); | ||
GameRegistry.addShapelessRecipe(new ResourceLocation(Constants.MOD_ID, "advanced_detector_track_kit"), null, advDetectorKit, parts, | ||
plank, redstone, stonePlate, stonePlate); | ||
|
||
ItemStack junctionKit = KitJunction.KIT.getTrackKitItem(); | ||
GameRegistry.addShapelessRecipe(new ResourceLocation(Constants.MOD_ID, "junction_track_kit"), null, junctionKit, parts, plank, | ||
redstone, redstone, redstone); | ||
} | ||
|
||
@Override | ||
public void postInit() { | ||
|
||
} | ||
}; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/vswe/stevescarts/compat/railcraft/RailcraftHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package vswe.stevescarts.compat.railcraft; | ||
|
||
import mods.railcraft.api.tracks.IOutfittedTrackTile; | ||
import mods.railcraft.api.tracks.TrackToolsAPI; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import vswe.stevescarts.compat.railcraft.kit.KitAdvDetector; | ||
|
||
public class RailcraftHook { | ||
|
||
private static RailcraftHook instance = new RailcraftHook(); | ||
|
||
public static RailcraftHook getInstance() { | ||
return instance; | ||
} | ||
|
||
static void init() { | ||
instance = new Exist(); | ||
} | ||
|
||
RailcraftHook() { | ||
} | ||
|
||
public boolean isAdvDetector(World world, BlockPos pos, IBlockState state) { | ||
return false; | ||
} | ||
|
||
public boolean isJunction(World world, BlockPos pos, IBlockState state) { | ||
return false; | ||
} | ||
|
||
static final class Exist extends RailcraftHook { | ||
|
||
@Override | ||
public boolean isAdvDetector(World world, BlockPos pos, IBlockState state) { | ||
if (state.getBlock() != TrackToolsAPI.blockTrackOutfitted) { | ||
return false; | ||
} | ||
TileEntity te = world.getTileEntity(pos); | ||
if (!(te instanceof IOutfittedTrackTile)) { | ||
return false; | ||
} | ||
return ((IOutfittedTrackTile) te).getTrackKitInstance().getTrackKit() == KitAdvDetector.KIT; | ||
} | ||
|
||
@Override | ||
public boolean isJunction(World world, BlockPos pos, IBlockState state) { | ||
if (state.getBlock() != TrackToolsAPI.blockTrackOutfitted) { | ||
return false; | ||
} | ||
TileEntity te = world.getTileEntity(pos); | ||
if (!(te instanceof IOutfittedTrackTile)) { | ||
return false; | ||
} | ||
return ((IOutfittedTrackTile) te).getTrackKitInstance().getTrackKit() == KitAdvDetector.KIT; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/vswe/stevescarts/compat/railcraft/kit/KitAdvDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package vswe.stevescarts.compat.railcraft.kit; | ||
|
||
import mods.railcraft.api.tracks.TrackKit; | ||
import mods.railcraft.api.tracks.TrackKitInstance; | ||
import net.minecraft.entity.item.EntityMinecart; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.ResourceLocation; | ||
import vswe.stevescarts.Constants; | ||
import vswe.stevescarts.blocks.BlockRailAdvDetector; | ||
|
||
public class KitAdvDetector extends TrackKitInstance { | ||
|
||
public static final TrackKit KIT = new TrackKit.Builder(new ResourceLocation(Constants.MOD_ID, "advanced_detector"), KitAdvDetector.class) | ||
.setAllowedOnSlopes(false) | ||
.setRenderStates(1) | ||
.build(); | ||
private static BlockRailAdvDetector block; | ||
|
||
@Override | ||
public TrackKit getTrackKit() { | ||
return KIT; | ||
} | ||
|
||
public static void setAdvDetector(BlockRailAdvDetector detector) { | ||
block = detector; | ||
} | ||
|
||
public KitAdvDetector() { | ||
} | ||
|
||
@Override | ||
public void onMinecartPass(EntityMinecart cart) { | ||
block.onMinecartPass(theWorldAsserted(), cart, getPos()); | ||
} | ||
|
||
// TODO canConnectRedstone not accomplishable | ||
|
||
|
||
@Override public boolean blockActivated(EntityPlayer player, EnumHand hand) { | ||
return block.onBlockActivated(theWorldAsserted(), getPos(), theWorldAsserted().getBlockState(getPos()), player, hand, EnumFacing.UP, 0, 0, 0); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/vswe/stevescarts/compat/railcraft/kit/KitJunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package vswe.stevescarts.compat.railcraft.kit; | ||
|
||
import mods.railcraft.api.tracks.TrackKit; | ||
import mods.railcraft.api.tracks.TrackKitInstance; | ||
import net.minecraft.block.BlockRailBase; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.item.EntityMinecart; | ||
import net.minecraft.util.ResourceLocation; | ||
import vswe.stevescarts.Constants; | ||
import vswe.stevescarts.blocks.BlockRailJunction; | ||
import vswe.stevescarts.entitys.EntityMinecartModular; | ||
|
||
public class KitJunction extends TrackKitInstance { | ||
|
||
public static final TrackKit KIT = new TrackKit.Builder(new ResourceLocation(Constants.MOD_ID, "junction"), KitJunction.class) | ||
.setAllowedOnSlopes(false) | ||
.setRenderer(TrackKit.Renderer.UNIFIED) | ||
.setRenderStates(6) //TODO | ||
.build(); | ||
|
||
@Override | ||
public TrackKit getTrackKit() { | ||
return KIT; | ||
} | ||
|
||
public KitJunction() { | ||
} | ||
|
||
@Override | ||
public BlockRailBase.EnumRailDirection getRailDirection(IBlockState state, EntityMinecart cart) { | ||
if (cart instanceof EntityMinecartModular) { | ||
final EntityMinecartModular modularCart = (EntityMinecartModular) cart; | ||
BlockRailBase.EnumRailDirection direction = modularCart.getRailDirection(getPos()); | ||
if (direction != null) { | ||
return direction; | ||
} | ||
} | ||
return super.getRailDirection(state, cart); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...main/resources/assets/stevescarts/blockstates/tracks/outfitted/kit/advanced_detector.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"forge_marker": 1, | ||
"defaults": { | ||
"model": "rail_flat", | ||
"textures": {"rail": "stevescarts:blocks/tracks/outfitted/kit/advanced_detector_0"} | ||
}, | ||
"variants": { | ||
"state": { | ||
"0": { | ||
"textures": {"rail": "stevescarts:blocks/tracks/outfitted/kit/advanced_detector_0"} | ||
} | ||
}, | ||
"shape": { | ||
"north_south": { | ||
"model": "rail_flat" | ||
}, | ||
"east_west": { | ||
"model": "rail_flat", "y": 90 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this? I do not see the railcraft jar, and I would be a lot happier using maven, even if it was from curse's maven endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
railcraft does not have a proper maven set up now unfortunately. i might see if railcraft can use bintray or something similar.