Message when using reach upgrades in creative.
Sound when placing blocks far away.
This commit is contained in:
@@ -17,7 +17,8 @@ public class BuildConfig {
|
|||||||
"If disabled, reach is set to level 3 for survival players."})
|
"If disabled, reach is set to level 3 for survival players."})
|
||||||
public boolean enableReachUpgrades = true;
|
public boolean enableReachUpgrades = true;
|
||||||
|
|
||||||
@Comment("Maximum reach in creative")
|
@Comment({"Maximum reach in creative",
|
||||||
|
"Keep in mind that chunks need to be loaded to be able to place blocks inside."})
|
||||||
public int maxReachCreative = 200;
|
public int maxReachCreative = 200;
|
||||||
|
|
||||||
@Comment({"Maximum reach in survival without upgrades",
|
@Comment({"Maximum reach in survival without upgrades",
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ public class ItemReachUpgrade1 extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||||
|
if (player.isCreative()) {
|
||||||
|
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||||
|
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||||
|
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||||
|
}
|
||||||
|
|
||||||
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
|
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
|
||||||
int currentLevel = buildSettings.getReachUpgrade();
|
int currentLevel = buildSettings.getReachUpgrade();
|
||||||
if (currentLevel == 0) {
|
if (currentLevel == 0) {
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ public class ItemReachUpgrade2 extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||||
|
if (player.isCreative()) {
|
||||||
|
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||||
|
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||||
|
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||||
|
}
|
||||||
|
|
||||||
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
|
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
|
||||||
int currentLevel = buildSettings.getReachUpgrade();
|
int currentLevel = buildSettings.getReachUpgrade();
|
||||||
if (currentLevel == 1) {
|
if (currentLevel == 1) {
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ public class ItemReachUpgrade3 extends Item {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||||
|
if (player.isCreative()) {
|
||||||
|
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||||
|
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||||
|
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||||
|
}
|
||||||
|
|
||||||
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
|
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
|
||||||
int currentLevel = buildSettings.getReachUpgrade();
|
int currentLevel = buildSettings.getReachUpgrade();
|
||||||
if (currentLevel == 2) {
|
if (currentLevel == 2) {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class ClientProxy implements IProxy {
|
|||||||
public static KeyBinding[] keyBindings;
|
public static KeyBinding[] keyBindings;
|
||||||
public static RayTraceResult previousLookAt;
|
public static RayTraceResult previousLookAt;
|
||||||
public static RayTraceResult currentLookAt;
|
public static RayTraceResult currentLookAt;
|
||||||
|
private static int breakCooldown = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
@@ -127,6 +128,16 @@ public class ClientProxy implements IProxy {
|
|||||||
RayTraceResult lookingAt = getLookingAt(player);
|
RayTraceResult lookingAt = getLookingAt(player);
|
||||||
if (lookingAt != null && lookingAt.typeOfHit == RayTraceResult.Type.BLOCK) {
|
if (lookingAt != null && lookingAt.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||||
EffortlessBuilding.packetHandler.sendToServer(new BlockPlacedMessage(lookingAt));
|
EffortlessBuilding.packetHandler.sendToServer(new BlockPlacedMessage(lookingAt));
|
||||||
|
|
||||||
|
//play sound if further than normal
|
||||||
|
if ((lookingAt.hitVec.subtract(player.getPositionEyes(1f))).lengthSquared() > 25f) {
|
||||||
|
BlockPos blockPos = lookingAt.getBlockPos();
|
||||||
|
IBlockState state = player.world.getBlockState(blockPos);
|
||||||
|
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||||
|
player.world.playSound(player, blockPos, soundtype.getPlaceSound(), SoundCategory.BLOCKS,
|
||||||
|
(soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||||
|
player.swingArm(EnumHand.MAIN_HAND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,18 +147,26 @@ public class ClientProxy implements IProxy {
|
|||||||
|
|
||||||
//Break block in distance in creative (or survival if enabled in config)
|
//Break block in distance in creative (or survival if enabled in config)
|
||||||
if (ReachHelper.canBreakFar(player)) {
|
if (ReachHelper.canBreakFar(player)) {
|
||||||
RayTraceResult lookingAt = getLookingAt(player);
|
if (breakCooldown <= 0) {
|
||||||
if (lookingAt != null && lookingAt.typeOfHit == RayTraceResult.Type.BLOCK) {
|
breakCooldown = 6;
|
||||||
EffortlessBuilding.packetHandler.sendToServer(new BlockBrokenMessage(lookingAt));
|
RayTraceResult lookingAt = getLookingAt(player);
|
||||||
|
if (lookingAt != null && lookingAt.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||||
|
EffortlessBuilding.packetHandler.sendToServer(new BlockBrokenMessage(lookingAt));
|
||||||
|
|
||||||
//play sound
|
//play sound
|
||||||
BlockPos blockPos = lookingAt.getBlockPos();
|
BlockPos blockPos = lookingAt.getBlockPos();
|
||||||
IBlockState state = player.world.getBlockState(blockPos);
|
IBlockState state = player.world.getBlockState(blockPos);
|
||||||
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||||
player.world.playSound(player, blockPos, soundtype.getBreakSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
player.world.playSound(player, blockPos, soundtype.getBreakSound(), SoundCategory.BLOCKS,
|
||||||
player.swingArm(EnumHand.MAIN_HAND);
|
(soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||||
|
player.swingArm(EnumHand.MAIN_HAND);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
breakCooldown--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
breakCooldown = 0;
|
||||||
}
|
}
|
||||||
event.setResult(Event.Result.ALLOW);
|
event.setResult(Event.Result.ALLOW);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user