-
Notifications
You must be signed in to change notification settings - Fork 9
Giga Torch and Pendant Light #107
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
Open
Caedis
wants to merge
8
commits into
master
Choose a base branch
from
caedis/lightItUp
base: master
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.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c83ce1b
initial giga torch and pendant light
Caedis 1e51b51
Merge remote-tracking branch 'origin/master' into caedis/lightItUp
Caedis 5a1d4d0
spotless
Caedis fd48ba8
Merge branch 'master' into caedis/lightItUp
Caedis 2190b12
Add context comment in MobDenySpawnEvents.java
Caedis 458b559
Merge remote-tracking branch 'origin/master' into caedis/lightItUp
Caedis 0def841
updated giga_torch model from Juni
Caedis 10e1102
Merge branch 'master' into caedis/lightItUp
Caedis 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
88 changes: 88 additions & 0 deletions
88
src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockGigaTorch.java
This file contains hidden or 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,88 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.common.blocks; | ||
|
|
||
| import static net.minecraftforge.common.util.ForgeDirection.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import net.minecraft.block.Block; | ||
| import net.minecraft.block.BlockContainer; | ||
| import net.minecraft.block.material.Material; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.item.ItemBlock; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraft.tileentity.TileEntity; | ||
| import net.minecraft.util.AxisAlignedBB; | ||
| import net.minecraft.util.StatCollector; | ||
| import net.minecraft.world.World; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.TileEntityGigaTorch; | ||
| import com.fouristhenumber.utilitiesinexcess.config.blocks.BlockConfig; | ||
| import com.gtnewhorizon.gtnhlib.client.model.ModelISBRH; | ||
|
|
||
| public class BlockGigaTorch extends BlockContainer { | ||
|
|
||
| public BlockGigaTorch() { | ||
| super(Material.circuits); | ||
| setBlockName("giga_torch"); | ||
| setBlockTextureName("utilitiesinexcess:giga_torch"); | ||
| setHardness(0.0F); | ||
| setLightLevel(0.9375F); // 15 light level | ||
| setStepSound(soundTypeWood); | ||
| } | ||
|
|
||
| @Override | ||
| public TileEntity createNewTileEntity(World world, int meta) { | ||
| return new TileEntityGigaTorch(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isOpaqueCube() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean renderAsNormalBlock() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public int getRenderType() { | ||
| return ModelISBRH.JSON_ISBRH_ID; | ||
| } | ||
|
|
||
| @Override | ||
| public AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean canPlaceBlockAt(World worldIn, int x, int y, int z) { | ||
| if (World.doesBlockHaveSolidTopSurface(worldIn, x, y - 1, z)) { | ||
| return true; | ||
| } else { | ||
| Block block = worldIn.getBlock(x, y - 1, z); | ||
| return block.canPlaceTorchOnTop(worldIn, x, y - 1, z); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor) { | ||
| if (!this.canPlaceBlockAt(worldIn, x, y, z) && worldIn.getBlock(x, y, z) == this) { | ||
| this.dropBlockAsItem(worldIn, x, y, z, 0, 0); | ||
| worldIn.setBlockToAir(x, y, z); | ||
| } | ||
| } | ||
|
|
||
| public static class ItemBlockGigaTorch extends ItemBlock { | ||
|
|
||
| public ItemBlockGigaTorch(Block block) { | ||
| super(block); | ||
| } | ||
|
|
||
| @Override | ||
| public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean bool) { | ||
| tooltip.add( | ||
| StatCollector.translateToLocalFormatted("tile.giga_torch.desc", BlockConfig.gigaTorch.gigaTorchRange)); | ||
| } | ||
| } | ||
| } |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPendantLight.java
This file contains hidden or 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,77 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.common.blocks; | ||
|
|
||
| import static net.minecraftforge.common.util.ForgeDirection.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import net.minecraft.block.Block; | ||
| import net.minecraft.block.BlockContainer; | ||
| import net.minecraft.block.material.Material; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.item.ItemBlock; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraft.tileentity.TileEntity; | ||
| import net.minecraft.util.StatCollector; | ||
| import net.minecraft.world.World; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.common.tileentities.TileEntityPendantLight; | ||
| import com.fouristhenumber.utilitiesinexcess.config.blocks.BlockConfig; | ||
| import com.gtnewhorizon.gtnhlib.client.model.ModelISBRH; | ||
|
|
||
| public class BlockPendantLight extends BlockContainer { | ||
|
|
||
| public BlockPendantLight() { | ||
| super(Material.circuits); | ||
| setBlockName("pendant_light"); | ||
| setBlockTextureName("utilitiesinexcess:pendant_light"); | ||
| setHardness(0.0F); | ||
| setLightLevel(0.9375F); // 15 light level | ||
| } | ||
|
|
||
| @Override | ||
| public TileEntity createNewTileEntity(World world, int meta) { | ||
| return new TileEntityPendantLight(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isOpaqueCube() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean renderAsNormalBlock() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public int getRenderType() { | ||
| return ModelISBRH.JSON_ISBRH_ID; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean canPlaceBlockOnSide(World worldIn, int x, int y, int z, int side) { | ||
| return worldIn.isSideSolid(x, y + 1, z, DOWN); | ||
| } | ||
|
|
||
| @Override | ||
| public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor) { | ||
| if (!this.canPlaceBlockAt(worldIn, x, y, z) && worldIn.getBlock(x, y, z) == this) { | ||
| this.dropBlockAsItem(worldIn, x, y, z, 0, 0); | ||
| worldIn.setBlockToAir(x, y, z); | ||
| } | ||
| } | ||
|
|
||
| public static class ItemBlockPendantLight extends ItemBlock { | ||
|
|
||
| public ItemBlockPendantLight(Block block) { | ||
| super(block); | ||
| } | ||
|
|
||
| @Override | ||
| public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean bool) { | ||
| tooltip.add( | ||
| StatCollector | ||
| .translateToLocalFormatted("tile.pendant_light.desc", BlockConfig.pendantLight.pendantLightRange)); | ||
| } | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/fouristhenumber/utilitiesinexcess/common/events/MobDenySpawnEvents.java
This file contains hidden or 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,51 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.common.events; | ||
|
|
||
| import net.minecraft.entity.EnumCreatureType; | ||
| import net.minecraft.entity.monster.EntitySlime; | ||
| import net.minecraftforge.event.entity.living.LivingSpawnEvent; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.ModBlocks; | ||
| import com.fouristhenumber.utilitiesinexcess.UtilitiesInExcess; | ||
| import com.gtnewhorizon.gtnhlib.eventbus.EventBusSubscriber; | ||
|
|
||
| import cpw.mods.fml.common.eventhandler.Event; | ||
| import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| @EventBusSubscriber() | ||
| public class MobDenySpawnEvents { | ||
|
|
||
| @EventBusSubscriber.Condition | ||
| public static boolean shouldSubscribe() { | ||
| return ModBlocks.GIGA_TORCH.isEnabled(); | ||
| } | ||
|
|
||
| // context https://github.com/GTNewHorizons/GT5-Unofficial/pull/905 | ||
| @SubscribeEvent | ||
| public static void denySpawn(LivingSpawnEvent.CheckSpawn event) { | ||
| if (event.getResult() == Event.Result.DENY) return; | ||
|
|
||
| if (event.entityLiving instanceof EntitySlime slime && !slime.hasCustomNameTag() | ||
| && event.getResult() == Event.Result.ALLOW) { | ||
| event.setResult(Event.Result.DEFAULT); | ||
| } | ||
|
|
||
| if (event.getResult() == Event.Result.ALLOW) { | ||
| return; | ||
| } | ||
|
|
||
| if (event.entityLiving.isCreatureType(EnumCreatureType.monster, false)) { | ||
| if (UtilitiesInExcess.proxy.mobSpawnBlockChecks.isInRange( | ||
| event.entity.worldObj.provider.dimensionId, | ||
| event.entity.posX, | ||
| event.entity.posY, | ||
| event.entity.posZ)) { | ||
| if (event.entityLiving instanceof EntitySlime slime) { | ||
| slime.setCustomNameTag("DoNotSpawnSlimes"); | ||
| } | ||
| event.setResult(Event.Result.DENY); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
29 changes: 29 additions & 0 deletions
29
...n/java/com/fouristhenumber/utilitiesinexcess/common/tileentities/TileEntityGigaTorch.java
This file contains hidden or 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,29 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.common.tileentities; | ||
|
|
||
| import net.minecraft.tileentity.TileEntity; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.UtilitiesInExcess; | ||
| import com.fouristhenumber.utilitiesinexcess.config.blocks.BlockConfig; | ||
|
|
||
| public class TileEntityGigaTorch extends TileEntity { | ||
|
|
||
| @Override | ||
| public boolean canUpdate() { | ||
| return false; | ||
| } | ||
|
|
||
| // placed or loaded from chunk | ||
| @Override | ||
| public void validate() { | ||
| super.validate(); | ||
| UtilitiesInExcess.proxy.mobSpawnBlockChecks | ||
| .put(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, BlockConfig.gigaTorch.gigaTorchRange); | ||
| } | ||
|
|
||
| // removed or unloaded | ||
| @Override | ||
| public void invalidate() { | ||
| UtilitiesInExcess.proxy.mobSpawnBlockChecks.remove(worldObj.provider.dimensionId, xCoord, yCoord, zCoord); | ||
| super.invalidate(); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
...ava/com/fouristhenumber/utilitiesinexcess/common/tileentities/TileEntityPendantLight.java
This file contains hidden or 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,29 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.common.tileentities; | ||
|
|
||
| import net.minecraft.tileentity.TileEntity; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.UtilitiesInExcess; | ||
| import com.fouristhenumber.utilitiesinexcess.config.blocks.BlockConfig; | ||
|
|
||
| public class TileEntityPendantLight extends TileEntity { | ||
|
|
||
| @Override | ||
| public boolean canUpdate() { | ||
| return false; | ||
| } | ||
|
|
||
| // placed or loaded from chunk | ||
| @Override | ||
| public void validate() { | ||
| super.validate(); | ||
| UtilitiesInExcess.proxy.mobSpawnBlockChecks | ||
| .put(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, BlockConfig.pendantLight.pendantLightRange); | ||
| } | ||
|
|
||
| // removed or unloaded | ||
| @Override | ||
| public void invalidate() { | ||
| UtilitiesInExcess.proxy.mobSpawnBlockChecks.remove(worldObj.provider.dimensionId, xCoord, yCoord, zCoord); | ||
| super.invalidate(); | ||
| } | ||
| } |
This file contains hidden or 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
5 changes: 5 additions & 0 deletions
5
src/main/resources/assets/utilitiesinexcess/blockstates/giga_torch.json
This file contains hidden or 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,5 @@ | ||
| { | ||
| "variants": { | ||
| "": { "model": "utilitiesinexcess:blocks/giga_torch"} | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.