Add ability for custom detector rail output
This commit is contained in:
parent
5eeda79234
commit
7b5a5fbcbe
|
@ -0,0 +1,11 @@
|
|||
--- ../src-base/minecraft/net/minecraft/block/BlockRailDetector.java
|
||||
+++ ../src-work/minecraft/net/minecraft/block/BlockRailDetector.java
|
||||
@@ -156,6 +156,8 @@
|
||||
{
|
||||
if (((Boolean)p_180641_1_.func_177229_b(field_176574_M)).booleanValue())
|
||||
{
|
||||
+ int result = net.minecraftforge.event.ForgeEventFactory.onDetectorRailCompare(p_180641_3_, func_176572_a(p_180641_3_));
|
||||
+ if (result > -1) return result;
|
||||
List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>func_176571_a(p_180641_2_, p_180641_3_, EntityMinecartCommandBlock.class, new Predicate[0]);
|
||||
|
||||
if (!list.isEmpty())
|
|
@ -46,6 +46,7 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -101,6 +102,7 @@ import net.minecraftforge.event.world.BlockEvent;
|
|||
import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
|
||||
import net.minecraftforge.event.world.DetectorRailComparatorEvent;
|
||||
import net.minecraftforge.event.world.ExplosionEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
@ -585,4 +587,11 @@ public class ForgeEventFactory
|
|||
return event.getTable();
|
||||
}
|
||||
|
||||
public static int onDetectorRailCompare(BlockPos pos, AxisAlignedBB box)
|
||||
{
|
||||
DetectorRailComparatorEvent evt = new DetectorRailComparatorEvent(pos, box);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt.getRedstonePower();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package net.minecraftforge.event.world;
|
||||
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* This event is fired serverside whenever a Detector Rail looks for a minecart to get a comparator value from
|
||||
* in {@link net.minecraft.block.BlockRailDetector#getComparatorInputOverride}.
|
||||
* This event is not cancelable.
|
||||
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
|
||||
*/
|
||||
public class DetectorRailComparatorEvent extends Event
|
||||
{
|
||||
|
||||
private final BlockPos pos;
|
||||
private final AxisAlignedBB searchBox;
|
||||
private int redstonePower;
|
||||
|
||||
public DetectorRailComparatorEvent(BlockPos pos, AxisAlignedBB searchBox)
|
||||
{
|
||||
this.pos = pos;
|
||||
this.searchBox = searchBox;
|
||||
this.redstonePower = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The position of the Detector Rail
|
||||
*/
|
||||
public BlockPos getPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The bounding box that is to be searched for minecarts
|
||||
*/
|
||||
public AxisAlignedBB getSearchBox()
|
||||
{
|
||||
return searchBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The redstone signal strength to give the comparator. Values below 0 mean vanilla logic will run.
|
||||
*/
|
||||
public int getRedstonePower()
|
||||
{
|
||||
return redstonePower;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the redstone power to give the comparator. Values below 0 mean vanilla logic will run.
|
||||
*/
|
||||
public void setRedstonePower(int redstonePower)
|
||||
{
|
||||
this.redstonePower = redstonePower;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue