Compare commits

..

46 Commits

Author SHA1 Message Date
9dde7b4288 1.0.4
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-09-10 19:10:56 -04:00
40de5445d1 1.0.3
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-09-06 10:41:30 -04:00
643e287e23 1.0.2
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-31 19:19:54 -04:00
e5135deef1 Add Veridium Block To Beacon Base Blocks Tag
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-30 19:10:33 -04:00
7cb97d4bb6 1.0.1
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-30 17:18:29 -04:00
a754b43b7c Merge pull request 'fix up ru_ru.lang' (#3) from Yoghurt4C/EnergonRelics:webedit-1 into master
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-29 21:37:00 +00:00
Yoghurt4C
89b42442fd Either Hot Shit or Total Bollocks 2020-08-27 13:48:32 +00:00
Yoghurt4C
ac1c09cc5f Update 'src/main/resources/assets/energonrelics/lang/ru_ru.json' 2020-08-27 13:21:16 +00:00
8e1712e64c 1.0.0
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-26 21:12:47 -04:00
3f59e506a4 0.2.2
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-22 12:17:00 -04:00
6382869176 0.2.1
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-21 18:34:25 -04:00
8941461874 0.2.0
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-21 12:54:25 -04:00
973f92cc35 Add Russian Translations
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-21 12:29:06 -04:00
e8940acb39 Add New Textures
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-21 12:26:37 -04:00
c095f7da28 Small Optimization
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 21:21:35 -04:00
c484e6d78a 0.1.9
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 20:53:33 -04:00
fbb1020ce8 0.1.8
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 19:03:47 -04:00
5258a235b5 Add Proper Culling
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 16:02:09 -04:00
f38f6fbced Add Check
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 15:58:18 -04:00
ce2e2df2d5 Improve Energy Portal
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 15:46:48 -04:00
91fab233a4 0.1.7
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 15:24:52 -04:00
4ebb0279fe 0.1.6
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-20 14:53:53 -04:00
5dbfb589ee 0.1.5
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-19 20:59:16 -04:00
9e0edf763a 0.1.4
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-19 20:48:29 -04:00
8241f88fea 0.1.3
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-19 20:40:49 -04:00
4799ad5903 Make Industrial Laser Set On Fire
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-19 20:19:27 -04:00
f4bb60b819 Improve Energy Teleporter Y
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-19 19:57:38 -04:00
f6e94963d2 Generate Random Seed For Structure Generator If Not Specified
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-19 15:53:46 -04:00
1c23d15d2e Don't Propagate Paid Actions
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-18 12:19:04 -04:00
dea30e1073 0.1.2
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-17 18:59:31 -04:00
116c03667f 0.1.1
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-16 13:15:33 -04:00
014ed2cded 0.1.0
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-16 11:24:03 -04:00
dfe547c34b 0.0.9
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-16 09:43:06 -04:00
9096dbd53a 0.0.8
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-15 23:01:24 -04:00
72c85fa67b 0.0.7
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-15 14:26:33 -04:00
401970963f 0.0.6
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-12 16:52:09 -04:00
b097bb7cd5 1.16.2
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-11 14:56:41 -04:00
4c85f10acb Fix Jenkins
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-08 17:57:45 -04:00
d9a38abadb 0.0.5
Some checks failed
EnergonRelics/pipeline/head There was a failure building this commit
2020-08-08 17:39:38 -04:00
ee4739474d Fix Jenkinsfile
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-07 17:51:16 -04:00
f68bb1d96d 0.0.4
All checks were successful
EnergonRelics/pipeline/head This commit looks good
Improve REI Plugin
2020-08-07 17:34:55 -04:00
80f41be450 0.0.3
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-06 22:32:48 -04:00
5669ee35b6 Add Profiler To isTouching
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-06 22:29:44 -04:00
db0620b3e2 More Performance Tweaks
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-06 22:12:48 -04:00
3d7df7742d Performance Tweaks
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-06 22:07:10 -04:00
24b69d5150 1.16.2 Pre-Release 3
All checks were successful
EnergonRelics/pipeline/head This commit looks good
2020-08-06 19:13:07 -04:00
149 changed files with 1812 additions and 409 deletions

View File

@ -1,4 +1,90 @@
# Changelog # Changelog
**1.0.4**
* Fix Crash When Sneak-Using Dye On A Block
**1.0.3**
* Fix Gravity Crash
**1.0.2**
* Attempt To Fix Structure Generation Crash
**1.0.1**
* Add Advancements
* Industrial Laser Can Smelt Nether Gold Ore
* Rework Network Chip Recipe
**1.0.8**
* Update Textures
**Beta 0.2.2**
* Update To Fabric Structure API
**Beta 0.2.1**
* Fix Solar Panel Crash
**Beta 0.2.0**
* Add New Textures
* Add Russian Translations
**Beta 0.1.9**
* Fix Profiling
**Beta 0.1.8**
* Fix Creative Inventory Breaking
**Beta 0.1.7**
* Improve Industrial Laser Fire
**Beta 0.1.6**
* Improve Energy Teleporter Reliability
**Beta 0.1.5**
* Fix Energy Teleporter Y Issues Again
**Beta 0.1.4**
* Fix Bug Where Off Switches Require Power
**Beta 0.1.3**
* Optimizations
* Fix Energy Teleporter Y Issues
* Make Industrial Laser Set Fire To Entities
* Redolence Solar Panels
**Beta 0.1.2**
* Improve Highlight Rendering
**Beta 0.1.1**
* Fix Texture Names
**Beta 0.1.0**
* Fix Interaction Bug With Phase Shifter Block
**Beta 0.0.9**
* Fix Interaction Bug With Phase Shifter Block
**Beta 0.0.8**
* Add Phase Shifter Block
* Fix Bugs
* Add Circuit Board To REI
**Beta 0.0.7**
* Fix Structure Generation
**Beta 0.0.6**
* Remove ``DamageSourceAccessor``
**Beta 0.0.5**
* Improve Fabric JSON
**Beta 0.0.4**
* Improve REI Plugin
**Beta 0.0.3**
* Performance Improvements
**Beta 0.0.2**
* Add New Textures
**Beta 0.0.1** **Beta 0.0.1**
* Initial Release * Initial Release

15
Jenkinsfile vendored
View File

@ -7,7 +7,7 @@ pipeline {
stages { stages {
stage('Build') { stage('Build') {
steps { steps {
sh './gradlew build javadoc publish' sh './gradlew build javadoc'
} }
post { post {
success { success {
@ -24,5 +24,18 @@ pipeline {
} }
} }
} }
stage('Publish') {
when {
expression {
return sh(returnStdout: true, script: 'git tag --contains').trim().length() > 0
}
}
steps {
sh './gradlew publish'
withCredentials([string(credentialsId: 'curseforge_key', variable: 'CURSEFORGE_KEY')]) {
sh './gradlew -Pcurseforge.api_key="${CURSEFORGE_KEY}" curseforge'
}
}
}
} }
} }

View File

@ -18,3 +18,4 @@ Using RoughlyEnoughItems with this mod is highly recommended.
- ``@PoeticRainbow#5928`` on Discord For The Logo And Poster - ``@PoeticRainbow#5928`` on Discord For The Logo And Poster
- ``@PoeticRainbow#5928`` on Discord For Their Texture Set - ``@PoeticRainbow#5928`` on Discord For Their Texture Set
- ``@azazelthedemonlord#2563`` on Discord For Their Texture Set - ``@azazelthedemonlord#2563`` on Discord For Their Texture Set
- ``kazmurenko`` on CurseForge For Translating To Russian

View File

@ -45,9 +45,6 @@ dependencies {
modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}" modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"
include "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}" include "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"
modImplementation "net.earthcomputer:libstructure:${project.libstructure_version}"
include "net.earthcomputer:libstructure:${project.libstructure_version}"
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}" compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
} }

27
docs/API.md Normal file
View File

@ -0,0 +1,27 @@
# API
The public API is in the package ``com.thebrokenrail.energonrelics.api``. Any registries are located in the package ``com.thebrokenrail.energonrelics.registry``. Anything else should be treated as unstable and may change at any moment.
## Setup
### ``build.gradle``
```gradle
repositories {
maven { url 'https://maven.thebrokenrail.com' }
}
dependencies {
modImplementation 'com.thebrokenrail:energonrelics:VERSION'
// VERSION = "<Mod Version>+<MC Version>", for example "1.0.0+1.16.2"
}
```
### ``fabric.mod.json``
```json
{
"depends": {
"energonrelics": "1.0.x"
}
}
```
## JavaDoc
[View JavaDoc](https://jenkins.thebrokenrail.com/job/EnergonRelics/job/master/JavaDoc/)

View File

@ -93,3 +93,13 @@
## Infuser ## Infuser
- Uses Energy To Attempt To Convert An Item To A Different Item - Uses Energy To Attempt To Convert An Item To A Different Item
- Each Item Has Multiple Outcomes And May Require Different Amount Of Energy - Each Item Has Multiple Outcomes And May Require Different Amount Of Energy
## Phase Shifter
- Two Modes: Input And Output
- Mode Is Toggled By Redstone Input
- Can Be Dyed
- Input Blocks Phase Items
- The More Phased Items, The More Power An Input Requires
- The Longer An Item Is Phased, The Higher Its Range Is
- Periodically, Phased Items Are Rolled
- When Phased Items Are Rolled, There Is A 10% Chance Of Success, If It Succeeds it Will Transfer The Phased Item To An Output With Range That Is The Same Color

View File

@ -7,3 +7,5 @@
[View Blocks](BLOCKS.md) [View Blocks](BLOCKS.md)
[View Structures](STRUCTURES.md) [View Structures](STRUCTURES.md)
[View API](API.md)

View File

@ -3,22 +3,21 @@ org.gradle.jvmargs = -Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
minecraft_version = 1.16.2-pre2 minecraft_version = 1.16.2
curseforge_id = 398250 curseforge_id = 398250
simple_minecraft_version = 1.16-Snapshot simple_minecraft_version = 1.16.2
yarn_build = 1 yarn_build = 21
fabric_loader_version = 0.9.0+build.204 fabric_loader_version = 0.9.2+build.206
# Mod Properties # Mod Properties
mod_version = 0.0.2 mod_version = 1.0.4
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
# Dependencies # Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_api_version = 0.16.4+build.392-1.16 fabric_api_version = 0.19.0+build.398-1.16
modmenu_version = 1.14.6+build.31 modmenu_version = 1.14.6+build.31
cloth_config_version = 4.7.0-unstable cloth_config_version = 4.7.0-unstable
autoconfig_version = 3.2.0-unstable autoconfig_version = 3.2.0-unstable
libstructure_version = 1.4.1 roughlyenoughitems_version = 5.2.3
roughlyenoughitems_version = 5.1.0-unstable
jetbrains_annotations_version = 19.0.0 jetbrains_annotations_version = 19.0.0

View File

@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.CreativeEnergySourceBlock;
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock; import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
import com.thebrokenrail.energonrelics.block.HolographicSkyBlock; import com.thebrokenrail.energonrelics.block.HolographicSkyBlock;
import com.thebrokenrail.energonrelics.block.InfuserBlock; import com.thebrokenrail.energonrelics.block.InfuserBlock;
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
import com.thebrokenrail.energonrelics.block.lightning.LightningRodBaseBlock; import com.thebrokenrail.energonrelics.block.lightning.LightningRodBaseBlock;
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldProjectorBlock; import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldProjectorBlock;
import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock; import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock;
@ -32,6 +33,7 @@ import com.thebrokenrail.energonrelics.block.EnergonLightBlock;
import com.thebrokenrail.energonrelics.block.SolarPanelBlock; import com.thebrokenrail.energonrelics.block.SolarPanelBlock;
import com.thebrokenrail.energonrelics.block.SwitchBlock; import com.thebrokenrail.energonrelics.block.SwitchBlock;
import com.thebrokenrail.energonrelics.api.block.SimpleBlock; import com.thebrokenrail.energonrelics.api.block.SimpleBlock;
import com.thebrokenrail.energonrelics.feature.CustomFeatures;
import com.thebrokenrail.energonrelics.item.MultimeterItem; import com.thebrokenrail.energonrelics.item.MultimeterItem;
import com.thebrokenrail.energonrelics.item.NetworkChipItem; import com.thebrokenrail.energonrelics.item.NetworkChipItem;
import com.thebrokenrail.energonrelics.potion.CustomPotions; import com.thebrokenrail.energonrelics.potion.CustomPotions;
@ -50,151 +52,162 @@ import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity; import net.minecraft.util.Rarity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
public final class EnergonRelics implements ModInitializer { public final class EnergonRelics implements ModInitializer {
public static final String NAMESPACE = "energonrelics"; public static final String NAMESPACE = "energonrelics";
public static NetworkChipItem NETWORK_CHIP_ITEM; public static final class Items {
static {
if (ItemGroup.BUILDING_BLOCKS == null) {
throw new RuntimeException("Items Loaded Too Early");
}
}
public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(NAMESPACE, "item_group"), () -> new ItemStack(NETWORK_CHIP_ITEM)); public static final NetworkChipItem NETWORK_CHIP_ITEM;
public static final EnergonLightBlock ENERGON_LIGHT_BLOCK = new EnergonLightBlock(); public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(NAMESPACE, "item_group"), () -> new ItemStack(Items.NETWORK_CHIP_ITEM));
public static final SolarPanelBlock SOLAR_PANEL_BLOCK = new SolarPanelBlock();
public static final SwitchBlock SWITCH_BLOCk = new SwitchBlock();
public static final MultimeterItem MULTIMETER_ITEM = new MultimeterItem();
public static final ThermalCasingBlock THERMAL_CASING_BLOCK = new ThermalCasingBlock(); static {
public static final ThermalGlassBlock THERMAL_GLASS_BLOCK = new ThermalGlassBlock(); NETWORK_CHIP_ITEM = new NetworkChipItem();
}
public static final BatteryCoreBlock BATTERY_CORE_BLOCk = new BatteryCoreBlock(); public static final MultimeterItem MULTIMETER = new MultimeterItem();
public static final PassiveBatteryControllerBlock PASSIVE_BATTERY_CONTROLLER_BLOCk = new PassiveBatteryControllerBlock(); public static final Item VERIDIUM_ORB = new Item(new Item.Settings().group(ITEM_GROUP).rarity(Rarity.UNCOMMON));
public static final ActiveBatteryControllerBlock ACTIVE_BATTERY_CONTROLLER_BLOCK = new ActiveBatteryControllerBlock(); public static final Item VERIDIUM_POWDER = new Item(new Item.Settings().group(ITEM_GROUP));
public static final Item DEFENSIVE_LASER_CORE = new Item(new Item.Settings().group(ITEM_GROUP));
public static final Item CIRCUIT_BOARD = new Item(new Item.Settings().group(ITEM_GROUP));
public static final Item VERIDIUM_INGOT = new Item(new Item.Settings().group(ITEM_GROUP));
}
public static final ReactorCoreBlock REACTOR_CORE_BLOCK = new ReactorCoreBlock(); public static final class Blocks {
public static final ReactorInputBlock REACTOR_INPUT_BLOCK = new ReactorInputBlock(); public static final EnergonLightBlock ENERGON_LIGHT = new EnergonLightBlock();
public static final ReactorControllerBlock REACTOR_CONTROLLER_BLOCK = new ReactorControllerBlock(); public static final SolarPanelBlock SOLAR_PANEL = new SolarPanelBlock();
public static final SwitchBlock SWITCH = new SwitchBlock();
public static final Item VERIDIUM_INGOT_ITEM = new Item(new Item.Settings().group(ITEM_GROUP)); public static final ThermalCasingBlock THERMAL_CASING = new ThermalCasingBlock();
public static final SimpleBlock VERIDIUM_ORE_BLOCK = new SimpleBlock(FabricBlockSettings.of(Material.STONE).requiresTool().strength(3f, 3f)); public static final ThermalGlassBlock THERMAL_GLASS = new ThermalGlassBlock();
public static final SimpleBlock VERIDIUM_BLOCK_BLOCK = new VeridiumBlockBlock();
public static final ConfiguredFeature<?, ?> VERIDIUM_ORE_FEATURE = Feature.ORE.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, EnergonRelics.VERIDIUM_ORE_BLOCK.getDefaultState(), 9)).method_30377(32).spreadHorizontally().repeat(2);
public static final Item CIRCUIT_BOARD_ITEM = new Item(new Item.Settings().group(ITEM_GROUP)); public static final BatteryCoreBlock BATTERY_CORE = new BatteryCoreBlock();
public static final PassiveBatteryControllerBlock PASSIVE_BATTERY_CONTROLLER = new PassiveBatteryControllerBlock();
public static final ActiveBatteryControllerBlock ACTIVE_BATTERY_CONTROLLER = new ActiveBatteryControllerBlock();
public static final Item DEFENSIVE_LASER_CORE_ITEM = new Item(new Item.Settings().group(ITEM_GROUP)); public static final ReactorCoreBlock REACTOR_CORE = new ReactorCoreBlock();
public static final DefensiveLaserBlock DEFENSIVE_LASER_BLOCK = new DefensiveLaserBlock(); public static final ReactorInputBlock REACTOR_INPUT = new ReactorInputBlock();
public static final ReactorControllerBlock REACTOR_CONTROLLER = new ReactorControllerBlock();
public static final BlockBreakerBlock BLOCK_BREAKER_BLOCK = new BlockBreakerBlock(); public static final SimpleBlock VERIDIUM_ORE = new SimpleBlock(FabricBlockSettings.of(Material.STONE).requiresTool().strength(3f, 3f));
public static final SimpleBlock VERIDIUM_BLOCK = new VeridiumBlockBlock();
public static final Item VERIDIUM_POWDER_ITEM = new Item(new Item.Settings().group(ITEM_GROUP)); public static final DefensiveLaserBlock DEFENSIVE_LASER = new DefensiveLaserBlock();
public static final BlockBreakerBlock BLOCK_BREAKER = new BlockBreakerBlock();
public static final LightningRodBaseBlock LIGHTNING_ROD_BASE_BLOCK = new LightningRodBaseBlock(); public static final LightningRodBaseBlock LIGHTNING_ROD_BASE = new LightningRodBaseBlock();
public static final LightningRodBlock LIGHTNING_ROD_BLOCK = new LightningRodBlock(); public static final LightningRodBlock LIGHTNING_ROD = new LightningRodBlock();
public static final SpecialRecipeSerializer<DuplicateNetworkChipRecipe> DUPLICATE_NETWORK_CHIP_RECIPE = new SpecialRecipeSerializer<>(DuplicateNetworkChipRecipe::new); public static final ForcefieldBlock FORCEFIELD = new ForcefieldBlock();
public static final ForcefieldProjectorBlock FORCEFIELD_PROJECTOR = new ForcefieldProjectorBlock();
public static final Material FIELD_MATERIAL = new Material.Builder(MaterialColor.CLEAR).replaceable().build(); public static final TractorBeamBlock TRACTOR_BEAM = new TractorBeamBlock();
public static final RepulsorBeamBlock REPULSOR_BEAM = new RepulsorBeamBlock();
public static final TractorBeamProjectorBlock TRACTOR_BEAM_PROJECTOR = new TractorBeamProjectorBlock();
public static final ForcefieldBlock FORCEFIELD_BLOCK = new ForcefieldBlock(); public static final IndustrialLaserBlock INDUSTRIAL_LASER = new IndustrialLaserBlock();
public static final ForcefieldProjectorBlock FORCEFIELD_PROJECTOR_BLOCK = new ForcefieldProjectorBlock(); public static final IndustrialLaserProjectorBlock INDUSTRIAL_LASER_PROJECTOR = new IndustrialLaserProjectorBlock();
public static final TractorBeamBlock TRACTOR_BEAM_BLOCK = new TractorBeamBlock(); public static final CreativeEnergySourceBlock CREATIVE_ENERGY_SOURCE = new CreativeEnergySourceBlock();
public static final RepulsorBeamBlock REPULSOR_BEAM_BLOCK = new RepulsorBeamBlock(); public static final HolographicSkyBlock HOLOGRAPHIC_SKY = new HolographicSkyBlock();
public static final TractorBeamProjectorBlock TRACTOR_BEAM_PROJECTOR_BLOCK = new TractorBeamProjectorBlock(); public static final InfuserBlock INFUSER = new InfuserBlock();
public static final IndustrialLaserBlock INDUSTRIAL_LASER_BLOCK = new IndustrialLaserBlock(); public static final EnergizedObsidianBlock ENERGIZED_OBSIDIAN = new EnergizedObsidianBlock();
public static final IndustrialLaserProjectorBlock INDUSTRIAL_LASER_PROJECTOR_BLOCK = new IndustrialLaserProjectorBlock(); public static final EnergyBeamBlock ENERGY_BEAM = new EnergyBeamBlock();
public static final EnergyPortalBlock ENERGY_PORTAL = new EnergyPortalBlock();
public static final EnergyProjectorBlock ENERGY_PROJECTOR = new EnergyProjectorBlock();
private static final Identifier BEEP_SOUND_ID = new Identifier(NAMESPACE, "beep"); public static final PhaseShifterBlock PHASE_SHIFTER = new PhaseShifterBlock();
private static final SoundEvent BEEP_SOUND_EVENT = new SoundEvent(BEEP_SOUND_ID); }
public static final CreativeEnergySourceBlock CREATIVE_ENERGY_SOURCE_BLOCK = new CreativeEnergySourceBlock(); public static final class Extras {
public static final SpecialRecipeSerializer<DuplicateNetworkChipRecipe> DUPLICATE_NETWORK_CHIP_RECIPE = new SpecialRecipeSerializer<>(DuplicateNetworkChipRecipe::new);
public static final HolographicSkyBlock HOLOGRAPHIC_SKY_BLOCK = new HolographicSkyBlock(); public static final Material FIELD_MATERIAL = new Material.Builder(MaterialColor.CLEAR).replaceable().build();
public static final InfuserBlock INFUSER_BLOCK = new InfuserBlock(); private static final Identifier BEEP_SOUND_ID = new Identifier(NAMESPACE, "beep");
private static final SoundEvent BEEP_SOUND_EVENT = new SoundEvent(BEEP_SOUND_ID);
public static final EnergizedObsidianBlock ENERGIZED_OBSIDIAN_BLOCK = new EnergizedObsidianBlock(); public static void playBeep(World world, BlockPos pos) {
public static final EnergyBeamBlock ENERGY_BEAM_BLOCK = new EnergyBeamBlock(); if (!world.isClient()) {
public static final EnergyPortalBlock ENERGY_PORTAL_BLOCK = new EnergyPortalBlock(); world.playSound(null, pos, BEEP_SOUND_EVENT, SoundCategory.BLOCKS, 0.3f, 1f);
public static final EnergyProjectorBlock ENERGY_PROJECTOR_BLOCK = new EnergyProjectorBlock(); }
public static final Item VERIDIUM_ORB_ITEM = new Item(new Item.Settings().group(ITEM_GROUP).rarity(Rarity.UNCOMMON)); }
}
@Override @Override
public void onInitialize() { public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_ingot"), VERIDIUM_INGOT_ITEM); Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_ingot"), Items.VERIDIUM_INGOT);
VERIDIUM_ORE_BLOCK.register("veridium_ore"); Blocks.VERIDIUM_ORE.register("veridium_ore");
VERIDIUM_BLOCK_BLOCK.register("veridium_block"); Blocks.VERIDIUM_BLOCK.register("veridium_block");
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(NAMESPACE, "veridium_ore"), VERIDIUM_ORE_FEATURE); CustomFeatures.register();
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_powder"), VERIDIUM_POWDER_ITEM); Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_powder"), Items.VERIDIUM_POWDER);
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_orb"), VERIDIUM_ORB_ITEM); Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_orb"), Items.VERIDIUM_ORB);
NETWORK_CHIP_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), new NetworkChipItem()); Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), Items.NETWORK_CHIP_ITEM);
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "multimeter"), MULTIMETER_ITEM); Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "multimeter"), Items.MULTIMETER);
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "circuit_board"), CIRCUIT_BOARD_ITEM); Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "circuit_board"), Items.CIRCUIT_BOARD);
ENERGON_LIGHT_BLOCK.register("energon_light"); Blocks.ENERGON_LIGHT.register("energon_light");
SOLAR_PANEL_BLOCK.register("solar_panel"); Blocks.SOLAR_PANEL.register("solar_panel");
SWITCH_BLOCk.register("switch"); Blocks.SWITCH.register("switch");
THERMAL_CASING_BLOCK.register("thermal_casing"); Blocks.THERMAL_CASING.register("thermal_casing");
THERMAL_GLASS_BLOCK.register("thermal_glass"); Blocks.THERMAL_GLASS.register("thermal_glass");
BATTERY_CORE_BLOCk.register("battery_core"); Blocks.BATTERY_CORE.register("battery_core");
PASSIVE_BATTERY_CONTROLLER_BLOCk.register("passive_battery_controller"); Blocks.PASSIVE_BATTERY_CONTROLLER.register("passive_battery_controller");
ACTIVE_BATTERY_CONTROLLER_BLOCK.register("active_battery_controller"); Blocks.ACTIVE_BATTERY_CONTROLLER.register("active_battery_controller");
REACTOR_CORE_BLOCK.register("reactor_core"); Blocks.REACTOR_CORE.register("reactor_core");
REACTOR_INPUT_BLOCK.register("reactor_input"); Blocks.REACTOR_INPUT.register("reactor_input");
REACTOR_CONTROLLER_BLOCK.register("reactor_controller"); Blocks.REACTOR_CONTROLLER.register("reactor_controller");
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "defensive_laser_core"), DEFENSIVE_LASER_CORE_ITEM); Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "defensive_laser_core"), Items.DEFENSIVE_LASER_CORE);
DEFENSIVE_LASER_BLOCK.register("defensive_laser"); Blocks.DEFENSIVE_LASER.register("defensive_laser");
StructureGeneratorBlock.register(); StructureGeneratorBlock.registerBlocks();
BLOCK_BREAKER_BLOCK.register("block_breaker"); Blocks.BLOCK_BREAKER.register("block_breaker");
CustomPotions.register(); CustomPotions.register();
LIGHTNING_ROD_BASE_BLOCK.register("lightning_rod_base"); Blocks.LIGHTNING_ROD_BASE.register("lightning_rod_base");
LIGHTNING_ROD_BLOCK.register("lightning_rod"); Blocks.LIGHTNING_ROD.register("lightning_rod");
Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "duplicate_network_chip"), DUPLICATE_NETWORK_CHIP_RECIPE); Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "duplicate_network_chip"), Extras.DUPLICATE_NETWORK_CHIP_RECIPE);
FORCEFIELD_BLOCK.register("forcefield"); Blocks.FORCEFIELD.register("forcefield");
FORCEFIELD_PROJECTOR_BLOCK.register("forcefield_projector"); Blocks.FORCEFIELD_PROJECTOR.register("forcefield_projector");
TRACTOR_BEAM_BLOCK.register("tractor_beam"); Blocks.TRACTOR_BEAM.register("tractor_beam");
REPULSOR_BEAM_BLOCK.register("repulsor_beam"); Blocks.REPULSOR_BEAM.register("repulsor_beam");
TRACTOR_BEAM_PROJECTOR_BLOCK.register("tractor_beam_projector"); Blocks.TRACTOR_BEAM_PROJECTOR.register("tractor_beam_projector");
INDUSTRIAL_LASER_BLOCK.register("industrial_laser"); Blocks.INDUSTRIAL_LASER.register("industrial_laser");
INDUSTRIAL_LASER_PROJECTOR_BLOCK.register("industrial_laser_projector"); Blocks.INDUSTRIAL_LASER_PROJECTOR.register("industrial_laser_projector");
Registry.register(Registry.SOUND_EVENT, BEEP_SOUND_ID, BEEP_SOUND_EVENT); Registry.register(Registry.SOUND_EVENT, Extras.BEEP_SOUND_ID, Extras.BEEP_SOUND_EVENT);
CREATIVE_ENERGY_SOURCE_BLOCK.register("creative_energy_source"); Blocks.CREATIVE_ENERGY_SOURCE.register("creative_energy_source");
HOLOGRAPHIC_SKY_BLOCK.register("holographic_sky"); Blocks.HOLOGRAPHIC_SKY.register("holographic_sky");
INFUSER_BLOCK.register("infuser"); Blocks.INFUSER.register("infuser");
ENERGIZED_OBSIDIAN_BLOCK.register("energized_obsidian"); Blocks.ENERGIZED_OBSIDIAN.register("energized_obsidian");
ENERGY_BEAM_BLOCK.register("energy_beam"); Blocks.ENERGY_BEAM.register("energy_beam");
ENERGY_PORTAL_BLOCK.register("energy_portal"); Blocks.ENERGY_PORTAL.register("energy_portal");
ENERGY_PROJECTOR_BLOCK.register("energy_projector"); Blocks.ENERGY_PROJECTOR.register("energy_projector");
}
public static void playBeep(World world, BlockPos pos) { Blocks.PHASE_SHIFTER.register("phase_shifter");
if (!world.isClient()) {
world.playSound(null, pos, BEEP_SOUND_EVENT, SoundCategory.BLOCKS, 0.3f, 1f);
}
} }
} }

View File

@ -53,7 +53,7 @@ public class SimpleBlock extends Block {
@SuppressWarnings("SameReturnValue") @SuppressWarnings("SameReturnValue")
@ApiStatus.OverrideOnly @ApiStatus.OverrideOnly
protected ItemGroup getItemGroup() { protected ItemGroup getItemGroup() {
return EnergonRelics.ITEM_GROUP; return EnergonRelics.Items.ITEM_GROUP;
} }
/** /**

View File

@ -1,17 +1,25 @@
package com.thebrokenrail.energonrelics.api.block; package com.thebrokenrail.energonrelics.api.block;
import net.minecraft.block.BlockEntityProvider; import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.ApiStatus;
import java.util.function.Function; import java.util.function.Function;
/** /**
* Simple Block With Entity * Simple Block With Entity
*/ */
@SuppressWarnings("deprecation")
public abstract class SimpleBlockWithEntity extends SimpleBlock implements BlockEntityProvider { public abstract class SimpleBlockWithEntity extends SimpleBlock implements BlockEntityProvider {
protected BlockEntityType<BlockEntity> type; protected BlockEntityType<BlockEntity> type;
@ -35,4 +43,35 @@ public abstract class SimpleBlockWithEntity extends SimpleBlock implements Block
public BlockEntity createBlockEntity(BlockView world) { public BlockEntity createBlockEntity(BlockView world) {
return getFactory().apply(type); return getFactory().apply(type);
} }
/**
* Does This Block's Block Entity Have An Inventory
* @return Has Inventory
*/
@ApiStatus.OverrideOnly
protected boolean hasInventory() {
return false;
}
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (state.getBlock() != newState.getBlock() && hasInventory()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof Inventory) {
ItemScatterer.spawn(world, pos, (Inventory) blockEntity);
world.updateComparators(pos, this);
}
}
super.onStateReplaced(state, world, pos, newState, moved);
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return hasInventory();
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return hasInventory() ? ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos)) : 0;
}
} }

View File

@ -60,13 +60,13 @@ public abstract class EnergyBlock extends SimpleBlockWithEntity {
BlockEntity entity = world.getBlockEntity(pos); BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof EnergyProviderBlockEntity && ((EnergyProviderBlockEntity) entity).isEnergyProvider()) { if (entity instanceof EnergyProviderBlockEntity && ((EnergyProviderBlockEntity) entity).isEnergyProvider()) {
ItemStack stack = player.getStackInHand(hand); ItemStack stack = player.getStackInHand(hand);
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) { if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
if (!((EnergyProviderBlockEntity) entity).hasStack()) { if (!((EnergyProviderBlockEntity) entity).hasStack()) {
if (!world.isClient()) { if (!world.isClient()) {
((EnergyProviderBlockEntity) entity).placeStack(stack, world); ((EnergyProviderBlockEntity) entity).placeStack(stack, world);
stack.setCount(0); stack.setCount(0);
} }
EnergonRelics.playBeep(world, pos); EnergonRelics.Extras.playBeep(world, pos);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {
return ActionResult.FAIL; return ActionResult.FAIL;
@ -77,7 +77,7 @@ public abstract class EnergyBlock extends SimpleBlockWithEntity {
ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack(world); ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack(world);
player.setStackInHand(hand, newStack); player.setStackInHand(hand, newStack);
} }
EnergonRelics.playBeep(world, pos); EnergonRelics.Extras.playBeep(world, pos);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {
return ActionResult.FAIL; return ActionResult.FAIL;

View File

@ -54,7 +54,7 @@ public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntit
*/ */
@ApiStatus.Internal @ApiStatus.Internal
public final boolean isNetwork(int network) { public final boolean isNetwork(int network) {
return isEnergyProvider() && EnergonRelics.NETWORK_CHIP_ITEM.getID(stack) == network; return isEnergyProvider() && EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack) == network;
} }
/** /**
@ -123,9 +123,9 @@ public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntit
@Override @Override
public List<EnergyTickable> startTick() { public List<EnergyTickable> startTick() {
if (isEnergyProvider() && stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) { if (isEnergyProvider() && stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
NetworkComponent component = NetworkComponent.getInstance((ServerWorld) Objects.requireNonNull(getWorld())); NetworkComponent component = NetworkComponent.getInstance((ServerWorld) Objects.requireNonNull(getWorld()));
List<BlockPosWithDimension> sources = component.getSourcesPos(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack)); List<BlockPosWithDimension> sources = component.getSourcesPos(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack));
if (!sources.contains(new BlockPosWithDimension(getPos(), getWorld().getRegistryKey()))) { if (!sources.contains(new BlockPosWithDimension(getPos(), getWorld().getRegistryKey()))) {
takeStack(getWorld()); takeStack(getWorld());
} }
@ -145,9 +145,9 @@ public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntit
NetworkComponent component = NetworkComponent.getInstance(serverWorld); NetworkComponent component = NetworkComponent.getInstance(serverWorld);
BlockPosWithDimension newPos = new BlockPosWithDimension(pos, world.getRegistryKey()); BlockPosWithDimension newPos = new BlockPosWithDimension(pos, world.getRegistryKey());
if (remove) { if (remove) {
component.removeSource(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack), newPos); component.removeSource(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack), newPos);
} else { } else {
component.addSource(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack), newPos); component.addSource(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack), newPos);
} }
} }

View File

@ -51,7 +51,11 @@ public abstract class EnergyReceiverBlockEntity extends EnergyProviderBlockEntit
if (providers.size() > 0) { if (providers.size() > 0) {
action.expandPayments(providers.size()); action.expandPayments(providers.size());
for (EnergyProviderBlockEntity provider : providers) { for (EnergyProviderBlockEntity provider : providers) {
provider.addPropagatedAction(action); if (action.amountOwed() > 0) {
provider.addPropagatedAction(action);
} else {
action.pay(0);
}
} }
} else { } else {
action.pay(0); action.pay(0);

View File

@ -14,13 +14,17 @@ public interface EnergyTickable {
*/ */
@ApiStatus.OverrideOnly @ApiStatus.OverrideOnly
List<EnergyTickable> startTick(); List<EnergyTickable> startTick();
/** /**
* Logic Tick * Logic Tick
*/ */
@ApiStatus.OverrideOnly @ApiStatus.OverrideOnly
void logicTick(); void logicTick();
/** /**
* Get ID * Get ID
*
* Used By The Debug Profiler
* @return ID * @return ID
*/ */
@ApiStatus.OverrideOnly @ApiStatus.OverrideOnly

View File

@ -14,14 +14,25 @@ import java.util.Objects;
/** /**
* Energy Ticker * Energy Ticker
*/ */
@ApiStatus.Internal public final class EnergyTicker {
public class EnergyTicker {
private static final List<EnergyTickable> scheduled = new ArrayList<>(); private static final List<EnergyTickable> scheduled = new ArrayList<>();
private static List<EnergyTickable> allLoaded = Collections.emptyList();
/**
* Get All Loaded Energy Tickers
*
* Only Usable In {@link EnergyTickable#logicTick()}
* @return List Of All Loaded Energy Tickers
*/
public static List<EnergyTickable> getAllLoaded() {
return allLoaded;
}
/** /**
* Schedule For Next Energy Tick * Schedule For Next Energy Tick
* @param tickable Object To Tick * @param tickable Object To Tick
*/ */
@ApiStatus.Internal
public static void schedule(EnergyTickable tickable) { public static void schedule(EnergyTickable tickable) {
scheduled.add(tickable); scheduled.add(tickable);
} }
@ -30,12 +41,15 @@ public class EnergyTicker {
* Tick Energy * Tick Energy
* @param world World * @param world World
*/ */
@ApiStatus.Internal
public static void tick(World world) { public static void tick(World world) {
if (Objects.requireNonNull(world.getServer()).getThread() == Thread.currentThread()) { if (Objects.requireNonNull(world.getServer()).getThread() == Thread.currentThread()) {
world.getProfiler().push(EnergonRelics.NAMESPACE); world.getProfiler().push(EnergonRelics.NAMESPACE);
NetworkComponent.getInstance((ServerWorld) world).clearCache(); NetworkComponent.getInstance((ServerWorld) world).clearCache();
world.getProfiler().push("startTick");
List<EnergyTickable> started = new ArrayList<>(); List<EnergyTickable> started = new ArrayList<>();
List<EnergyTickable> temp = new ArrayList<>(scheduled); List<EnergyTickable> temp = new ArrayList<>(scheduled);
@ -43,7 +57,7 @@ public class EnergyTicker {
while (!temp.isEmpty()) { while (!temp.isEmpty()) {
for (EnergyTickable tickable : temp) { for (EnergyTickable tickable : temp) {
if (!started.contains(tickable)) { if (!started.contains(tickable)) {
world.getProfiler().push(() -> tickable.getID() + " startTick"); world.getProfiler().push(tickable::getID);
temp2.addAll(tickable.startTick()); temp2.addAll(tickable.startTick());
started.add(tickable); started.add(tickable);
@ -51,14 +65,25 @@ public class EnergyTicker {
world.getProfiler().pop(); world.getProfiler().pop();
} }
} }
temp.clear();
temp.addAll(temp2); List<EnergyTickable> temp3 = temp;
temp = temp2;
temp2 = temp3;
temp2.clear(); temp2.clear();
} }
allLoaded = Collections.unmodifiableList(started);
world.getProfiler().push("shuffle");
Collections.shuffle(started, world.random); Collections.shuffle(started, world.random);
world.getProfiler().pop();
world.getProfiler().pop();
world.getProfiler().push("logicTick");
for (EnergyTickable tickable : started) { for (EnergyTickable tickable : started) {
world.getProfiler().push(() -> tickable.getID() + " logicTick"); world.getProfiler().push(tickable::getID);
tickable.logicTick(); tickable.logicTick();
@ -66,7 +91,11 @@ public class EnergyTicker {
} }
world.getProfiler().pop(); world.getProfiler().pop();
world.getProfiler().pop();
} }
scheduled.clear(); scheduled.clear();
allLoaded = Collections.emptyList();
} }
} }

View File

@ -0,0 +1,14 @@
package com.thebrokenrail.energonrelics.api.item;
import net.minecraft.text.MutableText;
/**
* Implement To Provide Extra Information In Multimeter Output
*/
public interface MultimeterExtra {
/**
* Get Extra Information
* @return Text
*/
MutableText getExtra();
}

View File

@ -0,0 +1,131 @@
package com.thebrokenrail.energonrelics.block;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock;
import com.thebrokenrail.energonrelics.block.entity.shifter.PhaseShifterBlockEntity;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.DyeItem;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.HopperScreenHandler;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Random;
import java.util.function.Function;
@SuppressWarnings("deprecation")
public class PhaseShifterBlock extends EnergyBlock {
public static final BooleanProperty POWERED = Properties.POWERED;
public static final BooleanProperty IS_OUTPUT = BooleanProperty.of("is_output");
public static final EnumProperty<DyeColor> COLOR = EnumProperty.of("color", DyeColor.class);
public PhaseShifterBlock() {
super(FabricBlockSettings.copy(Blocks.IRON_BLOCK).lightLevel(state -> state.get(POWERED) ? 13 : 0).emissiveLighting((state, world, pos) -> state.get(POWERED)));
setDefaultState(getDefaultState().with(POWERED, false).with(IS_OUTPUT, false).with(COLOR, DyeColor.WHITE));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(POWERED, IS_OUTPUT, COLOR);
}
@Override
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
return PhaseShifterBlockEntity::new;
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return getDefaultState().with(IS_OUTPUT, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
}
@Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (!world.isClient()) {
boolean bl = state.get(IS_OUTPUT);
if (bl != world.isReceivingRedstonePower(pos)) {
if (bl) {
world.getBlockTickScheduler().schedule(pos, this, 4);
} else {
world.setBlockState(pos, state.cycle(IS_OUTPUT), 2);
}
}
}
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (state.get(IS_OUTPUT) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, state.cycle(IS_OUTPUT), 2);
}
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
if (result != ActionResult.PASS) {
return result;
} else {
BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof Inventory) {
if (!world.isClient()) {
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inv, player2) -> new HopperScreenHandler(i, inv, (Inventory) entity), new TranslatableText("block." + EnergonRelics.NAMESPACE + ".phase_shifter")));
}
return ActionResult.SUCCESS;
} else {
return ActionResult.FAIL;
}
}
}
@Override
public void register(Identifier id) {
super.register(id);
UseBlockCallback.EVENT.register((player, world, hand, hit) -> {
if (!player.isSpectator() && player.shouldCancelInteraction()) {
BlockState state = world.getBlockState(hit.getBlockPos());
if (state.getBlock() == PhaseShifterBlock.this) {
ItemStack stack = player.getStackInHand(hand);
if (stack.getItem() instanceof DyeItem) {
DyeColor newColor = ((DyeItem) stack.getItem()).getColor();
if (state.get(PhaseShifterBlock.COLOR) != newColor) {
world.setBlockState(hit.getBlockPos(), state.with(PhaseShifterBlock.COLOR, newColor));
if (!player.isCreative()) {
stack.decrement(1);
}
return ActionResult.SUCCESS;
}
}
}
}
return ActionResult.PASS;
});
}
@Override
protected boolean hasInventory() {
return true;
}
}

View File

@ -22,26 +22,27 @@ import java.util.function.Function;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class SwitchBlock extends EnergyBlock { public class SwitchBlock extends EnergyBlock {
public static final BooleanProperty POWERED = Properties.POWERED; public static final BooleanProperty POWERED = Properties.POWERED;
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
public SwitchBlock() { public SwitchBlock() {
super(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1.5f, 6.0f)); super(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1.5f, 6.0f));
setDefaultState(getDefaultState().with(POWERED, false)); setDefaultState(getDefaultState().with(POWERED, false).with(ACTIVE, false));
} }
@Override @Override
public BlockState getPlacementState(ItemPlacementContext ctx) { public BlockState getPlacementState(ItemPlacementContext ctx) {
return getDefaultState().with(POWERED, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos())); return getDefaultState().with(ACTIVE, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
} }
@Override @Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) { public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (!world.isClient()) { if (!world.isClient()) {
boolean bl = state.get(POWERED); boolean bl = state.get(ACTIVE);
if (bl != world.isReceivingRedstonePower(pos)) { if (bl != world.isReceivingRedstonePower(pos)) {
if (bl) { if (bl) {
world.getBlockTickScheduler().schedule(pos, this, 4); world.getBlockTickScheduler().schedule(pos, this, 4);
} else { } else {
world.setBlockState(pos, state.cycle(POWERED), 2); world.setBlockState(pos, state.cycle(ACTIVE), 2);
} }
} }
} }
@ -49,14 +50,14 @@ public class SwitchBlock extends EnergyBlock {
@Override @Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (state.get(POWERED) && !world.isReceivingRedstonePower(pos)) { if (state.get(ACTIVE) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, state.cycle(POWERED), 2); world.setBlockState(pos, state.cycle(ACTIVE), 2);
} }
} }
@Override @Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(POWERED); builder.add(POWERED, ACTIVE);
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import com.thebrokenrail.energonrelics.api.energy.Action;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock; import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
import com.thebrokenrail.energonrelics.mixin.DamageSourceAccessor;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -49,7 +48,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
if (hasWorld()) { if (hasWorld()) {
return super.getCachedState(); return super.getCachedState();
} else { } else {
return EnergonRelics.DEFENSIVE_LASER_BLOCK.getDefaultState(); return EnergonRelics.Blocks.DEFENSIVE_LASER.getDefaultState();
} }
} }
@ -180,7 +179,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
return new ItemEntity(getWorld(), posVec.getX(), posVec.getY(), posVec.getZ()); return new ItemEntity(getWorld(), posVec.getX(), posVec.getY(), posVec.getZ());
} }
private static final DamageSource DAMAGE_SOURCE = DamageSourceAccessor.createDamageSource(EnergonRelics.NAMESPACE + ".defensive_laser").setScaledWithDifficulty().setExplosive(); private static final DamageSource DAMAGE_SOURCE = new DamageSource(EnergonRelics.NAMESPACE + ".defensive_laser").setScaledWithDifficulty().setExplosive();
private void fire(World world, BlockPos pos) { private void fire(World world, BlockPos pos) {
List<LivingEntity> entities = getEntities(entity -> true); List<LivingEntity> entities = getEntities(entity -> true);

View File

@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTickable; import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTickable;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.LightType; import net.minecraft.world.LightType;
import java.util.List; import java.util.List;
@ -25,7 +26,7 @@ public class SolarPanelBlockEntity extends EnergyGeneratorBlockEntity {
for (Direction side : Direction.values()) { for (Direction side : Direction.values()) {
light = Math.max(light, getLight(side)); light = Math.max(light, getLight(side));
} }
return light; return (int) (((float) light) * Math.max(0, MathHelper.cos(Objects.requireNonNull(getWorld()).getSkyAngleRadians(1f))));
} }
@Override @Override

View File

@ -3,8 +3,11 @@ package com.thebrokenrail.energonrelics.block.entity;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity; import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.energy.Action; import com.thebrokenrail.energonrelics.api.energy.Action;
import com.thebrokenrail.energonrelics.block.SwitchBlock; import com.thebrokenrail.energonrelics.block.SwitchBlock;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import java.util.Objects;
public class SwitchBlockEntity extends EnergyReceiverBlockEntity { public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
public SwitchBlockEntity(BlockEntityType<?> type) { public SwitchBlockEntity(BlockEntityType<?> type) {
super(type); super(type);
@ -12,6 +15,11 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
@Override @Override
protected void energyTick() { protected void energyTick() {
if (getCachedState().get(SwitchBlock.ACTIVE)) {
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.SWITCH_ENERGY_REQUIRED, SwitchBlock.POWERED, true, false));
} else if (getCachedState().get(SwitchBlock.POWERED)) {
Objects.requireNonNull(getWorld()).setBlockState(getPos(), getCachedState().with(SwitchBlock.POWERED, false));
}
} }
@Override @Override
@ -31,6 +39,6 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
} }
private boolean isActive() { private boolean isActive() {
return getCachedState().get(SwitchBlock.POWERED); return getCachedState().get(SwitchBlock.ACTIVE) && getCachedState().get(SwitchBlock.POWERED);
} }
} }

View File

@ -63,7 +63,7 @@ public class PassiveBatteryControllerBlockEntity extends EnergyReceiverBlockEnti
} }
public static boolean isInvalidBlock(BlockState block) { public static boolean isInvalidBlock(BlockState block) {
return !block.isOf(EnergonRelics.THERMAL_GLASS_BLOCK) && !block.isOf(EnergonRelics.THERMAL_CASING_BLOCK); return !block.isOf(EnergonRelics.Blocks.THERMAL_GLASS) && !block.isOf(EnergonRelics.Blocks.THERMAL_CASING);
} }
@Override @Override

View File

@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.entity.forcefield.FieldProjectorBlo
import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock; import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.potion.CustomPotions; import com.thebrokenrail.energonrelics.potion.CustomPotions;
import com.thebrokenrail.energonrelics.registry.laser.IndustrialLaserRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -20,14 +21,14 @@ import net.minecraft.world.explosion.Explosion;
import java.util.Objects; import java.util.Objects;
public class IndustrialLaserBlockEntity extends FieldProjectorBlockEntity { public class IndustrialLaserProjectorBlockEntity extends FieldProjectorBlockEntity {
private BlockPos targetPos; private BlockPos targetPos;
private BlockState targetState; private BlockState targetState;
private int progress = 0; private int progress = 0;
public IndustrialLaserBlockEntity(BlockEntityType<?> type) { public IndustrialLaserProjectorBlockEntity(BlockEntityType<?> type) {
super(type, state -> EnergonRelics.INDUSTRIAL_LASER_BLOCK); super(type, state -> EnergonRelics.Blocks.INDUSTRIAL_LASER);
} }
@Override @Override
@ -55,16 +56,17 @@ public class IndustrialLaserBlockEntity extends FieldProjectorBlockEntity {
TntBlock.primeTnt(getWorld(), targetPos); TntBlock.primeTnt(getWorld(), targetPos);
getWorld().setBlockState(targetPos, Blocks.AIR.getDefaultState()); getWorld().setBlockState(targetPos, Blocks.AIR.getDefaultState());
progress = 0; if (progress != 0) {
progress = 0;
markDirty(); markDirty();
}
} else if (IndustrialLaserRegistry.has(targetState.getBlock())) { } else if (IndustrialLaserRegistry.has(targetState.getBlock())) {
if (progress >= HardcodedConfig.INDUSTRIAL_LASER_BEAM_TIME) { if (progress >= HardcodedConfig.INDUSTRIAL_LASER_BEAM_TIME) {
getWorld().createExplosion(null, targetPos.getX() + 0.5d, targetPos.getY() + 0.5d, targetPos.getZ() + 0.5d, 0.5f, Explosion.DestructionType.NONE); getWorld().createExplosion(null, targetPos.getX() + 0.5d, targetPos.getY() + 0.5d, targetPos.getZ() + 0.5d, 0.5f, Explosion.DestructionType.NONE);
Block.dropStack(getWorld(), targetPos, IndustrialLaserRegistry.get(targetState.getBlock(), getWorld().random)); Block.dropStack(getWorld(), targetPos, IndustrialLaserRegistry.get(targetState.getBlock(), getWorld().random));
getWorld().breakBlock(targetPos, false); getWorld().breakBlock(targetPos, false);
if (targetState.getBlock() == EnergonRelics.VERIDIUM_ORE_BLOCK) { if (targetState.getBlock() == EnergonRelics.Blocks.VERIDIUM_ORE) {
AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(getWorld(), targetPos.getX() + 0.5d, targetPos.getY() + 0.5d, targetPos.getZ() + 0.5d); AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(getWorld(), targetPos.getX() + 0.5d, targetPos.getY() + 0.5d, targetPos.getZ() + 0.5d);
areaEffectCloudEntity.setRadius(1.2f); areaEffectCloudEntity.setRadius(1.2f);
areaEffectCloudEntity.setRadiusOnUse(-0.5f); areaEffectCloudEntity.setRadiusOnUse(-0.5f);

View File

@ -3,9 +3,9 @@ package com.thebrokenrail.energonrelics.block.entity.infuser;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity; import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.energy.Action; import com.thebrokenrail.energonrelics.api.energy.Action;
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
import com.thebrokenrail.energonrelics.block.InfuserBlock; import com.thebrokenrail.energonrelics.block.InfuserBlock;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.item.MultimeterItem;
import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserAction; import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserAction;
import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserEntry; import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserEntry;
import com.thebrokenrail.energonrelics.registry.infuser.InfuserRegistry; import com.thebrokenrail.energonrelics.registry.infuser.InfuserRegistry;
@ -20,7 +20,7 @@ import net.minecraft.util.Formatting;
import java.util.Objects; import java.util.Objects;
public class InfuserBlockEntity extends EnergyReceiverBlockEntity implements MultimeterItem.MultimeterExtra { public class InfuserBlockEntity extends EnergyReceiverBlockEntity implements MultimeterExtra {
public InfuserBlockEntity(BlockEntityType<?> type) { public InfuserBlockEntity(BlockEntityType<?> type) {
super(type); super(type);
} }

View File

@ -18,7 +18,7 @@ public class EnergyProjectorBlockEntity extends FieldProjectorBlockEntity {
private BlockState targetState; private BlockState targetState;
public EnergyProjectorBlockEntity(BlockEntityType<?> type) { public EnergyProjectorBlockEntity(BlockEntityType<?> type) {
super(type, state -> EnergonRelics.ENERGY_BEAM_BLOCK); super(type, state -> EnergonRelics.Blocks.ENERGY_BEAM);
} }
@Override @Override
@ -44,10 +44,10 @@ public class EnergyProjectorBlockEntity extends FieldProjectorBlockEntity {
boolean isObsidian; boolean isObsidian;
if (targetState.getBlock() == Blocks.OBSIDIAN) { if (targetState.getBlock() == Blocks.OBSIDIAN) {
isObsidian = true; isObsidian = true;
targetState = EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK.getDefaultState(); targetState = EnergonRelics.Blocks.ENERGIZED_OBSIDIAN.getDefaultState();
getWorld().setBlockState(targetPos, targetState); getWorld().setBlockState(targetPos, targetState);
} else { } else {
isObsidian = targetState.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK; isObsidian = targetState.getBlock() == EnergonRelics.Blocks.ENERGIZED_OBSIDIAN;
} }
if (isObsidian) { if (isObsidian) {

View File

@ -17,7 +17,7 @@ public class ReactorInputBlockEntity extends BlockEntity implements Inventory {
super(type); super(type);
} }
private final int INVENTORY_SIZE = 5; public final static int INVENTORY_SIZE = 5;
private final DefaultedList<ItemStack> inv = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY); private final DefaultedList<ItemStack> inv = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);

View File

@ -0,0 +1,267 @@
package com.thebrokenrail.energonrelics.block.entity.shifter;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.energy.Action;
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTickable;
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTicker;
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
import com.thebrokenrail.energonrelics.block.entity.reactor.ReactorInputBlockEntity;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.util.WeightedList;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.collection.DefaultedList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class PhaseShifterBlockEntity extends EnergyReceiverBlockEntity implements Inventory, MultimeterExtra {
private final static int INVENTORY_SIZE = ReactorInputBlockEntity.INVENTORY_SIZE;
private final DefaultedList<ItemStack> inv = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);
private int cooldown = 0;
public PhaseShifterBlockEntity(BlockEntityType<?> type) {
super(type);
}
@Override
public int size() {
return inv.size();
}
@Override
public boolean isEmpty() {
boolean empty = false;
for (ItemStack stack : inv) {
if (stack.isEmpty()) {
empty = true;
break;
}
}
return empty;
}
@Override
public ItemStack getStack(int slot) {
return inv.get(slot);
}
@Override
public ItemStack removeStack(int slot, int amount) {
ItemStack stack = Inventories.splitStack(inv, slot, amount);
if (!stack.isEmpty()) {
markDirty();
}
return stack;
}
@Override
public ItemStack removeStack(int slot) {
return Inventories.removeStack(inv, slot);
}
@Override
public void setStack(int slot, ItemStack stack) {
inv.set(slot, stack);
if (stack.getCount() > getMaxCountPerStack()) {
stack.setCount(getMaxCountPerStack());
}
}
@Override
public boolean canPlayerUse(PlayerEntity player) {
if (Objects.requireNonNull(getWorld()).getBlockEntity(getPos()) != this) {
return false;
} else {
return player.squaredDistanceTo((double) getPos().getX() + 0.5D, (double) getPos().getY() + 0.5D, (double) getPos().getZ() + 0.5D) <= 64.0D;
}
}
@Override
public void clear() {
inv.clear();
}
private final List<PhasedItem> phasedItems = new ArrayList<>();
@Override
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
inv.clear();
Inventories.fromTag(tag, inv);
cooldown = tag.getInt("Cooldown");
phasedItems.clear();
Tag list = tag.get("PhasedItems");
if (list instanceof ListTag) {
ListTag itemsTag = (ListTag) list;
for (int i = 0; i < itemsTag.size(); i++) {
phasedItems.add(PhasedItem.fromTag(itemsTag.getCompound(i)));
}
}
}
private int canInsert(ItemStack stack) {
if (stack.getCount() <= getMaxCountPerStack()) {
for (int slot = 0; slot < size(); slot++) {
ItemStack oldStack = getStack(slot);
if (oldStack.isItemEqual(stack)) {
int newCount = oldStack.getCount() + stack.getCount();
if (newCount <= Math.min(oldStack.getMaxCount(), getMaxCountPerStack())) {
return slot;
}
}
}
for (int slot = 0; slot < size(); slot++) {
ItemStack oldStack = getStack(slot);
if (oldStack.isEmpty()) {
return slot;
}
}
}
return -1;
}
private long getCost() {
return getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? HardcodedConfig.PHASE_SHIFTER_OUTPUT_ENERGY_REQUIRED : HardcodedConfig.PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_BASE + (HardcodedConfig.PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_PER_ITEM * phasedItems.size());
}
@Override
protected void energyTick() {
assert getWorld() != null;
addAction(Action.createBlockStatePropertyAction(getCost(), PhaseShifterBlock.POWERED, true, false));
boolean dirty = false;
if (cooldown > 0) {
cooldown--;
dirty = true;
}
if (getCachedState().get(PhaseShifterBlock.POWERED) && !getCachedState().get(PhaseShifterBlock.IS_OUTPUT)) {
List<PhaseShifterBlockEntity> outputs = new ArrayList<>();
for (EnergyTickable tickable : EnergyTicker.getAllLoaded()) {
if (tickable instanceof PhaseShifterBlockEntity && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.IS_OUTPUT) && Objects.requireNonNull(((PhaseShifterBlockEntity) tickable).getWorld()).getRegistryKey() == getWorld().getRegistryKey() && ((PhaseShifterBlockEntity) tickable).cooldown == 0 && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.COLOR) == getCachedState().get(PhaseShifterBlock.COLOR)) {
outputs.add((PhaseShifterBlockEntity) tickable);
}
}
if (phasedItems.size() > 0) {
dirty = true;
}
Iterator<PhasedItem> iterator = phasedItems.iterator();
while (iterator.hasNext()) {
PhasedItem item = iterator.next();
if (item.cooldown > 0) {
item.cooldown--;
} else {
Map<PhaseShifterBlockEntity, Integer> validOutputs = new HashMap<>();
for (PhaseShifterBlockEntity output : outputs) {
int slot = output.canInsert(item.item);
if (slot != -1 && output.getPos().isWithinDistance(getPos(), item.getRange())) {
validOutputs.put(output, slot);
}
}
boolean success = validOutputs.size() > 0 && HardcodedConfig.PHASE_SHIFTER_SUCCESS_CHANCE >= getWorld().random.nextFloat();
if (success) {
WeightedList<PhaseShifterBlockEntity> weightedList = new WeightedList<>();
for (PhaseShifterBlockEntity output : validOutputs.keySet()) {
weightedList.add(1, output);
}
PhaseShifterBlockEntity output = weightedList.pick(getWorld().random);
int slot = validOutputs.get(output);
ItemStack stack = item.item.copy();
stack.increment(output.getStack(slot).getCount());
output.setStack(slot, stack);
output.resetCooldown();
output.markDirty();
iterator.remove();
} else {
item.roll++;
item.cooldown = HardcodedConfig.PHASE_SHIFTER_INPUT_ROLL_COOLDOWN;
}
}
}
if (cooldown == 0) {
ItemStack next = ItemStack.EMPTY;
for (int slot = 0; slot < size(); slot++) {
ItemStack stack = getStack(slot);
if (!stack.isEmpty()) {
next = stack.split(1);
}
}
if (!next.isEmpty()) {
phasedItems.add(new PhasedItem(next));
resetCooldown();
dirty = true;
}
}
} else if (phasedItems.size() > 0) {
phasedItems.clear();
dirty = true;
}
if (dirty) {
markDirty();
}
}
private void resetCooldown() {
cooldown = getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? HardcodedConfig.PHASE_SHIFTER_OUTPUT_COOLDOWN : HardcodedConfig.PHASE_SHIFTER_INPUT_COOLDOWN;
}
@Override
public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag);
Inventories.toTag(tag, inv);
tag.putInt("Cooldown", cooldown);
ListTag itemsTag = new ListTag();
for (PhasedItem item : phasedItems) {
itemsTag.add(item.toTag());
}
tag.put("PhasedItems", itemsTag);
return tag;
}
@Override
public MutableText getExtra() {
return getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? null : new TranslatableText("text." + EnergonRelics.NAMESPACE + ".phase_shifter_extra", new LiteralText(String.valueOf(phasedItems.size())).formatted(Formatting.WHITE));
}
}

View File

@ -0,0 +1,34 @@
package com.thebrokenrail.energonrelics.block.entity.shifter;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
class PhasedItem {
final ItemStack item;
int cooldown = 0;
int roll = 0;
PhasedItem(ItemStack item) {
this.item = item;
}
int getRange() {
return HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_BASE + (roll * HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_INCREMENT);
}
CompoundTag toTag() {
CompoundTag tag = new CompoundTag();
tag.put("Item", item.toTag(new CompoundTag()));
tag.putInt("Cooldown", cooldown);
tag.putInt("Roll", roll);
return tag;
}
static PhasedItem fromTag(CompoundTag tag) {
PhasedItem item = new PhasedItem(ItemStack.fromTag(tag.getCompound("Item")));
item.cooldown = tag.getInt("Cooldown");
item.roll = tag.getInt("Roll");
return item;
}
}

View File

@ -20,6 +20,7 @@ public class StructureGeneratorBlockEntity extends BlockEntity {
StructurePart<?> create(World world, Random random, List<StructurePart.Transformation> transformations); StructurePart<?> create(World world, Random random, List<StructurePart.Transformation> transformations);
} }
private boolean hasSeed = false;
private long seed = 0; private long seed = 0;
private boolean generated = false; private boolean generated = false;
@ -31,12 +32,14 @@ public class StructureGeneratorBlockEntity extends BlockEntity {
} }
public void setSeed(long seed) { public void setSeed(long seed) {
hasSeed = true;
this.seed = seed; this.seed = seed;
} }
@Override @Override
public CompoundTag toTag(CompoundTag tag) { public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag); super.toTag(tag);
tag.putBoolean("HasSeed", hasSeed);
tag.putLong("Seed", seed); tag.putLong("Seed", seed);
tag.putBoolean("Generated", generated); tag.putBoolean("Generated", generated);
return tag; return tag;
@ -45,12 +48,17 @@ public class StructureGeneratorBlockEntity extends BlockEntity {
@Override @Override
public void fromTag(BlockState state, CompoundTag tag) { public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag); super.fromTag(state, tag);
hasSeed = tag.getBoolean("HasSeed");
seed = tag.getLong("Seed"); seed = tag.getLong("Seed");
generated = tag.getBoolean("Generated"); generated = tag.getBoolean("Generated");
} }
public void generate() { public void generate() {
if (hasWorld() && !Objects.requireNonNull(getWorld()).isClient() && !generated) { if (hasWorld() && !Objects.requireNonNull(getWorld()).isClient() && !generated) {
if (!hasSeed) {
seed = getWorld().random.nextLong();
}
Direction facing = getCachedState().get(StructureGeneratorBlock.HORIZONTAL_FACING); Direction facing = getCachedState().get(StructureGeneratorBlock.HORIZONTAL_FACING);
generated = true; generated = true;
new StructurePlacer(factory.create(getWorld(), new Random(seed), Collections.singletonList(StructurePart.directionToTransformation(facing)))).place(getWorld(), getPos()); new StructurePlacer(factory.create(getWorld(), new Random(seed), Collections.singletonList(StructurePart.directionToTransformation(facing)))).place(getWorld(), getPos());

View File

@ -11,6 +11,6 @@ public class ForcefieldBlock extends AbstractFieldBlock {
@Override @Override
protected BlockState getProjectorBlockState() { protected BlockState getProjectorBlockState() {
return EnergonRelics.FORCEFIELD_PROJECTOR_BLOCK.getDefaultState(); return EnergonRelics.Blocks.FORCEFIELD_PROJECTOR.getDefaultState();
} }
} }

View File

@ -5,6 +5,6 @@ import com.thebrokenrail.energonrelics.block.forcefield.util.FieldProjectorBlock
public class ForcefieldProjectorBlock extends FieldProjectorBlock { public class ForcefieldProjectorBlock extends FieldProjectorBlock {
public ForcefieldProjectorBlock() { public ForcefieldProjectorBlock() {
super(state -> EnergonRelics.FORCEFIELD_BLOCK); super(state -> EnergonRelics.Blocks.FORCEFIELD);
} }
} }

View File

@ -19,7 +19,7 @@ public class TractorBeamProjectorBlock extends FieldProjectorBlock {
public static final BooleanProperty IS_REPULSOR = BooleanProperty.of("is_repulsor"); public static final BooleanProperty IS_REPULSOR = BooleanProperty.of("is_repulsor");
public TractorBeamProjectorBlock() { public TractorBeamProjectorBlock() {
super(state -> state.get(IS_REPULSOR) ? EnergonRelics.REPULSOR_BEAM_BLOCK : EnergonRelics.TRACTOR_BEAM_BLOCK); super(state -> state.get(IS_REPULSOR) ? EnergonRelics.Blocks.REPULSOR_BEAM : EnergonRelics.Blocks.TRACTOR_BEAM);
setDefaultState(getDefaultState().with(IS_REPULSOR, false)); setDefaultState(getDefaultState().with(IS_REPULSOR, false));
} }

View File

@ -26,7 +26,7 @@ public class IndustrialLaserBlock extends AbstractFieldBlock {
@Override @Override
protected BlockState getProjectorBlockState() { protected BlockState getProjectorBlockState() {
return EnergonRelics.INDUSTRIAL_LASER_PROJECTOR_BLOCK.getDefaultState(); return EnergonRelics.Blocks.INDUSTRIAL_LASER_PROJECTOR.getDefaultState();
} }
private static class IndustrialLaserDamageSource extends DamageSource { private static class IndustrialLaserDamageSource extends DamageSource {
@ -47,7 +47,11 @@ public class IndustrialLaserBlock extends AbstractFieldBlock {
if (entity instanceof CreeperEntity) { if (entity instanceof CreeperEntity) {
((CreeperEntity) entity).ignite(); ((CreeperEntity) entity).ignite();
} else if (entity instanceof LivingEntity) { } else if (entity instanceof LivingEntity) {
entity.damage(DAMAGE_SOURCE, HardcodedConfig.INDUSTRIAL_LASER_BEAM_DAMAGE); if (!entity.isFireImmune()) {
entity.setOnFireFor(8);
entity.damage(DAMAGE_SOURCE, HardcodedConfig.INDUSTRIAL_LASER_BEAM_DAMAGE);
}
} else if (entity instanceof ItemEntity) { } else if (entity instanceof ItemEntity) {
ItemStack stack = ((ItemEntity) entity).getStack(); ItemStack stack = ((ItemEntity) entity).getStack();
if (stack.getItem() == Items.GUNPOWDER) { if (stack.getItem() == Items.GUNPOWDER) {

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.energonrelics.block.forcefield.laser; package com.thebrokenrail.energonrelics.block.forcefield.laser;
import com.thebrokenrail.energonrelics.block.entity.forcefield.laser.IndustrialLaserBlockEntity; import com.thebrokenrail.energonrelics.block.entity.forcefield.laser.IndustrialLaserProjectorBlockEntity;
import com.thebrokenrail.energonrelics.block.forcefield.util.FieldProjectorBlock; import com.thebrokenrail.energonrelics.block.forcefield.util.FieldProjectorBlock;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
@ -14,6 +14,6 @@ public class IndustrialLaserProjectorBlock extends FieldProjectorBlock {
@Override @Override
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() { protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
return IndustrialLaserBlockEntity::new; return IndustrialLaserProjectorBlockEntity::new;
} }
} }

View File

@ -31,7 +31,7 @@ public abstract class AbstractFieldBlock extends SimpleBlock {
public static final DirectionProperty FACING = Properties.FACING; public static final DirectionProperty FACING = Properties.FACING;
public AbstractFieldBlock(boolean hasCollision) { public AbstractFieldBlock(boolean hasCollision) {
super((hasCollision ? FabricBlockSettings.of(EnergonRelics.FIELD_MATERIAL) : FabricBlockSettings.of(EnergonRelics.FIELD_MATERIAL).noCollision()).strength(-1.0F, 3600000.8F).dropsNothing().nonOpaque().lightLevel(4).emissiveLighting((state, world, pos) -> true).nonOpaque().sounds(BlockSoundGroup.GLASS).allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).blockVision((state, world, pos) -> false)); super((hasCollision ? FabricBlockSettings.of(EnergonRelics.Extras.FIELD_MATERIAL) : FabricBlockSettings.of(EnergonRelics.Extras.FIELD_MATERIAL).noCollision()).strength(-1.0F, 3600000.8F).dropsNothing().nonOpaque().lightLevel(4).emissiveLighting((state, world, pos) -> true).nonOpaque().sounds(BlockSoundGroup.GLASS).allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> hasCollision).blockVision((state, world, pos) -> false));
setDefaultState(getDefaultState().with(FACING, Direction.NORTH)); setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
} }

View File

@ -21,7 +21,7 @@ public class BeamBlock extends AbstractFieldBlock {
@Override @Override
protected BlockState getProjectorBlockState() { protected BlockState getProjectorBlockState() {
return EnergonRelics.TRACTOR_BEAM_PROJECTOR_BLOCK.getDefaultState().with(TractorBeamProjectorBlock.IS_REPULSOR, isRepulsor); return EnergonRelics.Blocks.TRACTOR_BEAM_PROJECTOR.getDefaultState().with(TractorBeamProjectorBlock.IS_REPULSOR, isRepulsor);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View File

@ -70,7 +70,7 @@ public class LightningRodBaseBlock extends EnergyBlock {
@Override @Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
boolean valid = true; boolean valid = true;
if (direction == Direction.UP && (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(LightningRodBlock.HALF) != DoubleBlockHalf.LOWER)) { if (direction == Direction.UP && (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD || newState.get(LightningRodBlock.HALF) != DoubleBlockHalf.LOWER)) {
valid = false; valid = false;
} }
@ -85,8 +85,8 @@ public class LightningRodBaseBlock extends EnergyBlock {
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
super.onPlaced(world, pos, state, placer, itemStack); super.onPlaced(world, pos, state, placer, itemStack);
world.setBlockState(pos.up(2), EnergonRelics.LIGHTNING_ROD_BLOCK.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.UPPER)); world.setBlockState(pos.up(2), EnergonRelics.Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.UPPER));
world.setBlockState(pos.up(1), EnergonRelics.LIGHTNING_ROD_BLOCK.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.LOWER)); world.setBlockState(pos.up(1), EnergonRelics.Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.LOWER));
} }
@Override @Override

View File

@ -30,7 +30,7 @@ public class LightningRodBlock extends SimpleBlock {
public static final EnumProperty<DoubleBlockHalf> HALF = Properties.DOUBLE_BLOCK_HALF; public static final EnumProperty<DoubleBlockHalf> HALF = Properties.DOUBLE_BLOCK_HALF;
public LightningRodBlock() { public LightningRodBlock() {
super(FabricBlockSettings.copy(EnergonRelics.LIGHTNING_ROD_BASE_BLOCK).dropsNothing().emissiveLighting((state, world, pos) -> true).lightLevel(state -> 10)); super(FabricBlockSettings.copy(EnergonRelics.Blocks.LIGHTNING_ROD_BASE).dropsNothing().emissiveLighting((state, world, pos) -> true).lightLevel(state -> 10));
setDefaultState(getDefaultState().with(HALF, DoubleBlockHalf.LOWER)); setDefaultState(getDefaultState().with(HALF, DoubleBlockHalf.LOWER));
} }
@ -91,16 +91,16 @@ public class LightningRodBlock extends SimpleBlock {
if (state.get(HALF) == DoubleBlockHalf.LOWER) { if (state.get(HALF) == DoubleBlockHalf.LOWER) {
if (direction == Direction.UP) { if (direction == Direction.UP) {
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(HALF) != DoubleBlockHalf.UPPER) { if (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD || newState.get(HALF) != DoubleBlockHalf.UPPER) {
valid = false; valid = false;
} }
} else if (direction == Direction.DOWN) { } else if (direction == Direction.DOWN) {
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) { if (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD_BASE) {
valid = false; valid = false;
} }
} }
} else if (state.get(HALF) == DoubleBlockHalf.UPPER && direction == Direction.DOWN) { } else if (state.get(HALF) == DoubleBlockHalf.UPPER && direction == Direction.DOWN) {
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(HALF) != DoubleBlockHalf.LOWER) { if (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD || newState.get(HALF) != DoubleBlockHalf.LOWER) {
valid = false; valid = false;
} }
} }
@ -120,7 +120,7 @@ public class LightningRodBlock extends SimpleBlock {
BlockState targetState = world.getBlockState(targetPos); BlockState targetState = world.getBlockState(targetPos);
if (targetState.getBlock() == EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) { if (targetState.getBlock() == EnergonRelics.Blocks.LIGHTNING_ROD_BASE) {
world.breakBlock(targetPos, false, player); world.breakBlock(targetPos, false, player);
} }
} }
@ -130,6 +130,6 @@ public class LightningRodBlock extends SimpleBlock {
@Override @Override
public Item asItem() { public Item asItem() {
return EnergonRelics.LIGHTNING_ROD_BASE_BLOCK.asItem(); return EnergonRelics.Blocks.LIGHTNING_ROD_BASE.asItem();
} }
} }

View File

@ -35,7 +35,7 @@ public class EnergizedObsidianBlock extends SimpleBlock {
private static boolean faces(WorldAccess world, BlockPos targetPos, BlockPos pos) { private static boolean faces(WorldAccess world, BlockPos targetPos, BlockPos pos) {
BlockState state = world.getBlockState(targetPos); BlockState state = world.getBlockState(targetPos);
if ((state.getBlock() == EnergonRelics.ENERGY_BEAM_BLOCK || state.getBlock() == EnergonRelics.ENERGY_PROJECTOR_BLOCK) && state.contains(Properties.FACING)) { if ((state.getBlock() == EnergonRelics.Blocks.ENERGY_BEAM || state.getBlock() == EnergonRelics.Blocks.ENERGY_PROJECTOR) && state.contains(Properties.FACING)) {
Direction facing = state.get(Properties.FACING); Direction facing = state.get(Properties.FACING);
for (Direction side : Direction.values()) { for (Direction side : Direction.values()) {
if (targetPos.offset(side).equals(pos)) { if (targetPos.offset(side).equals(pos)) {

View File

@ -11,6 +11,6 @@ public class EnergyBeamBlock extends AbstractFieldBlock {
@Override @Override
protected BlockState getProjectorBlockState() { protected BlockState getProjectorBlockState() {
return EnergonRelics.ENERGY_PROJECTOR_BLOCK.getDefaultState(); return EnergonRelics.Blocks.ENERGY_PROJECTOR.getDefaultState();
} }
} }

View File

@ -7,10 +7,12 @@ import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext; import net.minecraft.block.ShapeContext;
import net.minecraft.block.piston.PistonBehavior; import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.function.BooleanBiFunction; import net.minecraft.util.function.BooleanBiFunction;
@ -27,7 +29,7 @@ import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class EnergyPortalBlock extends SimpleBlock { public class EnergyPortalBlock extends SimpleBlock {
public EnergyPortalBlock() { public EnergyPortalBlock() {
super(FabricBlockSettings.copy(Blocks.NETHER_PORTAL).dropsNothing().emissiveLighting((state, world, pos) -> true).noCollision()); super(FabricBlockSettings.of(Material.PORTAL).strength(-1f, 3600000.8f).lightLevel(11).sounds(BlockSoundGroup.GLASS).dropsNothing().emissiveLighting((state, world, pos) -> true).noCollision());
} }
@Override @Override
@ -47,7 +49,7 @@ public class EnergyPortalBlock extends SimpleBlock {
} }
private static boolean isObsidian(BlockState state) { private static boolean isObsidian(BlockState state) {
return state.getBlock() == Blocks.OBSIDIAN || state.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK; return state.getBlock() == Blocks.OBSIDIAN || state.getBlock() == EnergonRelics.Blocks.ENERGIZED_OBSIDIAN;
} }
public static boolean isValidFrame(WorldAccess world, BlockPos centerPos) { public static boolean isValidFrame(WorldAccess world, BlockPos centerPos) {
@ -56,7 +58,7 @@ public class EnergyPortalBlock extends SimpleBlock {
if (isValidDirection(side)) { if (isValidDirection(side)) {
BlockPos energizedPos = centerPos.offset(side, 2); BlockPos energizedPos = centerPos.offset(side, 2);
BlockState energizedObsidian = world.getBlockState(energizedPos); BlockState energizedObsidian = world.getBlockState(energizedPos);
if (energizedObsidian.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK) { if (energizedObsidian.getBlock() == EnergonRelics.Blocks.ENERGIZED_OBSIDIAN) {
BlockState obsidian1 = world.getBlockState(energizedPos.offset(side.rotateYClockwise(), 1)); BlockState obsidian1 = world.getBlockState(energizedPos.offset(side.rotateYClockwise(), 1));
BlockState obsidian2 = world.getBlockState(energizedPos.offset(side.rotateYCounterclockwise(), 1)); BlockState obsidian2 = world.getBlockState(energizedPos.offset(side.rotateYCounterclockwise(), 1));
if (isObsidian(obsidian1) && isObsidian(obsidian2)) { if (isObsidian(obsidian1) && isObsidian(obsidian2)) {
@ -72,7 +74,7 @@ public class EnergyPortalBlock extends SimpleBlock {
BlockPos centerPos = pos; BlockPos centerPos = pos;
for (Direction side : Direction.values()) { for (Direction side : Direction.values()) {
if (isValidDirection(side)) { if (isValidDirection(side)) {
if (world.getBlockState(pos.offset(side)).getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK) { if (world.getBlockState(pos.offset(side)).getBlock() != EnergonRelics.Blocks.ENERGY_PORTAL) {
centerPos = centerPos.offset(side.getOpposite()); centerPos = centerPos.offset(side.getOpposite());
} }
} }
@ -85,7 +87,7 @@ public class EnergyPortalBlock extends SimpleBlock {
BlockPos startPos = centerPos.add(-1, 0, -1); BlockPos startPos = centerPos.add(-1, 0, -1);
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
for (int z = 0; z < 3; z++) { for (int z = 0; z < 3; z++) {
if (world.getBlockState(startPos.add(x, 0, z)).getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK) { if (world.getBlockState(startPos.add(x, 0, z)).getBlock() != EnergonRelics.Blocks.ENERGY_PORTAL) {
valid = false; valid = false;
break; break;
} }
@ -99,7 +101,7 @@ public class EnergyPortalBlock extends SimpleBlock {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
for (int z = 0; z < 3; z++) { for (int z = 0; z < 3; z++) {
BlockState state = world.getBlockState(startPos.add(x, 0, z)); BlockState state = world.getBlockState(startPos.add(x, 0, z));
if (state.getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK && !state.isAir()) { if (state.getBlock() != EnergonRelics.Blocks.ENERGY_PORTAL && !state.isAir()) {
return; return;
} }
} }
@ -107,7 +109,7 @@ public class EnergyPortalBlock extends SimpleBlock {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
for (int z = 0; z < 3; z++) { for (int z = 0; z < 3; z++) {
world.setBlockState(startPos.add(x, 0, z), EnergonRelics.ENERGY_PORTAL_BLOCK.getDefaultState(), 3 | 16); world.setBlockState(startPos.add(x, 0, z), EnergonRelics.Blocks.ENERGY_PORTAL.getDefaultState(), 3 | 16);
} }
} }
} }
@ -140,11 +142,13 @@ public class EnergyPortalBlock extends SimpleBlock {
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity); super.onEntityCollision(state, world, pos, entity);
if (!world.isClient() && !entity.hasVehicle() && entity.canUsePortals() && VoxelShapes.matchesAnywhere(VoxelShapes.cuboid(entity.getBoundingBox().offset(-pos.getX(), -pos.getY(), -pos.getZ())), state.getOutlineShape(world, pos), BooleanBiFunction.AND)) { World entityWorld = entity.getEntityWorld();
if (entityWorld == world && !entityWorld.isClient() && !entity.hasVehicle() && entity.canUsePortals() && VoxelShapes.matchesAnywhere(VoxelShapes.cuboid(entity.getBoundingBox().offset(-pos.getX(), -pos.getY(), -pos.getZ())), state.getOutlineShape(entityWorld, pos), BooleanBiFunction.AND)) {
boolean cooling = ((PortalCooldownEntity) entity).isEnergyPortalCooldown(); boolean cooling = ((PortalCooldownEntity) entity).isEnergyPortalCooldown();
((PortalCooldownEntity) entity).resetEnergyPortalCooldown(); ((PortalCooldownEntity) entity).resetEnergyPortalCooldown();
if (!cooling) { if (!cooling) {
EnergyTeleporter.teleport((ServerWorld) world, entity.getPos(), pos, entity); EnergyTeleporter.teleport((ServerWorld) entityWorld, entity.getPos(), pos, entity);
} }
} }
} }

View File

@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.block.portal;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.mixin.ServerPlayerEntityAccessor;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -13,20 +14,25 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryKey; import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.Heightmap; import net.minecraft.world.Heightmap;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.UUID;
class EnergyTeleporter { class EnergyTeleporter {
private static void teleport(Entity entity, ServerWorld to, Vec3d pos) { private static void teleport(Entity entity, ServerWorld to, Vec3d pos) {
if (entity instanceof ServerPlayerEntity) {
((ServerPlayerEntityAccessor) entity).setInTeleportationState(true);
}
try { try {
TeleportCommand.teleport(null, entity, to, pos.getX(), pos.getY(), pos.getZ(), EnumSet.noneOf(PlayerPositionLookS2CPacket.Flag.class), entity.yaw, entity.pitch, null); TeleportCommand.teleport(null, entity, to, pos.getX(), pos.getY(), pos.getZ(), EnumSet.noneOf(PlayerPositionLookS2CPacket.Flag.class), entity.yaw, entity.pitch, null);
} catch (CommandSyntaxException ignored) { } catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if (entity instanceof ServerPlayerEntity) {
((ServerPlayerEntity) entity).networkHandler.syncWithPlayerPosition();
} }
} }
@ -34,8 +40,6 @@ class EnergyTeleporter {
BlockPos center = EnergyPortalBlock.getCenterPos(world, blockPos); BlockPos center = EnergyPortalBlock.getCenterPos(world, blockPos);
Vec3d offset = pos.subtract(Vec3d.ofBottomCenter(center)); Vec3d offset = pos.subtract(Vec3d.ofBottomCenter(center));
UUID uuid = entity.getUuid();
RegistryKey<World> worldKey = world.getRegistryKey(); RegistryKey<World> worldKey = world.getRegistryKey();
if (worldKey == World.OVERWORLD) { if (worldKey == World.OVERWORLD) {
teleportWithMultiplier(world, entity, center, offset, World.NETHER, 1d / HardcodedConfig.ENERGY_PORTAL_MULTIPLIER); teleportWithMultiplier(world, entity, center, offset, World.NETHER, 1d / HardcodedConfig.ENERGY_PORTAL_MULTIPLIER);
@ -46,38 +50,18 @@ class EnergyTeleporter {
} }
if (entity instanceof ServerPlayerEntity) { if (entity instanceof ServerPlayerEntity) {
ServerPlayerEntity player = world.getServer().getPlayerManager().getPlayer(uuid); ((ServerPlayerEntity) entity).playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, SoundCategory.PLAYERS, 0.25f, world.random.nextFloat() * 0.4f + 0.8f);
if (player != null) {
player.playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, SoundCategory.PLAYERS, 0.25f, world.random.nextFloat() * 0.4f + 0.8f);
}
} }
} }
private static int convertY(int y, int oldHeight, int newHeight) { private static int convertY(int y, int oldHeight, int newHeight) {
int bottomPadding = HardcodedConfig.ENERGY_PORTAL_Y_PADDING; int newY = (int) (((float) newHeight / (float) oldHeight) * (float) y);
int topPadding = bottomPadding + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP;
int oldMax = oldHeight - topPadding; int bottomY = HardcodedConfig.ENERGY_PORTAL_Y_PADDING;
int topY = newHeight - (bottomY + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP);
newY = Math.max(bottomY, Math.min(topY, newY));
y = MathHelper.clamp(y, bottomPadding, oldMax); return newY;
int totalPadding = bottomPadding + topPadding;
int oldPaddedHeight = oldHeight - totalPadding;
int newPaddedHeight = newHeight - totalPadding;
float multiplier = (float) newPaddedHeight / (float) oldPaddedHeight;
y = y - bottomPadding;
y = (int) (y * multiplier);
int newMax = newHeight - topPadding;
y = y + bottomPadding;
y = MathHelper.clamp(y, bottomPadding, newMax);
return y;
} }
private static void teleportWithMultiplier(ServerWorld world, Entity entity, BlockPos center, Vec3d offset, RegistryKey<World> toKey, double multiplier) { private static void teleportWithMultiplier(ServerWorld world, Entity entity, BlockPos center, Vec3d offset, RegistryKey<World> toKey, double multiplier) {

View File

@ -22,6 +22,7 @@ import net.minecraft.world.World;
import java.util.function.Function; import java.util.function.Function;
@SuppressWarnings("deprecation")
public class ReactorInputBlock extends SimpleBlockWithEntity { public class ReactorInputBlock extends SimpleBlockWithEntity {
public ReactorInputBlock() { public ReactorInputBlock() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.YELLOW_TERRACOTTA).requiresTool().strength(1.5f, 6.0f)); super(FabricBlockSettings.of(Material.STONE, MaterialColor.YELLOW_TERRACOTTA).requiresTool().strength(1.5f, 6.0f));
@ -33,7 +34,6 @@ public class ReactorInputBlock extends SimpleBlockWithEntity {
} }
@Override @Override
@SuppressWarnings("deprecation")
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
BlockEntity entity = world.getBlockEntity(pos); BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof Inventory) { if (entity instanceof Inventory) {
@ -45,4 +45,9 @@ public class ReactorInputBlock extends SimpleBlockWithEntity {
return ActionResult.FAIL; return ActionResult.FAIL;
} }
} }
@Override
protected boolean hasInventory() {
return true;
}
} }

View File

@ -5,8 +5,8 @@ import com.thebrokenrail.energonrelics.block.entity.structure.StructureGenerator
import com.thebrokenrail.energonrelics.api.block.SimpleBlockWithEntity; import com.thebrokenrail.energonrelics.api.block.SimpleBlockWithEntity;
import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexStartPart; import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexStartPart;
import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexState; import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexState;
import net.earthcomputer.libstructure.LibStructure;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.structure.v1.FabricStructureBuilder;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -23,10 +23,12 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.chunk.StructureConfig; import net.minecraft.world.gen.chunk.StructureConfig;
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructureFeature;
@ -98,10 +100,12 @@ public class StructureGeneratorBlock extends SimpleBlockWithEntity {
@Override @Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) { public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
super.onBlockAdded(state, world, pos, oldState, notify); super.onBlockAdded(state, world, pos, oldState, notify);
schedule(world, pos); if (world instanceof ServerWorld) {
schedule((ServerWorld) world, pos);
}
} }
public void schedule(World world, BlockPos pos) { public void schedule(StructureWorldAccess world, BlockPos pos) {
world.getBlockTickScheduler().schedule(pos, this, 0); world.getBlockTickScheduler().schedule(pos, this, 0);
} }
@ -116,22 +120,26 @@ public class StructureGeneratorBlock extends SimpleBlockWithEntity {
blocks.put(name, block); blocks.put(name, block);
Registry.register(Registry.STRUCTURE_PIECE, new Identifier(EnergonRelics.NAMESPACE, name + "_piece"), block.piece); Registry.register(Registry.STRUCTURE_PIECE, new Identifier(EnergonRelics.NAMESPACE, name + "_piece"), block.piece);
LibStructure.registerStructure(new Identifier(EnergonRelics.NAMESPACE, name), block.feature, GenerationStep.Feature.UNDERGROUND_STRUCTURES, block.structureConfig, block.feature.configure(FeatureConfig.DEFAULT)); FabricStructureBuilder.create(new Identifier(EnergonRelics.NAMESPACE, name), block.feature).step(GenerationStep.Feature.UNDERGROUND_STRUCTURES).defaultConfig(block.structureConfig).superflatFeature(block.feature.configure(FeatureConfig.DEFAULT)).register();
} }
public static void register() { public static void registerBlocks() {
for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) { for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) {
entry.getValue().register(entry.getKey()); entry.getValue().register(entry.getKey());
} }
} }
public static void addToBiome(GenerationSettings.Builder builder) { public static void addToBiome(Biome biome) {
registerStructures();
for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) { for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) {
builder.structureFeature(entry.getValue().feature.configure(DefaultFeatureConfig.INSTANCE)); ConfiguredStructureFeature<?, ?> feature = entry.getValue().feature.configure(DefaultFeatureConfig.INSTANCE);
biome.getGenerationSettings().getStructureFeatures().add(() -> feature);
} }
} }
static { public static void registerStructures() {
create("research_complex", (world, random, transformations) -> new ResearchComplexStartPart(new ResearchComplexState(world, random), transformations), new StructureConfig(32, 8, 14357618)); if (blocks.size() == 0) {
create("research_complex", (world, random, transformations) -> new ResearchComplexStartPart(new ResearchComplexState(world, random), transformations), new StructureConfig(32, 8, 14357618));
}
} }
} }

View File

@ -19,17 +19,23 @@ class StructureGeneratorPiece extends StructurePiece {
private final StructureGeneratorBlock block; private final StructureGeneratorBlock block;
private final BlockRotation rotation; private final BlockRotation rotation;
private final BlockPos pos; private final BlockPos pos;
private boolean placed;
StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos) { private StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos, boolean placed) {
super(block.piece, 0); super(block.piece, 0);
this.block = block; this.block = block;
this.rotation = rotation; this.rotation = rotation;
this.pos = pos; this.pos = pos;
this.placed = placed;
boundingBox = BlockBox.create(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); boundingBox = BlockBox.create(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
} }
StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos) {
this(block, rotation, pos, false);
}
StructureGeneratorPiece(StructureGeneratorBlock block, CompoundTag tag) { StructureGeneratorPiece(StructureGeneratorBlock block, CompoundTag tag) {
this(block, BlockRotation.valueOf(tag.getString("Rot")), new BlockPos(tag.getInt("X"), tag.getInt("Y"), tag.getInt("Z"))); this(block, BlockRotation.valueOf(tag.getString("Rot")), new BlockPos(tag.getInt("X"), tag.getInt("Y"), tag.getInt("Z")), tag.getBoolean("Placed"));
} }
@Override @Override
@ -38,19 +44,24 @@ class StructureGeneratorPiece extends StructurePiece {
tag.putInt("X", pos.getX()); tag.putInt("X", pos.getX());
tag.putInt("Y", pos.getY()); tag.putInt("Y", pos.getY());
tag.putInt("Z", pos.getZ()); tag.putInt("Z", pos.getZ());
tag.putBoolean("Placed", placed);
} }
@Override @Override
public boolean generate(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) { public boolean generate(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) {
BlockState state = block.getDefaultState().rotate(rotation); if (!placed) {
BlockState state = block.getDefaultState().rotate(rotation);
world.setBlockState(pos, state, 3); world.setBlockState(pos, state, 3);
BlockEntity entity = world.getBlockEntity(pos); BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof StructureGeneratorBlockEntity) { if (entity instanceof StructureGeneratorBlockEntity) {
((StructureGeneratorBlockEntity) entity).setSeed(random.nextLong()); ((StructureGeneratorBlockEntity) entity).setSeed(random.nextLong());
}
block.schedule(world, pos);
placed = true;
} }
block.schedule(world.toServerWorld(), pos);
return true; return true;
} }
} }

View File

@ -1,9 +1,11 @@
package com.thebrokenrail.energonrelics.client; package com.thebrokenrail.energonrelics.client;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
import com.thebrokenrail.energonrelics.block.forcefield.util.AbstractFieldBlock; import com.thebrokenrail.energonrelics.block.forcefield.util.AbstractFieldBlock;
import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock; import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock;
import com.thebrokenrail.energonrelics.client.config.UserConfig; import com.thebrokenrail.energonrelics.client.config.UserConfig;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData; import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
@ -12,6 +14,7 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback; import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@ -40,22 +43,26 @@ public final class EnergonRelicsClient implements ClientModInitializer {
public void onInitializeClient() { public void onInitializeClient() {
EnergyBlock.initRenderer(); EnergyBlock.initRenderer();
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.THERMAL_GLASS_BLOCK, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.THERMAL_GLASS, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.DEFENSIVE_LASER_BLOCK, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.DEFENSIVE_LASER, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.FORCEFIELD_BLOCK, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.FORCEFIELD, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.TRACTOR_BEAM_BLOCK, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.TRACTOR_BEAM, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.REPULSOR_BEAM_BLOCK, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.REPULSOR_BEAM, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.INDUSTRIAL_LASER_BLOCK, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.INDUSTRIAL_LASER, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_PORTAL_BLOCK, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.ENERGY_PORTAL, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_BEAM_BLOCK, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.ENERGY_BEAM, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.PHASE_SHIFTER, RenderLayer.getCutoutMipped());
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> state.get(PhaseShifterBlock.COLOR).getFireworkColor(), EnergonRelics.Blocks.PHASE_SHIFTER);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? HardcodedConfig.PHASE_SHIFTER_DEFAULT_COLOR.getFireworkColor() : -1);
AutoConfig.register(UserConfig.class, ReloadSerializer::new); AutoConfig.register(UserConfig.class, ReloadSerializer::new);
AttackBlockCallback.EVENT.register((playerEntity, world, hand, blockPos, direction) -> { AttackBlockCallback.EVENT.register((playerEntity, world, hand, blockPos, direction) -> {
BlockState state = world.getBlockState(blockPos); BlockState state = world.getBlockState(blockPos);
if (state.getBlock() instanceof AbstractFieldBlock || state.getBlock() == EnergonRelics.ENERGY_PORTAL_BLOCK) { if (state.getBlock() instanceof AbstractFieldBlock || state.getBlock() == EnergonRelics.Blocks.ENERGY_PORTAL) {
return ActionResult.FAIL; return ActionResult.FAIL;
} else { } else {
return ActionResult.PASS; return ActionResult.PASS;

View File

@ -22,7 +22,6 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
@Override @Override
public void render(BlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { public void render(BlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
if (entity instanceof DefensiveLaserBlockEntity) { if (entity instanceof DefensiveLaserBlockEntity) {
matrices.push(); matrices.push();
matrices.translate(0.5d, 0.5d, 0.5d); matrices.translate(0.5d, 0.5d, 0.5d);
@ -44,7 +43,7 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
MinecraftClient client = MinecraftClient.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
client.getItemRenderer().renderItem(new ItemStack(EnergonRelics.DEFENSIVE_LASER_CORE_ITEM), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers); client.getItemRenderer().renderItem(new ItemStack(EnergonRelics.Items.DEFENSIVE_LASER_CORE), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers);
matrices.pop(); matrices.pop();
@ -61,5 +60,6 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
matrices.pop(); matrices.pop();
} }
} }
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
} }
} }

View File

@ -3,6 +3,8 @@ package com.thebrokenrail.energonrelics.client.block.entity.render;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity; import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.mixin.RenderPhaseAccessor; import com.thebrokenrail.energonrelics.mixin.RenderPhaseAccessor;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -15,6 +17,7 @@ import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -23,13 +26,14 @@ import net.minecraft.util.math.Matrix4f;
import java.util.Objects; import java.util.Objects;
@Environment(EnvType.CLIENT)
public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntity> { public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntity> {
public HighlightBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) { public HighlightBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
private static RenderLayer getLayer(Identifier texture) { private static RenderLayer getLayer(Identifier texture) {
return RenderLayer.of(EnergonRelics.NAMESPACE + ":highlight", VertexFormats.POSITION_COLOR, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder().transparency(RenderPhaseAccessor.getTRANSLUCENT_TRANSPARENCY()).layering(RenderPhaseAccessor.getVIEW_OFFSET_Z_LAYERING()).texture(new RenderPhase.Texture(texture, false, false)).fog(RenderPhaseAccessor.getNO_FOG()).cull(RenderPhaseAccessor.getENABLE_CULLING()).build(false)); return RenderLayer.of(EnergonRelics.NAMESPACE + ":highlight", VertexFormats.POSITION_COLOR, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder().writeMaskState(RenderPhaseAccessor.getCOLOR_MASK()).transparency(RenderPhaseAccessor.getTRANSLUCENT_TRANSPARENCY()).layering(RenderPhaseAccessor.getVIEW_OFFSET_Z_LAYERING()).texture(new RenderPhase.Texture(texture, false, false)).fog(RenderPhaseAccessor.getNO_FOG()).cull(RenderPhaseAccessor.getENABLE_CULLING()).build(false));
} }
private static final RenderLayer SELECTED_LAYER = getLayer(new Identifier(EnergonRelics.NAMESPACE, "textures/entity/selected_energy_block.png")); private static final RenderLayer SELECTED_LAYER = getLayer(new Identifier(EnergonRelics.NAMESPACE, "textures/entity/selected_energy_block.png"));
@ -42,39 +46,78 @@ public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntit
MinecraftClient client = MinecraftClient.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
assert client.player != null; assert client.player != null;
ItemStack stack = client.player.getStackInHand(Hand.MAIN_HAND); ItemStack stack = client.player.getStackInHand(Hand.MAIN_HAND);
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) { if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
boolean contains = ((EnergyReceiverBlockEntity) entity).contains(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack)); boolean contains = ((EnergyReceiverBlockEntity) entity).contains(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack));
Matrix4f matrix4f = matrices.peek().getModel();
if (!contains) { if (!contains) {
renderLayer(entity, matrix4f, vertexConsumers.getBuffer(UNSELECTED_LAYER)); renderCuboid(entity, matrices, vertexConsumers.getBuffer(UNSELECTED_LAYER));
} else { } else {
renderLayer(entity, matrix4f, vertexConsumers.getBuffer(SELECTED_LAYER)); renderCuboid(entity, matrices, vertexConsumers.getBuffer(SELECTED_LAYER));
} }
} }
} }
matrices.pop(); matrices.pop();
} }
private void renderLayer(BlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer) { private static boolean shouldDrawSide(BlockEntity entity, Direction side) {
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 1f, 1f, 1f, 1f, 1f, Direction.SOUTH);
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, Direction.NORTH);
renderSide(entity, matrix4f, vertexConsumer, 1f, 1f, 1f, 0f, 0f, 1f, 1f, 0f, Direction.EAST);
renderSide(entity, matrix4f, vertexConsumer, 0f, 0f, 0f, 1f, 0f, 1f, 1f, 0f, Direction.WEST);
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 1f, Direction.DOWN);
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 1f, 1f, 1f, 0f, 0f, Direction.UP);
}
protected boolean shouldDrawSide(BlockEntity entity, Direction side) {
BlockState state = entity.getCachedState(); BlockState state = entity.getCachedState();
return Block.shouldDrawSide(state, Objects.requireNonNull(entity.getWorld()), entity.getPos(), side); return Block.shouldDrawSide(state, Objects.requireNonNull(entity.getWorld()), entity.getPos(), side);
} }
private void renderSide(BlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer, float f, float g, float h, float i, float j, float k, float l, float m, Direction side) { protected static void renderCuboid(BlockEntity entity, MatrixStack matrices, VertexConsumer consumer) {
if (shouldDrawSide(entity, side)) { float sizeX = 1f;
vertexConsumer.vertex(matrix4f, f, h, j).color(1f, 1f, 1f, 1f).next(); float sizeY = 1f;
vertexConsumer.vertex(matrix4f, g, h, k).color(1f, 1f, 1f, 1f).next(); float sizeZ = 1f;
vertexConsumer.vertex(matrix4f, g, i, l).color(1f, 1f, 1f, 1f).next();
vertexConsumer.vertex(matrix4f, f, i, m).color(1f, 1f, 1f, 1f).next(); matrices.translate(0.5d, 0.5d, 0.5d);
for (Direction side : Direction.values()) {
if (shouldDrawSide(entity, side)) {
matrices.push();
multiply(matrices, side);
Matrix4f model = matrices.peek().getModel();
vertex(consumer, model, -0.5f, -0.5f, -0.5f);
vertex(consumer, model, -0.5f, -0.5f + sizeY, -0.5f);
vertex(consumer, model, -0.5f + sizeX, -0.5f + sizeY, -0.5f);
vertex(consumer, model, -0.5f + sizeX, -0.5f, -0.5f);
matrices.pop();
}
}
}
@SuppressWarnings("SameParameterValue")
private static void vertex(VertexConsumer consumer, Matrix4f model, float x, float y, float z) {
consumer.vertex(model, x, y, z).color(1f, 1f, 1f, 1f).next();
}
private static void multiply(MatrixStack matrices, Direction side) {
switch (side) {
case NORTH: {
break;
}
case SOUTH: {
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180));
break;
}
case EAST: {
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90));
break;
}
case WEST: {
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90));
break;
}
case UP: {
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));
break;
}
case DOWN: {
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90));
break;
}
} }
} }
} }

View File

@ -12,12 +12,10 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase; import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.VertexFormats; import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Matrix4f;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@ -69,27 +67,9 @@ public class HolographicSkyBlockEntityRenderer extends HighlightBlockEntityRende
if (entity instanceof HolographicSkyBlockEntity && entity.getCachedState().get(HolographicSkyBlock.POWERED)) { if (entity instanceof HolographicSkyBlockEntity && entity.getCachedState().get(HolographicSkyBlock.POWERED)) {
matrixStack.push(); matrixStack.push();
Matrix4f matrix4f = matrixStack.peek().getModel(); Matrix4f matrix4f = matrixStack.peek().getModel();
renderLayer((HolographicSkyBlockEntity) entity, matrix4f, vertexConsumerProvider.getBuffer(LAYER)); renderCuboid(entity, matrixStack, vertexConsumerProvider.getBuffer(LAYER));
matrixStack.pop(); matrixStack.pop();
} }
super.render(entity, f, matrixStack, vertexConsumerProvider, i, j); super.render(entity, f, matrixStack, vertexConsumerProvider, i, j);
} }
private void renderLayer(HolographicSkyBlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer) {
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 1f, 1f, 1f, 1f, 1f, Direction.SOUTH);
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, Direction.NORTH);
renderSide(entity, matrix4f, vertexConsumer, 1f, 1f, 1f, 0f, 0f, 1f, 1f, 0f, Direction.EAST);
renderSide(entity, matrix4f, vertexConsumer, 0f, 0f, 0f, 1f, 0f, 1f, 1f, 0f, Direction.WEST);
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 1f, Direction.DOWN);
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 1f, 1f, 1f, 0f, 0f, Direction.UP);
}
private void renderSide(HolographicSkyBlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer, float f, float g, float h, float i, float j, float k, float l, float m, Direction side) {
if (shouldDrawSide(entity, side)) {
vertexConsumer.vertex(matrix4f, f, h, j).color(1f, 1f, 1f, 1f).next();
vertexConsumer.vertex(matrix4f, g, h, k).color(1f, 1f, 1f, 1f).next();
vertexConsumer.vertex(matrix4f, g, i, l).color(1f, 1f, 1f, 1f).next();
vertexConsumer.vertex(matrix4f, f, i, m).color(1f, 1f, 1f, 1f).next();
}
}
} }

View File

@ -3,16 +3,22 @@ package com.thebrokenrail.energonrelics.client.rei;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.client.rei.infuser.InfuserCategory; import com.thebrokenrail.energonrelics.client.rei.infuser.InfuserCategory;
import com.thebrokenrail.energonrelics.client.rei.reactor.ReactorFuelCategory; import com.thebrokenrail.energonrelics.client.rei.reactor.ReactorFuelCategory;
import me.shedaniel.rei.api.BuiltinPlugin;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeHelper; import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.plugins.REIPluginV0;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import java.util.ArrayList;
import java.util.List;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public final class EnergonRelicsPlugin implements REIPluginV0 { public final class EnergonRelicsPlugin implements REIPluginV0 {
public static final Identifier INFUSER = new Identifier(EnergonRelics.NAMESPACE, "plugin/infuser"); public static final Identifier INFUSING = new Identifier(EnergonRelics.NAMESPACE, "plugin/infusing");
public static final Identifier REACTOR_FUEL = new Identifier(EnergonRelics.NAMESPACE, "plugin/reactor_fuel"); public static final Identifier REACTOR_FUEL = new Identifier(EnergonRelics.NAMESPACE, "plugin/reactor_fuel");
@Override @Override
@ -22,8 +28,17 @@ public final class EnergonRelicsPlugin implements REIPluginV0 {
@Override @Override
public void registerOthers(RecipeHelper recipeHelper) { public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(INFUSER, EntryStack.create(EnergonRelics.INFUSER_BLOCK)); recipeHelper.registerWorkingStations(INFUSING, EntryStack.create(EnergonRelics.Blocks.INFUSER));
recipeHelper.registerWorkingStations(REACTOR_FUEL, EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK)); recipeHelper.registerWorkingStations(REACTOR_FUEL, EntryStack.create(EnergonRelics.Blocks.REACTOR_INPUT));
recipeHelper.removeAutoCraftButton(INFUSING);
recipeHelper.removeAutoCraftButton(REACTOR_FUEL);
BuiltinPlugin.getInstance().registerInformation(EntryStack.create(EnergonRelics.Items.CIRCUIT_BOARD), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".information.structure_generation.title"), texts -> {
List<Text> newTexts = new ArrayList<>(texts);
newTexts.add(new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".information.structure_generation.research_complex"));
return newTexts;
});
} }
@Override @Override

View File

@ -36,8 +36,8 @@ public class InfuserCategory implements RecipeCategory<InfuserDisplay> {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
List<Widget> widgets = new ArrayList<>(); List<Widget> widgets = new ArrayList<>();
widgets.add(Widgets.createRecipeBase(bounds)); widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width / 2, bounds.y + 9), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infuser.chance", new DecimalFormat("###.##").format(display.successChance * 100d))).noShadow().centered().color(0xFF404040, 0xFFBBBBBB)); widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width / 2, bounds.y + 9), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infusing.chance", new DecimalFormat("###.##").format(display.successChance * 100d))).noShadow().centered().color(0xFF404040, 0xFFBBBBBB));
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width / 2, bounds.y + 18), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infuser.cost", display.cost)).noShadow().centered().color(0xFF404040, 0xFFBBBBBB)); widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width / 2, bounds.y + 18), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infusing.cost", display.cost)).noShadow().centered().color(0xFF404040, 0xFFBBBBBB));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 25)).animationDurationTicks(HardcodedConfig.INFUSER_TIME)); widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 25)).animationDurationTicks(HardcodedConfig.INFUSER_TIME));
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 26)).entries(display.getInputEntries().get(0)).markInput()); widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 26)).entries(display.getInputEntries().get(0)).markInput());
@ -47,8 +47,8 @@ public class InfuserCategory implements RecipeCategory<InfuserDisplay> {
widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 26))); widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 26)));
widgets.add(Widgets.createSlot(new Point(outputX, outputY)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput()); widgets.add(Widgets.createSlot(new Point(outputX, outputY)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
} else { } else {
Identifier outputID = Registry.ITEM.getId(display.getResultingEntries().get(0).get(0).getItem()); Identifier outputID = Registry.ITEM.getId(display.output.getItem());
Text text = new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infuser.display_item." + outputID.getNamespace() + "." + outputID.getPath()); Text text = new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infusing.display_item." + outputID.getNamespace() + "." + outputID.getPath());
widgets.add(Widgets.createLabel(new Point(outputX - 7, outputY + 3), text).noShadow().leftAligned().color(0xFF404040, 0xFFBBBBBB)); widgets.add(Widgets.createLabel(new Point(outputX - 7, outputY + 3), text).noShadow().leftAligned().color(0xFF404040, 0xFFBBBBBB));
} }
return widgets; return widgets;
@ -61,17 +61,17 @@ public class InfuserCategory implements RecipeCategory<InfuserDisplay> {
@Override @Override
public Identifier getIdentifier() { public Identifier getIdentifier() {
return EnergonRelicsPlugin.INFUSER; return EnergonRelicsPlugin.INFUSING;
} }
@Override @Override
public EntryStack getLogo() { public EntryStack getLogo() {
return EntryStack.create(EnergonRelics.INFUSER_BLOCK); return EntryStack.create(EnergonRelics.Blocks.INFUSER);
} }
@Override @Override
public String getCategoryName() { public String getCategoryName() {
return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".infuser.name"); return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".infusing.name");
} }
public static void register(RecipeHelper recipeHelper) { public static void register(RecipeHelper recipeHelper) {

View File

@ -15,7 +15,7 @@ import java.util.List;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class InfuserDisplay implements RecipeDisplay { public class InfuserDisplay implements RecipeDisplay {
private final EntryStack input; private final EntryStack input;
private final EntryStack output; public final EntryStack output;
public final boolean outputsItem; public final boolean outputsItem;
public final double successChance; public final double successChance;
public final long cost; public final long cost;
@ -35,12 +35,16 @@ public class InfuserDisplay implements RecipeDisplay {
@Override @Override
public List<List<EntryStack>> getResultingEntries() { public List<List<EntryStack>> getResultingEntries() {
return Collections.singletonList(Collections.singletonList(output)); if (outputsItem) {
return Collections.singletonList(Collections.singletonList(output));
} else {
return Collections.emptyList();
}
} }
@Override @Override
public Identifier getRecipeCategory() { public Identifier getRecipeCategory() {
return EnergonRelicsPlugin.INFUSER; return EnergonRelicsPlugin.INFUSING;
} }
@Override @Override

View File

@ -8,11 +8,15 @@ import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory; import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.RecipeHelper; import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.api.widgets.Slot;
import me.shedaniel.rei.api.widgets.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry;
import me.shedaniel.rei.gui.widget.Widget; import me.shedaniel.rei.gui.widget.Widget;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@ -50,7 +54,7 @@ public class ReactorFuelCategory implements RecipeCategory<ReactorFuelDisplay> {
@Override @Override
public EntryStack getLogo() { public EntryStack getLogo() {
return EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK); return EntryStack.create(EnergonRelics.Blocks.REACTOR_INPUT);
} }
@Override @Override
@ -58,6 +62,33 @@ public class ReactorFuelCategory implements RecipeCategory<ReactorFuelDisplay> {
return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".reactor_fuel.name"); return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".reactor_fuel.name");
} }
@Override
public RecipeEntry getSimpleRenderer(ReactorFuelDisplay recipe) {
Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground().disableHighlight();
return new RecipeEntry() {
@Override
public int getHeight() {
return 22;
}
@Override
public Tooltip getTooltip(Point point) {
if (slot.containsMouse(point)) {
return slot.getCurrentTooltip(point);
} else {
return null;
}
}
@Override
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
slot.setZ(getZ() + 50);
slot.getBounds().setLocation(bounds.x + bounds.width / 2 - 10, bounds.y + 2);
slot.render(matrices, mouseX, mouseY, delta);
}
};
}
public static void register(RecipeHelper recipeHelper) { public static void register(RecipeHelper recipeHelper) {
for (Map.Entry<Item, Float> entry : ReactorFuelRegistry.entrySet()) { for (Map.Entry<Item, Float> entry : ReactorFuelRegistry.entrySet()) {
recipeHelper.registerDisplay(new ReactorFuelDisplay(new ItemStack(entry.getKey()), entry.getValue())); recipeHelper.registerDisplay(new ReactorFuelDisplay(new ItemStack(entry.getKey()), entry.getValue()));

View File

@ -202,8 +202,8 @@ public class NetworkComponent extends PersistentState {
Entry entry = getOrCreate(id); Entry entry = getOrCreate(id);
if (!entry.sources.contains(pos)) { if (!entry.sources.contains(pos)) {
entry.sources.add(pos); entry.sources.add(pos);
markDirty();
} }
markDirty();
} }
public void removeSource(int id, BlockPosWithDimension pos) { public void removeSource(int id, BlockPosWithDimension pos) {

View File

@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.config;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.DyeColor;
/** /**
* Hardcoded Configuration Values * Hardcoded Configuration Values
@ -9,14 +10,16 @@ import net.minecraft.item.Items;
public final class HardcodedConfig { public final class HardcodedConfig {
public static final int POWER_RANGE = 64; public static final int POWER_RANGE = 64;
public static final long SWITCH_ENERGY_REQUIRED = 2;
public static final int ENERGON_LIGHT_ENERGY_REQUIRED = 5; public static final int ENERGON_LIGHT_ENERGY_REQUIRED = 5;
public static final long SOLAR_PANEL_MAX_ENERGY_OUTPUT = 50; public static final long SOLAR_PANEL_MAX_ENERGY_OUTPUT = 70;
public static final long BATTERY_CHARGE_RATE = 40; public static final long BATTERY_CHARGE_RATE = 40;
public static final int REACTOR_TIME = 2400; public static final int REACTOR_TIME = 2400;
public static final int REACTOR_ENERGY_OUTPUT = 250; public static final int REACTOR_ENERGY_OUTPUT = 350;
public static final int DEFENSIVE_LASER_RANGE = 28; public static final int DEFENSIVE_LASER_RANGE = 28;
public static final long DEFENSIVE_LASER_IDLE_ENERGY_REQUIRED = 32; public static final long DEFENSIVE_LASER_IDLE_ENERGY_REQUIRED = 32;
@ -53,4 +56,15 @@ public final class HardcodedConfig {
public static final int ENERGY_PORTAL_MULTIPLIER = 16; public static final int ENERGY_PORTAL_MULTIPLIER = 16;
public static final int ENERGY_PORTAL_Y_PADDING = 4; public static final int ENERGY_PORTAL_Y_PADDING = 4;
public static final int ENERGY_PORTAL_Y_PADDING_EXTRA_TOP = 3; public static final int ENERGY_PORTAL_Y_PADDING_EXTRA_TOP = 3;
public static final long PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_BASE = 112;
public static final long PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_PER_ITEM = 19;
public static final int PHASE_SHIFTER_INPUT_COOLDOWN = 16;
public static final int PHASE_SHIFTER_INPUT_ROLL_COOLDOWN = 6;
public static final int PHASE_SHIFTER_INPUT_RANGE_BASE = 21;
public static final int PHASE_SHIFTER_INPUT_RANGE_INCREMENT = 9;
public static final float PHASE_SHIFTER_SUCCESS_CHANCE = 0.1f;
public static final long PHASE_SHIFTER_OUTPUT_ENERGY_REQUIRED = 28;
public static final int PHASE_SHIFTER_OUTPUT_COOLDOWN = 21;
public static final DyeColor PHASE_SHIFTER_DEFAULT_COLOR = DyeColor.WHITE;
} }

View File

@ -0,0 +1,17 @@
package com.thebrokenrail.energonrelics.feature;
import com.thebrokenrail.energonrelics.EnergonRelics;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
public class CustomFeatures {
public static final ConfiguredFeature<?, ?> VERIDIUM_ORE_FEATURE = Feature.ORE.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, EnergonRelics.Blocks.VERIDIUM_ORE.getDefaultState(), 9)).method_30377(32).spreadHorizontally().repeat(2);
public static void register() {
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(EnergonRelics.NAMESPACE, "veridium_ore"), VERIDIUM_ORE_FEATURE);
}
}

View File

@ -3,6 +3,7 @@ package com.thebrokenrail.energonrelics.item;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity; import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.api.block.entity.helper.EnergyGenerator; import com.thebrokenrail.energonrelics.api.block.entity.helper.EnergyGenerator;
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ItemUsageContext;
@ -18,11 +19,7 @@ import java.util.Objects;
public class MultimeterItem extends Item { public class MultimeterItem extends Item {
public MultimeterItem() { public MultimeterItem() {
super(new Settings().maxCount(1).group(EnergonRelics.ITEM_GROUP)); super(new Settings().maxCount(1).group(EnergonRelics.Items.ITEM_GROUP));
}
public interface MultimeterExtra {
MutableText getExtra();
} }
public static MutableText format(long value) { public static MutableText format(long value) {
@ -61,10 +58,13 @@ public class MultimeterItem extends Item {
} }
if (entity instanceof MultimeterExtra) { if (entity instanceof MultimeterExtra) {
if (!world.isClient() && context.getPlayer() != null) { if (!world.isClient() && context.getPlayer() != null) {
if (success) { MutableText extraText = ((MultimeterExtra) entity).getExtra();
text.append(separator); if (extraText != null) {
if (success) {
text.append(separator);
}
text.append(extraText.formatted(Formatting.YELLOW));
} }
text.append(((MultimeterExtra) entity).getExtra().formatted(Formatting.YELLOW));
} }
success = true; success = true;
} }
@ -72,7 +72,7 @@ public class MultimeterItem extends Item {
if (!world.isClient()) { if (!world.isClient()) {
Objects.requireNonNull(context.getPlayer()).sendMessage(text, true); Objects.requireNonNull(context.getPlayer()).sendMessage(text, true);
} }
EnergonRelics.playBeep(world, context.getBlockPos()); EnergonRelics.Extras.playBeep(world, context.getBlockPos());
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {
return ActionResult.PASS; return ActionResult.PASS;

View File

@ -24,7 +24,7 @@ import java.util.List;
public class NetworkChipItem extends Item { public class NetworkChipItem extends Item {
public NetworkChipItem() { public NetworkChipItem() {
super(new Settings().maxCount(1).group(EnergonRelics.ITEM_GROUP)); super(new Settings().maxCount(1).group(EnergonRelics.Items.ITEM_GROUP));
} }
private void setID(ItemStack stack, int id) { private void setID(ItemStack stack, int id) {
@ -86,7 +86,7 @@ public class NetworkChipItem extends Item {
NetworkComponent component = NetworkComponent.getInstance(serverWorld); NetworkComponent component = NetworkComponent.getInstance(serverWorld);
((EnergyReceiverBlockEntity) entity).toggle(getOrCreateID(context.getStack(), component)); ((EnergyReceiverBlockEntity) entity).toggle(getOrCreateID(context.getStack(), component));
} }
EnergonRelics.playBeep(world, context.getBlockPos()); EnergonRelics.Extras.playBeep(world, context.getBlockPos());
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {
return ActionResult.PASS; return ActionResult.PASS;

View File

@ -1,13 +0,0 @@
package com.thebrokenrail.energonrelics.mixin;
import net.minecraft.entity.damage.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(DamageSource.class)
public interface DamageSourceAccessor {
@Invoker
static DamageSource createDamageSource(String name) {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,20 @@
package com.thebrokenrail.energonrelics.mixin;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.function.Supplier;
@Mixin(GenerationSettings.class)
public interface GenerationSettingsAccessor {
@Accessor
List<Supplier<ConfiguredStructureFeature<?, ?>>> getStructureFeatures();
@Mutable
@Accessor
void setStructureFeatures(List<Supplier<ConfiguredStructureFeature<?, ?>>> structureFeatures);
}

View File

@ -0,0 +1,16 @@
package com.thebrokenrail.energonrelics.mixin;
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
import net.minecraft.Bootstrap;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Bootstrap.class)
public class MixinBootstrap {
@Inject(at = @At("TAIL"), method = "initialize")
private static void initialize(CallbackInfo info) {
StructureGeneratorBlock.registerStructures();
}
}

View File

@ -1,7 +1,6 @@
package com.thebrokenrail.energonrelics.mixin; package com.thebrokenrail.energonrelics.mixin;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.feature.CustomFeatures;
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.feature.DefaultBiomeFeatures; import net.minecraft.world.gen.feature.DefaultBiomeFeatures;
@ -14,11 +13,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinDefaultBiomeFeatures { public class MixinDefaultBiomeFeatures {
@Inject(at = @At("RETURN"), method = "addDefaultOres") @Inject(at = @At("RETURN"), method = "addDefaultOres")
private static void addDefaultOres(GenerationSettings.Builder builder, CallbackInfo info) { private static void addDefaultOres(GenerationSettings.Builder builder, CallbackInfo info) {
builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, EnergonRelics.VERIDIUM_ORE_FEATURE); builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, CustomFeatures.VERIDIUM_ORE_FEATURE);
}
@Inject(at = @At("RETURN"), method = "addDefaultUndergroundStructures")
private static void addDefaultUndergroundStructures(GenerationSettings.Builder builder, CallbackInfo info) {
StructureGeneratorBlock.addToBiome(builder);
} }
} }

View File

@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.forcefield.util.BeamBlock;
import com.thebrokenrail.energonrelics.block.portal.PortalCooldownEntity; import com.thebrokenrail.energonrelics.block.portal.PortalCooldownEntity;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@ -26,6 +27,8 @@ import java.util.function.Predicate;
public abstract class MixinEntity implements PortalCooldownEntity { public abstract class MixinEntity implements PortalCooldownEntity {
@Unique @Unique
private int energyPortalCooldown = 0; private int energyPortalCooldown = 0;
@Unique
private boolean touchingBeam = false;
@Shadow @Shadow
public abstract Box getBoundingBox(); public abstract Box getBoundingBox();
@ -39,6 +42,8 @@ public abstract class MixinEntity implements PortalCooldownEntity {
@Unique @Unique
private boolean isTouching(Predicate<Block> test) { private boolean isTouching(Predicate<Block> test) {
if (getServer() == null || getServer().getThread() == Thread.currentThread()) { if (getServer() == null || getServer().getThread() == Thread.currentThread()) {
getEntityWorld().getProfiler().push("energonrelics:isTouching");
Box box = getBoundingBox(); Box box = getBoundingBox();
int i = MathHelper.floor(box.minX); int i = MathHelper.floor(box.minX);
int j = MathHelper.ceil(box.maxX); int j = MathHelper.ceil(box.maxX);
@ -46,17 +51,22 @@ public abstract class MixinEntity implements PortalCooldownEntity {
int l = MathHelper.ceil(box.maxY); int l = MathHelper.ceil(box.maxY);
int m = MathHelper.floor(box.minZ); int m = MathHelper.floor(box.minZ);
int n = MathHelper.ceil(box.maxZ); int n = MathHelper.ceil(box.maxZ);
BlockPos.Mutable pos = new BlockPos.Mutable();
for (int p = i; p < j; ++p) { for (int p = i; p < j; ++p) {
for (int q = k; q < l; ++q) { for (int q = k; q < l; ++q) {
for (int r = m; r < n; ++r) { for (int r = m; r < n; ++r) {
BlockPos pos = new BlockPos(p, q, r); pos.set(p, q, r);
if (test.test(getEntityWorld().getBlockState(pos).getBlock())) { BlockState state = getEntityWorld().getBlockState(pos);
if (state.getCollisionShape(getEntityWorld(), pos).isEmpty() && test.test(state.getBlock())) {
getEntityWorld().getProfiler().pop();
return true; return true;
} }
} }
} }
} }
} }
getEntityWorld().getProfiler().pop();
return false; return false;
} }
@ -65,7 +75,7 @@ public abstract class MixinEntity implements PortalCooldownEntity {
@Inject(at = @At("HEAD"), method = "hasNoGravity", cancellable = true) @Inject(at = @At("HEAD"), method = "hasNoGravity", cancellable = true)
public void hasNoGravity(CallbackInfoReturnable<Boolean> info) { public void hasNoGravity(CallbackInfoReturnable<Boolean> info) {
if (isTouching(block -> block instanceof BeamBlock) && !saving) { if (!saving && touchingBeam) {
info.setReturnValue(true); info.setReturnValue(true);
} }
} }
@ -86,11 +96,14 @@ public abstract class MixinEntity implements PortalCooldownEntity {
energyPortalCooldown = tag.getInt(EnergonRelics.NAMESPACE + ":EnergyPortalCooldown"); energyPortalCooldown = tag.getInt(EnergonRelics.NAMESPACE + ":EnergyPortalCooldown");
} }
@Inject(at = @At("HEAD"), method = "tick")
public void tickHead(CallbackInfo info) {
touchingBeam = isTouching(block -> block instanceof BeamBlock);
}
@Inject(at = @At("RETURN"), method = "tick") @Inject(at = @At("RETURN"), method = "tick")
public void tick(CallbackInfo info) { public void tickReturn(CallbackInfo info) {
if (!isTouching(block -> block == EnergonRelics.ENERGY_PORTAL_BLOCK) && energyPortalCooldown > 0) { energyPortalCooldown--;
energyPortalCooldown--;
}
} }
@Override @Override

View File

@ -0,0 +1,47 @@
package com.thebrokenrail.energonrelics.mixin;
import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.datafixers.DataFixer;
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
import net.minecraft.resource.ResourcePackManager;
import net.minecraft.resource.ServerResourceManager;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldGenerationProgressListenerFactory;
import net.minecraft.util.UserCache;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.SaveProperties;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.level.storage.LevelStorage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.net.Proxy;
import java.util.ArrayList;
@Mixin(MinecraftServer.class)
public class MixinMinecraftServer {
@Shadow
@Final
protected DynamicRegistryManager.Impl registryManager;
@Inject(at = @At("TAIL"), method = "<init>")
private void init(Thread thread, DynamicRegistryManager.Impl impl, LevelStorage.Session session, SaveProperties saveProperties, ResourcePackManager resourcePackManager, Proxy proxy, DataFixer dataFixer, ServerResourceManager serverResourceManager, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, UserCache userCache, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo info) {
if (registryManager.getOptional(Registry.BIOME_KEY).isPresent()) {
for (Biome biome : registryManager.getOptional(Registry.BIOME_KEY).get()) {
// Make Mutable
((GenerationSettingsAccessor) biome.getGenerationSettings()).setStructureFeatures(new ArrayList<>(((GenerationSettingsAccessor) biome.getGenerationSettings()).getStructureFeatures()));
if (biome.getGenerationSettings().hasStructureFeature(StructureFeature.MINESHAFT)) {
StructureGeneratorBlock.addToBiome(biome);
}
}
}
}
}

View File

@ -25,4 +25,9 @@ public interface RenderPhaseAccessor {
static RenderPhase.Cull getENABLE_CULLING() { static RenderPhase.Cull getENABLE_CULLING() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Accessor
static RenderPhase.WriteMaskState getCOLOR_MASK() {
throw new UnsupportedOperationException();
}
} }

View File

@ -0,0 +1,11 @@
package com.thebrokenrail.energonrelics.mixin;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ServerPlayerEntity.class)
public interface ServerPlayerEntityAccessor {
@Accessor
void setInTeleportationState(boolean inTeleportationState);
}

View File

@ -50,7 +50,7 @@ public class CustomPotions {
} }
private static void registerBrewingRecipes() { private static void registerBrewingRecipes() {
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.VERIDIUM_POWDER_ITEM, VERIDIUM_POISON_EFFECT.potion); BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.Items.VERIDIUM_POWDER, VERIDIUM_POISON_EFFECT.potion);
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(VERIDIUM_POISON_EFFECT.potion, Items.REDSTONE, VERIDIUM_POISON_EFFECT.longPotion); BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(VERIDIUM_POISON_EFFECT.potion, Items.REDSTONE, VERIDIUM_POISON_EFFECT.longPotion);
} }

View File

@ -20,9 +20,9 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
boolean foundCircuit = false; boolean foundCircuit = false;
for (int i = 0; i < inv.size(); i++) { for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStack(i); ItemStack stack = inv.getStack(i);
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM && !foundChip) { if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM && !foundChip) {
foundChip = true; foundChip = true;
} else if (stack.getItem() == EnergonRelics.CIRCUIT_BOARD_ITEM && !foundCircuit) { } else if (stack.getItem() == EnergonRelics.Items.CIRCUIT_BOARD && !foundCircuit) {
foundCircuit = true; foundCircuit = true;
} else if (!stack.isEmpty()) { } else if (!stack.isEmpty()) {
return false; return false;
@ -36,7 +36,7 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
ItemStack out = ItemStack.EMPTY; ItemStack out = ItemStack.EMPTY;
for (int i = 0; i < inv.size(); i++) { for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStack(i); ItemStack stack = inv.getStack(i);
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) { if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
out = stack.copy(); out = stack.copy();
out.setCount(1); out.setCount(1);
} }
@ -52,7 +52,7 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
ItemStack stack = inv.getStack(i); ItemStack stack = inv.getStack(i);
if (stack.getItem().hasRecipeRemainder()) { if (stack.getItem().hasRecipeRemainder()) {
defaultedList.set(i, new ItemStack(stack.getItem().getRecipeRemainder())); defaultedList.set(i, new ItemStack(stack.getItem().getRecipeRemainder()));
} else if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) { } else if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
ItemStack newStack = stack.copy(); ItemStack newStack = stack.copy();
newStack.setCount(1); newStack.setCount(1);
defaultedList.set(i, newStack); defaultedList.set(i, newStack);
@ -69,6 +69,6 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
@Override @Override
public RecipeSerializer<?> getSerializer() { public RecipeSerializer<?> getSerializer() {
return EnergonRelics.DUPLICATE_NETWORK_CHIP_RECIPE; return EnergonRelics.Extras.DUPLICATE_NETWORK_CHIP_RECIPE;
} }
} }

View File

@ -103,12 +103,14 @@ public final class InfuserRegistry {
add(Items.GOLDEN_APPLE, new InfuserEntry(510, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.ENCHANTED_GOLDEN_APPLE)}, new InfuserAction[]{new InfuserAction.ExplosionAction()})); add(Items.GOLDEN_APPLE, new InfuserEntry(510, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.ENCHANTED_GOLDEN_APPLE)}, new InfuserAction[]{new InfuserAction.ExplosionAction()}));
add(Items.COAL, new InfuserEntry(340, 0.2d, new InfuserAction[]{new InfuserAction.ItemAction(Items.DIAMOND)}, new InfuserAction[]{new InfuserAction.ExplosionAction()})); add(Items.COAL, new InfuserEntry(340, 0.2d, new InfuserAction[]{new InfuserAction.ItemAction(Items.DIAMOND)}, new InfuserAction[]{new InfuserAction.ExplosionAction()}));
add(EnergonRelics.VERIDIUM_INGOT_ITEM, new InfuserEntry(240, 0.25d, new InfuserAction[]{new InfuserAction.ItemAction(EnergonRelics.VERIDIUM_ORB_ITEM)}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ItemAction(EnergonRelics.VERIDIUM_POWDER_ITEM), new InfuserAction.ExplosionAction()})); add(EnergonRelics.Items.VERIDIUM_INGOT, new InfuserEntry(240, 0.25d, new InfuserAction[]{new InfuserAction.ItemAction(EnergonRelics.Items.VERIDIUM_ORB)}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ItemAction(EnergonRelics.Items.VERIDIUM_POWDER), new InfuserAction.ExplosionAction()}));
add(EnergonRelics.VERIDIUM_POWDER_ITEM, new InfuserEntry(170, 0.27d, new InfuserAction[]{new InfuserAction.ItemAction(new ItemStack(EnergonRelics.VERIDIUM_INGOT_ITEM, 2))}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ExplosionAction()})); add(EnergonRelics.Items.VERIDIUM_POWDER, new InfuserEntry(170, 0.27d, new InfuserAction[]{new InfuserAction.ItemAction(new ItemStack(EnergonRelics.Items.VERIDIUM_INGOT, 2))}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ExplosionAction()}));
add(Items.GOLD_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.GOLD_INGOT)}, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_NUGGET), new InfuserAction.ParticleAction()})); add(Items.GOLD_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.GOLD_INGOT)}, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_NUGGET), new InfuserAction.ParticleAction()}));
add(Items.IRON_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_INGOT)}, new InfuserAction[]{new InfuserAction.ParticleAction()})); add(Items.IRON_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_INGOT)}, new InfuserAction[]{new InfuserAction.ParticleAction()}));
add(Items.IRON_ORE, new InfuserEntry(270, 0.42d, new InfuserAction[]{new InfuserAction.ItemAction(Items.GOLD_ORE)}, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_ORE), new InfuserAction.ItemAction(Items.STONE)}));
} }
private static Item[] getWool() { private static Item[] getWool() {

View File

@ -1,4 +1,4 @@
package com.thebrokenrail.energonrelics.block.entity.forcefield.laser; package com.thebrokenrail.energonrelics.registry.laser;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
@ -13,10 +13,19 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.function.Function; import java.util.function.Function;
/**
* Industrial Laser Registry
*/
public class IndustrialLaserRegistry { public class IndustrialLaserRegistry {
private static final Map<Block, Function<Random, ItemStack>> map = new HashMap<>(); private static final Map<Block, Function<Random, ItemStack>> map = new HashMap<>();
private static void add(Block ore, Item ingot, Block storage) { /**
* Add To Registry
* @param ore Ore Block
* @param ingot Ingot Item
* @param storage Storage Block
*/
public static void add(Block ore, Item ingot, Block storage) {
map.put(ore, random -> { map.put(ore, random -> {
int min = HardcodedConfig.INDUSTRIAL_LASER_MIN_INGOTS_FROM_ORE; int min = HardcodedConfig.INDUSTRIAL_LASER_MIN_INGOTS_FROM_ORE;
int max = HardcodedConfig.INDUSTRIAL_LASER_MAX_INGOTS_FROM_ORE; int max = HardcodedConfig.INDUSTRIAL_LASER_MAX_INGOTS_FROM_ORE;
@ -25,14 +34,27 @@ public class IndustrialLaserRegistry {
return new ItemStack(ingot, count); return new ItemStack(ingot, count);
}); });
map.put(storage, random -> new ItemStack(ingot, HardcodedConfig.INDUSTRIAL_LASER_INGOTS_FROM_STORAGE)); if (storage != null) {
map.put(storage, random -> new ItemStack(ingot, HardcodedConfig.INDUSTRIAL_LASER_INGOTS_FROM_STORAGE));
}
} }
static boolean has(Block block) { /**
* Check If Registry Contains Block
* @param block Block
* @return If Registry Contains Block
*/
public static boolean has(Block block) {
return map.containsKey(block); return map.containsKey(block);
} }
static ItemStack get(Block block, Random random) { /**
* Get From Registry
* @param block Block
* @param random Random
* @return Output Item(s)
*/
public static ItemStack get(Block block, Random random) {
return map.get(block).apply(random); return map.get(block).apply(random);
} }
@ -42,8 +64,9 @@ public class IndustrialLaserRegistry {
add(Blocks.COAL_ORE, Items.COAL, Blocks.COAL_BLOCK); add(Blocks.COAL_ORE, Items.COAL, Blocks.COAL_BLOCK);
add(Blocks.IRON_ORE, Items.IRON_INGOT, Blocks.IRON_BLOCK); add(Blocks.IRON_ORE, Items.IRON_INGOT, Blocks.IRON_BLOCK);
add(Blocks.GOLD_ORE, Items.GOLD_INGOT, Blocks.GOLD_BLOCK); add(Blocks.GOLD_ORE, Items.GOLD_INGOT, Blocks.GOLD_BLOCK);
add(Blocks.NETHER_GOLD_ORE, Items.GOLD_INGOT, null);
add(Blocks.DIAMOND_ORE, Items.DIAMOND, Blocks.DIAMOND_BLOCK); add(Blocks.DIAMOND_ORE, Items.DIAMOND, Blocks.DIAMOND_BLOCK);
add(Blocks.EMERALD_ORE, Items.EMERALD, Blocks.EMERALD_BLOCK); add(Blocks.EMERALD_ORE, Items.EMERALD, Blocks.EMERALD_BLOCK);
add(EnergonRelics.VERIDIUM_ORE_BLOCK, EnergonRelics.VERIDIUM_INGOT_ITEM, EnergonRelics.VERIDIUM_BLOCK_BLOCK); add(EnergonRelics.Blocks.VERIDIUM_ORE, EnergonRelics.Items.VERIDIUM_INGOT, EnergonRelics.Blocks.VERIDIUM_BLOCK);
} }
} }

View File

@ -43,8 +43,8 @@ public final class ReactorFuelRegistry {
} }
static { static {
add(EnergonRelics.VERIDIUM_INGOT_ITEM, 1f); add(EnergonRelics.Items.VERIDIUM_INGOT, 1f);
add(EnergonRelics.VERIDIUM_BLOCK_BLOCK.asItem(), 9f); add(EnergonRelics.Blocks.VERIDIUM_BLOCK.asItem(), 9f);
add(EnergonRelics.VERIDIUM_POWDER_ITEM, 0.25f); add(EnergonRelics.Items.VERIDIUM_POWDER, 0.25f);
} }
} }

View File

@ -59,7 +59,7 @@ public abstract class AbstractResearchComplexRoomPart extends BaseResearchComple
set(new BlockPos(0, 0, 2), plate); set(new BlockPos(0, 0, 2), plate);
BlockState light = EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState(); BlockState light = EnergonRelics.Blocks.ENERGON_LIGHT.getDefaultState();
List<BlockPos> list = getLights(); List<BlockPos> list = getLights();
for (BlockPos pos : list) { for (BlockPos pos : list) {
set(pos, light); set(pos, light);

View File

@ -17,7 +17,7 @@ public abstract class BaseResearchComplexPart extends StructurePart<ResearchComp
@Override @Override
protected void handleBlockPlace(World world, BlockPos pos, BlockState state) { protected void handleBlockPlace(World world, BlockPos pos, BlockState state) {
if (state.getBlock() == EnergonRelics.ENERGON_LIGHT_BLOCK) { if (state.getBlock() == EnergonRelics.Blocks.ENERGON_LIGHT) {
BlockEntity entity = world.getBlockEntity(pos); BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof EnergonLightBlockEntity) { if (entity instanceof EnergonLightBlockEntity) {
((EnergonLightBlockEntity) entity).toggle(getState().getMainNetwork()); ((EnergonLightBlockEntity) entity).toggle(getState().getMainNetwork());

View File

@ -62,7 +62,7 @@ public class ResearchComplexHallwayPart extends BaseResearchComplexPart {
} }
if (hasLight) { if (hasLight) {
set(new BlockPos(3, 5, 1), EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState()); set(new BlockPos(3, 5, 1), EnergonRelics.Blocks.ENERGON_LIGHT.getDefaultState());
} }
if (leftRoomPadding == 0) { if (leftRoomPadding == 0) {

View File

@ -74,19 +74,19 @@ public class ResearchComplexStartPart extends BaseResearchComplexPart {
} }
if (yOffset == 5) { if (yOffset == 5) {
set(new BlockPos(2, yOffset, 2), EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState()); set(new BlockPos(2, yOffset, 2), EnergonRelics.Blocks.ENERGON_LIGHT.getDefaultState());
} }
} }
private void buildReactor() { private void buildReactor() {
set(new BlockPos(0, 1, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState()); set(new BlockPos(0, 1, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState());
set(new BlockPos(1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState()); set(new BlockPos(1, 2, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState());
set(new BlockPos(0, 2, 0), EnergonRelics.REACTOR_CORE_BLOCK.getDefaultState()); set(new BlockPos(0, 2, 0), EnergonRelics.Blocks.REACTOR_CORE.getDefaultState());
set(new BlockPos(-1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState()); set(new BlockPos(-1, 2, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState());
set(new BlockPos(0, 3, 0), EnergonRelics.REACTOR_INPUT_BLOCK.getDefaultState()); set(new BlockPos(0, 3, 0), EnergonRelics.Blocks.REACTOR_INPUT.getDefaultState());
set(new BlockPos(0, 2, -1), EnergonRelics.REACTOR_CONTROLLER_BLOCK.getDefaultState()); set(new BlockPos(0, 2, -1), EnergonRelics.Blocks.REACTOR_CONTROLLER.getDefaultState());
set(new BlockPos(0, 1, -1), Blocks.LEVER.getDefaultState().with(LeverBlock.FACE, WallMountLocation.FLOOR)); set(new BlockPos(0, 1, -1), Blocks.LEVER.getDefaultState().with(LeverBlock.FACE, WallMountLocation.FLOOR));
set(new BlockPos(0, 2, 1), EnergonRelics.THERMAL_GLASS_BLOCK.getDefaultState()); set(new BlockPos(0, 2, 1), EnergonRelics.Blocks.THERMAL_GLASS.getDefaultState());
} }
@Override @Override
@ -105,10 +105,10 @@ public class ResearchComplexStartPart extends BaseResearchComplexPart {
@Override @Override
protected void handleBlockPlace(World world, BlockPos pos, BlockState state) { protected void handleBlockPlace(World world, BlockPos pos, BlockState state) {
super.handleBlockPlace(world, pos, state); super.handleBlockPlace(world, pos, state);
if (state.getBlock() == EnergonRelics.REACTOR_CONTROLLER_BLOCK) { if (state.getBlock() == EnergonRelics.Blocks.REACTOR_CONTROLLER) {
BlockEntity entity = world.getBlockEntity(pos); BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof ReactorControllerBlockEntity) { if (entity instanceof ReactorControllerBlockEntity) {
((ReactorControllerBlockEntity) entity).placeStack(EnergonRelics.NETWORK_CHIP_ITEM.create(getState().getMainNetwork()), world); ((ReactorControllerBlockEntity) entity).placeStack(EnergonRelics.Items.NETWORK_CHIP_ITEM.create(getState().getMainNetwork()), world);
} }
} }
} }

View File

@ -2,9 +2,11 @@ package com.thebrokenrail.energonrelics.util;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import org.jetbrains.annotations.ApiStatus;
import java.util.function.Consumer; import java.util.function.Consumer;
@ApiStatus.Internal
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class BooleanIterator { public class BooleanIterator {
public static void run(Consumer<Boolean> function) { public static void run(Consumer<Boolean> function) {

View File

@ -1,7 +1,7 @@
{ {
"parent": "minecraft:block/block", "parent": "minecraft:block/block",
"textures": { "textures": {
"0": "energonrelics:block/gold_block", "0": "minecraft:block/gold_block",
"1": "energonrelics:block/lightning_rod_base", "1": "energonrelics:block/lightning_rod_base",
"particle": "#1" "particle": "#1"
}, },
@ -53,8 +53,7 @@
"east": {"uv": [4, 3, 16, 5], "texture": "#1"}, "east": {"uv": [4, 3, 16, 5], "texture": "#1"},
"south": {"uv": [2, 2, 14, 4], "rotation": 180, "texture": "#1"}, "south": {"uv": [2, 2, 14, 4], "rotation": 180, "texture": "#1"},
"west": {"uv": [4, 3, 16, 5], "texture": "#1"}, "west": {"uv": [4, 3, 16, 5], "texture": "#1"},
"up": {"uv": [2, 2, 14, 14], "texture": "#1"}, "up": {"uv": [2, 2, 14, 14], "texture": "#1"}
"down": {"uv": [0, 0, 12, 12], "texture": "#missing"}
} }
}, },
{ {

View File

@ -2,7 +2,7 @@
"credit": "Made by Azazelthedemonlord", "credit": "Made by Azazelthedemonlord",
"textures": { "textures": {
"0": "energonrelics:block/lightning_rod", "0": "energonrelics:block/lightning_rod",
"particle": "energonrelics:block/gold_block" "particle": "minecraft:block/gold_block"
}, },
"elements": [ "elements": [
{ {

View File

@ -3,7 +3,7 @@
"textures": { "textures": {
"0": "energonrelics:block/lightning_rod", "0": "energonrelics:block/lightning_rod",
"1": "energonrelics:block/lightning_rod_base", "1": "energonrelics:block/lightning_rod_base",
"particle": "energonrelics:block/gold_block" "particle": "minecraft:block/gold_block"
}, },
"elements": [ "elements": [
{ {
@ -37,9 +37,7 @@
"to": [9, 12, 11], "to": [9, 12, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [15, 19, 20]}, "rotation": {"angle": 0, "axis": "y", "origin": [15, 19, 20]},
"faces": { "faces": {
"north": {"uv": [0, 0, 2, 1], "texture": "#missing"},
"east": {"uv": [1, 7, 2, 13], "rotation": 270, "texture": "#0"}, "east": {"uv": [1, 7, 2, 13], "rotation": 270, "texture": "#0"},
"south": {"uv": [0, 0, 2, 1], "texture": "#missing"},
"west": {"uv": [1, 7, 2, 13], "rotation": 270, "texture": "#0"}, "west": {"uv": [1, 7, 2, 13], "rotation": 270, "texture": "#0"},
"up": {"uv": [1, 2, 3, 8], "texture": "#0"}, "up": {"uv": [1, 2, 3, 8], "texture": "#0"},
"down": {"uv": [1, 8, 3, 14], "texture": "#0"} "down": {"uv": [1, 8, 3, 14], "texture": "#0"}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,3 @@
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Some files were not shown because too many files have changed in this diff Show More