use of mods.railcraft.api.tracks.TrackType in project Railcraft by Railcraft.
the class ItemTrackOutfitted method initializeClient.
@SideOnly(Side.CLIENT)
@Override
public void initializeClient() {
ArrayList<ModelResourceLocation> textures = new ArrayList<>();
for (TrackType trackType : TrackRegistry.TRACK_TYPE) {
for (TrackKit trackKit : TrackRegistry.TRACK_KIT) {
textures.add(new ModelResourceLocation(new ResourceLocation(RailcraftConstants.RESOURCE_DOMAIN, MODEL_PREFIX + trackType.getName() + "." + trackKit.getName()), "inventory"));
}
}
ModelManager.registerComplexItemModel(this, (stack -> new ModelResourceLocation(new ResourceLocation(RailcraftConstants.RESOURCE_DOMAIN, MODEL_PREFIX + getSuffix(stack)), "inventory")), textures.toArray(new ModelResourceLocation[textures.size()]));
}
use of mods.railcraft.api.tracks.TrackType in project Railcraft by Railcraft.
the class OutfittedTrackModel method getDependencies.
@Override
public Collection<ResourceLocation> getDependencies() {
if (trackTypeModelsLocations.isEmpty()) {
for (TrackType trackType : TrackRegistry.TRACK_TYPE) {
for (BlockRailBase.EnumRailDirection shape : BlockTrackOutfitted.SHAPE.getAllowedValues()) {
trackTypeModelsLocations.add(getTrackTypeModelLocation(trackType, shape));
}
}
}
if (trackKitModelsLocations.isEmpty()) {
TrackRegistry.TRACK_KIT.stream().filter(t -> t.getRenderer() == TrackKit.Renderer.COMPOSITE).forEach(t -> {
EnumSet<BlockRailBase.EnumRailDirection> shapes = EnumSet.copyOf(BlockTrackOutfitted.SHAPE.getAllowedValues());
if (!t.isAllowedOnSlopes()) {
shapes.removeIf(s -> !TrackShapeHelper.isLevelStraight(s));
}
for (BlockRailBase.EnumRailDirection shape : shapes) {
for (int state = 0; state < t.getRenderStates(); state++) trackKitModelsLocations.add(getTrackKitModelLocation(t, shape, state));
}
});
}
if (unifiedModelsLocations.isEmpty()) {
TrackRegistry.TRACK_KIT.stream().filter(t -> t.getRenderer() == TrackKit.Renderer.UNIFIED).forEach(trackKit -> {
EnumSet<BlockRailBase.EnumRailDirection> shapes = EnumSet.copyOf(BlockTrackOutfitted.SHAPE.getAllowedValues());
if (!trackKit.isAllowedOnSlopes()) {
shapes.removeIf(s -> !TrackShapeHelper.isLevelStraight(s));
}
for (TrackType trackType : TrackRegistry.TRACK_TYPE) for (BlockRailBase.EnumRailDirection shape : shapes) {
for (int state = 0; state < trackKit.getRenderStates(); state++) unifiedModelsLocations.add(getUnifiedModelLocation(trackType, trackKit, shape, state));
}
});
}
if (models.isEmpty()) {
models.addAll(trackTypeModelsLocations);
models.addAll(trackKitModelsLocations);
models.addAll(unifiedModelsLocations);
}
return models;
}
use of mods.railcraft.api.tracks.TrackType in project Railcraft by Railcraft.
the class ItemTrackKit method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
playerIn.swingArm(hand);
if (Game.isClient(worldIn))
return EnumActionResult.PASS;
IBlockState oldState = WorldPlugin.getBlockState(worldIn, pos);
if (!TrackTools.isRailBlock(oldState)) {
return EnumActionResult.PASS;
}
TrackType trackType = null;
if (oldState.getBlock() instanceof BlockTrackFlex) {
BlockTrackFlex track = (BlockTrackFlex) oldState.getBlock();
trackType = track.getTrackType(worldIn, pos);
} else if (oldState.getBlock() == Blocks.RAIL) {
trackType = TrackTypes.IRON.getTrackType();
}
if (trackType != null) {
BlockRailBase.EnumRailDirection shape = TrackTools.getTrackDirectionRaw(worldIn, pos);
if (TrackShapeHelper.isStraight(shape)) {
TrackKit trackKit = TrackRegistry.TRACK_KIT.get(stack);
if (!shape.isAscending() || trackKit.isAllowedOnSlopes()) {
if (!trackKit.isAllowedTrackType(trackType)) {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.track_type");
return EnumActionResult.PASS;
}
if (BlockTrackOutfitted.placeTrack(worldIn, pos, playerIn, shape, trackType, trackKit)) {
SoundHelper.playPlaceSoundForBlock(worldIn, pos);
stack.stackSize--;
return EnumActionResult.SUCCESS;
}
} else {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.slope");
}
} else {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.curve");
}
} else {
ChatPlugin.sendLocalizedChatFromServer(playerIn, "gui.railcraft.track_kit.item.invalid.track");
}
return EnumActionResult.PASS;
}
use of mods.railcraft.api.tracks.TrackType in project Railcraft by Railcraft.
the class TrackKitBooster method onMinecartPass.
@Override
public void onMinecartPass(EntityMinecart cart) {
TrackType trackType = ((TileTrackOutfitted) getTile()).getTrackType();
if (TrackTypes.REINFORCED.getTrackType() == trackType)
onMinecartPassStandard(cart, BOOST_FACTOR_REINFORCED);
else if (trackType.isHighSpeed())
onMinecartPassHighSpeed(cart);
else
onMinecartPassStandard(cart, BOOST_FACTOR);
}
use of mods.railcraft.api.tracks.TrackType in project Railcraft by Railcraft.
the class ItemSpikeMaul method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
playerIn.swingArm(hand);
if (ISpikeMaulTarget.spikeMaulTargets.isEmpty())
return EnumActionResult.PASS;
IBlockState oldState = WorldPlugin.getBlockState(worldIn, pos);
TileEntity oldTile = null;
if (oldState.getBlock().hasTileEntity(oldState)) {
oldTile = WorldPlugin.getBlockTile(worldIn, pos);
}
if (!TrackTools.isRailBlock(oldState))
return EnumActionResult.PASS;
TrackType trackType = TrackTools.getTrackTypeAt(worldIn, pos, oldState);
BlockRailBase.EnumRailDirection shape = TrackTools.getTrackDirectionRaw(oldState);
if (!TrackShapeHelper.isAscending(shape)) {
Deque<ISpikeMaulTarget> targets = new LinkedList<>(ISpikeMaulTarget.spikeMaulTargets);
Set<ISpikeMaulTarget> tried = new HashSet<>();
boolean foundMatch = false;
ISpikeMaulTarget target;
while ((target = targets.poll()) != null && !tried.contains(target)) {
if (target.matches(worldIn, pos, oldState)) {
foundMatch = true;
break;
} else {
tried.add(target);
targets.addLast(target);
}
}
if (foundMatch) {
if (Game.isClient(worldIn))
return EnumActionResult.SUCCESS;
WorldPlugin.setBlockToAir(worldIn, pos);
ChargeManager.getNetwork(worldIn).deregisterChargeNode(pos);
while ((target = targets.poll()) != null) {
if (target.setToTarget(worldIn, pos, oldState, playerIn, shape, trackType)) {
SoundHelper.playPlaceSoundForBlock(worldIn, pos);
stack.damageItem(1, playerIn);
return EnumActionResult.SUCCESS;
}
}
WorldPlugin.setBlockState(worldIn, pos, oldState);
if (oldTile != null) {
oldTile.validate();
worldIn.setTileEntity(pos, oldTile);
}
return EnumActionResult.FAIL;
}
}
return EnumActionResult.PASS;
}
Aggregations