Compare commits

..

No commits in common. "master" and "0.0.2+1.16.2-pre2" have entirely different histories.

149 changed files with 409 additions and 1812 deletions

View File

@ -1,90 +1,4 @@
# 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' sh './gradlew build javadoc publish'
} }
post { post {
success { success {
@ -24,18 +24,5 @@ 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,4 +18,3 @@ 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,6 +45,9 @@ 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}"
} }

View File

@ -1,27 +0,0 @@
# 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,13 +93,3 @@
## 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,5 +7,3 @@
[View Blocks](BLOCKS.md) [View Blocks](BLOCKS.md)
[View Structures](STRUCTURES.md) [View Structures](STRUCTURES.md)
[View API](API.md)

View File

@ -3,21 +3,22 @@ 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 minecraft_version = 1.16.2-pre2
curseforge_id = 398250 curseforge_id = 398250
simple_minecraft_version = 1.16.2 simple_minecraft_version = 1.16-Snapshot
yarn_build = 21 yarn_build = 1
fabric_loader_version = 0.9.2+build.206 fabric_loader_version = 0.9.0+build.204
# Mod Properties # Mod Properties
mod_version = 1.0.4 mod_version = 0.0.2
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.19.0+build.398-1.16 fabric_api_version = 0.16.4+build.392-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
roughlyenoughitems_version = 5.2.3 libstructure_version = 1.4.1
roughlyenoughitems_version = 5.1.0-unstable
jetbrains_annotations_version = 19.0.0 jetbrains_annotations_version = 19.0.0

View File

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

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.Items.ITEM_GROUP; return EnergonRelics.ITEM_GROUP;
} }
/** /**

View File

@ -1,25 +1,17 @@
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;
@ -43,35 +35,4 @@ 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.Items.NETWORK_CHIP_ITEM) { if (stack.getItem() == EnergonRelics.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.Extras.playBeep(world, pos); EnergonRelics.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.Extras.playBeep(world, pos); EnergonRelics.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.Items.NETWORK_CHIP_ITEM.getID(stack) == network; return isEnergyProvider() && EnergonRelics.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.Items.NETWORK_CHIP_ITEM) { if (isEnergyProvider() && stack.getItem() == EnergonRelics.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.Items.NETWORK_CHIP_ITEM.getID(stack)); List<BlockPosWithDimension> sources = component.getSourcesPos(EnergonRelics.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.Items.NETWORK_CHIP_ITEM.getID(stack), newPos); component.removeSource(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack), newPos);
} else { } else {
component.addSource(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack), newPos); component.addSource(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack), newPos);
} }
} }

View File

@ -51,11 +51,7 @@ 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) {
if (action.amountOwed() > 0) {
provider.addPropagatedAction(action); provider.addPropagatedAction(action);
} else {
action.pay(0);
}
} }
} else { } else {
action.pay(0); action.pay(0);

View File

@ -14,17 +14,13 @@ 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,25 +14,14 @@ import java.util.Objects;
/** /**
* Energy Ticker * Energy Ticker
*/ */
public final class EnergyTicker { @ApiStatus.Internal
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);
} }
@ -41,15 +30,12 @@ public final 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);
@ -57,7 +43,7 @@ public final 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); world.getProfiler().push(() -> tickable.getID() + " startTick");
temp2.addAll(tickable.startTick()); temp2.addAll(tickable.startTick());
started.add(tickable); started.add(tickable);
@ -65,25 +51,14 @@ public final class EnergyTicker {
world.getProfiler().pop(); world.getProfiler().pop();
} }
} }
temp.clear();
List<EnergyTickable> temp3 = temp; temp.addAll(temp2);
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); world.getProfiler().push(() -> tickable.getID() + " logicTick");
tickable.logicTick(); tickable.logicTick();
@ -91,11 +66,7 @@ public final class EnergyTicker {
} }
world.getProfiler().pop(); world.getProfiler().pop();
world.getProfiler().pop();
} }
scheduled.clear(); scheduled.clear();
allLoaded = Collections.emptyList();
} }
} }

View File

@ -1,14 +0,0 @@
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

@ -1,131 +0,0 @@
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,27 +22,26 @@ 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).with(ACTIVE, false)); setDefaultState(getDefaultState().with(POWERED, false));
} }
@Override @Override
public BlockState getPlacementState(ItemPlacementContext ctx) { public BlockState getPlacementState(ItemPlacementContext ctx) {
return getDefaultState().with(ACTIVE, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos())); return getDefaultState().with(POWERED, 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(ACTIVE); boolean bl = state.get(POWERED);
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(ACTIVE), 2); world.setBlockState(pos, state.cycle(POWERED), 2);
} }
} }
} }
@ -50,14 +49,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(ACTIVE) && !world.isReceivingRedstonePower(pos)) { if (state.get(POWERED) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, state.cycle(ACTIVE), 2); world.setBlockState(pos, state.cycle(POWERED), 2);
} }
} }
@Override @Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(POWERED, ACTIVE); builder.add(POWERED);
} }
@Override @Override

View File

@ -5,6 +5,7 @@ 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;
@ -48,7 +49,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
if (hasWorld()) { if (hasWorld()) {
return super.getCachedState(); return super.getCachedState();
} else { } else {
return EnergonRelics.Blocks.DEFENSIVE_LASER.getDefaultState(); return EnergonRelics.DEFENSIVE_LASER_BLOCK.getDefaultState();
} }
} }
@ -179,7 +180,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 = new DamageSource(EnergonRelics.NAMESPACE + ".defensive_laser").setScaledWithDifficulty().setExplosive(); private static final DamageSource DAMAGE_SOURCE = DamageSourceAccessor.createDamageSource(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,7 +5,6 @@ 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;
@ -26,7 +25,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 (int) (((float) light) * Math.max(0, MathHelper.cos(Objects.requireNonNull(getWorld()).getSkyAngleRadians(1f)))); return light;
} }
@Override @Override

View File

@ -3,11 +3,8 @@ 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);
@ -15,11 +12,6 @@ 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
@ -39,6 +31,6 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
} }
private boolean isActive() { private boolean isActive() {
return getCachedState().get(SwitchBlock.ACTIVE) && getCachedState().get(SwitchBlock.POWERED); return 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.Blocks.THERMAL_GLASS) && !block.isOf(EnergonRelics.Blocks.THERMAL_CASING); return !block.isOf(EnergonRelics.THERMAL_GLASS_BLOCK) && !block.isOf(EnergonRelics.THERMAL_CASING_BLOCK);
} }
@Override @Override

View File

@ -5,7 +5,6 @@ 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;
@ -21,14 +20,14 @@ import net.minecraft.world.explosion.Explosion;
import java.util.Objects; import java.util.Objects;
public class IndustrialLaserProjectorBlockEntity extends FieldProjectorBlockEntity { public class IndustrialLaserBlockEntity extends FieldProjectorBlockEntity {
private BlockPos targetPos; private BlockPos targetPos;
private BlockState targetState; private BlockState targetState;
private int progress = 0; private int progress = 0;
public IndustrialLaserProjectorBlockEntity(BlockEntityType<?> type) { public IndustrialLaserBlockEntity(BlockEntityType<?> type) {
super(type, state -> EnergonRelics.Blocks.INDUSTRIAL_LASER); super(type, state -> EnergonRelics.INDUSTRIAL_LASER_BLOCK);
} }
@Override @Override
@ -56,17 +55,16 @@ public class IndustrialLaserProjectorBlockEntity extends FieldProjectorBlockEnti
TntBlock.primeTnt(getWorld(), targetPos); TntBlock.primeTnt(getWorld(), targetPos);
getWorld().setBlockState(targetPos, Blocks.AIR.getDefaultState()); getWorld().setBlockState(targetPos, Blocks.AIR.getDefaultState());
if (progress != 0) {
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.Blocks.VERIDIUM_ORE) { if (targetState.getBlock() == EnergonRelics.VERIDIUM_ORE_BLOCK) {
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

@ -1,4 +1,4 @@
package com.thebrokenrail.energonrelics.registry.laser; package com.thebrokenrail.energonrelics.block.entity.forcefield.laser;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
@ -13,19 +13,10 @@ 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;
@ -34,27 +25,14 @@ public class IndustrialLaserRegistry {
return new ItemStack(ingot, count); return new ItemStack(ingot, count);
}); });
if (storage != null) {
map.put(storage, random -> new ItemStack(ingot, HardcodedConfig.INDUSTRIAL_LASER_INGOTS_FROM_STORAGE)); 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);
} }
@ -64,9 +42,8 @@ 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.Blocks.VERIDIUM_ORE, EnergonRelics.Items.VERIDIUM_INGOT, EnergonRelics.Blocks.VERIDIUM_BLOCK); add(EnergonRelics.VERIDIUM_ORE_BLOCK, EnergonRelics.VERIDIUM_INGOT_ITEM, EnergonRelics.VERIDIUM_BLOCK_BLOCK);
} }
} }

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 MultimeterExtra { public class InfuserBlockEntity extends EnergyReceiverBlockEntity implements MultimeterItem.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.Blocks.ENERGY_BEAM); super(type, state -> EnergonRelics.ENERGY_BEAM_BLOCK);
} }
@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.Blocks.ENERGIZED_OBSIDIAN.getDefaultState(); targetState = EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK.getDefaultState();
getWorld().setBlockState(targetPos, targetState); getWorld().setBlockState(targetPos, targetState);
} else { } else {
isObsidian = targetState.getBlock() == EnergonRelics.Blocks.ENERGIZED_OBSIDIAN; isObsidian = targetState.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK;
} }
if (isObsidian) { if (isObsidian) {

View File

@ -17,7 +17,7 @@ public class ReactorInputBlockEntity extends BlockEntity implements Inventory {
super(type); super(type);
} }
public final static int INVENTORY_SIZE = 5; private final 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

@ -1,267 +0,0 @@
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

@ -1,34 +0,0 @@
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,7 +20,6 @@ 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;
@ -32,14 +31,12 @@ 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;
@ -48,17 +45,12 @@ 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.Blocks.FORCEFIELD_PROJECTOR.getDefaultState(); return EnergonRelics.FORCEFIELD_PROJECTOR_BLOCK.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.Blocks.FORCEFIELD); super(state -> EnergonRelics.FORCEFIELD_BLOCK);
} }
} }

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.Blocks.REPULSOR_BEAM : EnergonRelics.Blocks.TRACTOR_BEAM); super(state -> state.get(IS_REPULSOR) ? EnergonRelics.REPULSOR_BEAM_BLOCK : EnergonRelics.TRACTOR_BEAM_BLOCK);
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.Blocks.INDUSTRIAL_LASER_PROJECTOR.getDefaultState(); return EnergonRelics.INDUSTRIAL_LASER_PROJECTOR_BLOCK.getDefaultState();
} }
private static class IndustrialLaserDamageSource extends DamageSource { private static class IndustrialLaserDamageSource extends DamageSource {
@ -47,11 +47,7 @@ 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) {
if (!entity.isFireImmune()) {
entity.setOnFireFor(8);
entity.damage(DAMAGE_SOURCE, HardcodedConfig.INDUSTRIAL_LASER_BEAM_DAMAGE); 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.IndustrialLaserProjectorBlockEntity; import com.thebrokenrail.energonrelics.block.entity.forcefield.laser.IndustrialLaserBlockEntity;
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 IndustrialLaserProjectorBlockEntity::new; return IndustrialLaserBlockEntity::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.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)); 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));
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.Blocks.TRACTOR_BEAM_PROJECTOR.getDefaultState().with(TractorBeamProjectorBlock.IS_REPULSOR, isRepulsor); return EnergonRelics.TRACTOR_BEAM_PROJECTOR_BLOCK.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.Blocks.LIGHTNING_ROD || newState.get(LightningRodBlock.HALF) != DoubleBlockHalf.LOWER)) { if (direction == Direction.UP && (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || 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.Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.UPPER)); world.setBlockState(pos.up(2), EnergonRelics.LIGHTNING_ROD_BLOCK.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.UPPER));
world.setBlockState(pos.up(1), EnergonRelics.Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.LOWER)); world.setBlockState(pos.up(1), EnergonRelics.LIGHTNING_ROD_BLOCK.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.Blocks.LIGHTNING_ROD_BASE).dropsNothing().emissiveLighting((state, world, pos) -> true).lightLevel(state -> 10)); super(FabricBlockSettings.copy(EnergonRelics.LIGHTNING_ROD_BASE_BLOCK).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.Blocks.LIGHTNING_ROD || newState.get(HALF) != DoubleBlockHalf.UPPER) { if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(HALF) != DoubleBlockHalf.UPPER) {
valid = false; valid = false;
} }
} else if (direction == Direction.DOWN) { } else if (direction == Direction.DOWN) {
if (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD_BASE) { if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) {
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.Blocks.LIGHTNING_ROD || newState.get(HALF) != DoubleBlockHalf.LOWER) { if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || 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.Blocks.LIGHTNING_ROD_BASE) { if (targetState.getBlock() == EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) {
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.Blocks.LIGHTNING_ROD_BASE.asItem(); return EnergonRelics.LIGHTNING_ROD_BASE_BLOCK.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.Blocks.ENERGY_BEAM || state.getBlock() == EnergonRelics.Blocks.ENERGY_PROJECTOR) && state.contains(Properties.FACING)) { if ((state.getBlock() == EnergonRelics.ENERGY_BEAM_BLOCK || state.getBlock() == EnergonRelics.ENERGY_PROJECTOR_BLOCK) && 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.Blocks.ENERGY_PROJECTOR.getDefaultState(); return EnergonRelics.ENERGY_PROJECTOR_BLOCK.getDefaultState();
} }
} }

View File

@ -7,12 +7,10 @@ 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;
@ -29,7 +27,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.of(Material.PORTAL).strength(-1f, 3600000.8f).lightLevel(11).sounds(BlockSoundGroup.GLASS).dropsNothing().emissiveLighting((state, world, pos) -> true).noCollision()); super(FabricBlockSettings.copy(Blocks.NETHER_PORTAL).dropsNothing().emissiveLighting((state, world, pos) -> true).noCollision());
} }
@Override @Override
@ -49,7 +47,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.Blocks.ENERGIZED_OBSIDIAN; return state.getBlock() == Blocks.OBSIDIAN || state.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK;
} }
public static boolean isValidFrame(WorldAccess world, BlockPos centerPos) { public static boolean isValidFrame(WorldAccess world, BlockPos centerPos) {
@ -58,7 +56,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.Blocks.ENERGIZED_OBSIDIAN) { if (energizedObsidian.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK) {
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)) {
@ -74,7 +72,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.Blocks.ENERGY_PORTAL) { if (world.getBlockState(pos.offset(side)).getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK) {
centerPos = centerPos.offset(side.getOpposite()); centerPos = centerPos.offset(side.getOpposite());
} }
} }
@ -87,7 +85,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.Blocks.ENERGY_PORTAL) { if (world.getBlockState(startPos.add(x, 0, z)).getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK) {
valid = false; valid = false;
break; break;
} }
@ -101,7 +99,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.Blocks.ENERGY_PORTAL && !state.isAir()) { if (state.getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK && !state.isAir()) {
return; return;
} }
} }
@ -109,7 +107,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.Blocks.ENERGY_PORTAL.getDefaultState(), 3 | 16); world.setBlockState(startPos.add(x, 0, z), EnergonRelics.ENERGY_PORTAL_BLOCK.getDefaultState(), 3 | 16);
} }
} }
} }
@ -142,13 +140,11 @@ 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);
World entityWorld = entity.getEntityWorld(); 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)) {
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) entityWorld, entity.getPos(), pos, entity); EnergyTeleporter.teleport((ServerWorld) world, entity.getPos(), pos, entity);
} }
} }
} }

View File

@ -2,7 +2,6 @@ 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;
@ -14,25 +13,20 @@ 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 e) { } catch (CommandSyntaxException ignored) {
throw new RuntimeException(e);
}
if (entity instanceof ServerPlayerEntity) {
((ServerPlayerEntity) entity).networkHandler.syncWithPlayerPosition();
} }
} }
@ -40,6 +34,8 @@ 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);
@ -50,18 +46,38 @@ class EnergyTeleporter {
} }
if (entity instanceof ServerPlayerEntity) { if (entity instanceof ServerPlayerEntity) {
((ServerPlayerEntity) entity).playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, SoundCategory.PLAYERS, 0.25f, world.random.nextFloat() * 0.4f + 0.8f); ServerPlayerEntity player = world.getServer().getPlayerManager().getPlayer(uuid);
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 newY = (int) (((float) newHeight / (float) oldHeight) * (float) y); int bottomPadding = HardcodedConfig.ENERGY_PORTAL_Y_PADDING;
int topPadding = bottomPadding + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP;
int bottomY = HardcodedConfig.ENERGY_PORTAL_Y_PADDING; int oldMax = oldHeight - topPadding;
int topY = newHeight - (bottomY + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP);
newY = Math.max(bottomY, Math.min(topY, newY));
return newY; y = MathHelper.clamp(y, bottomPadding, oldMax);
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,7 +22,6 @@ 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));
@ -34,6 +33,7 @@ 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,9 +45,4 @@ 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,12 +23,10 @@ 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.Biome; import net.minecraft.world.biome.GenerationSettings;
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;
@ -100,12 +98,10 @@ 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);
if (world instanceof ServerWorld) { schedule(world, pos);
schedule((ServerWorld) world, pos);
}
} }
public void schedule(StructureWorldAccess world, BlockPos pos) { public void schedule(World world, BlockPos pos) {
world.getBlockTickScheduler().schedule(pos, this, 0); world.getBlockTickScheduler().schedule(pos, this, 0);
} }
@ -120,26 +116,22 @@ 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);
FabricStructureBuilder.create(new Identifier(EnergonRelics.NAMESPACE, name), block.feature).step(GenerationStep.Feature.UNDERGROUND_STRUCTURES).defaultConfig(block.structureConfig).superflatFeature(block.feature.configure(FeatureConfig.DEFAULT)).register(); LibStructure.registerStructure(new Identifier(EnergonRelics.NAMESPACE, name), block.feature, GenerationStep.Feature.UNDERGROUND_STRUCTURES, block.structureConfig, block.feature.configure(FeatureConfig.DEFAULT));
} }
public static void registerBlocks() { public static void register() {
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(Biome biome) { public static void addToBiome(GenerationSettings.Builder builder) {
registerStructures();
for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) { for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) {
ConfiguredStructureFeature<?, ?> feature = entry.getValue().feature.configure(DefaultFeatureConfig.INSTANCE); builder.structureFeature(entry.getValue().feature.configure(DefaultFeatureConfig.INSTANCE));
biome.getGenerationSettings().getStructureFeatures().add(() -> feature);
} }
} }
public static void registerStructures() { static {
if (blocks.size() == 0) {
create("research_complex", (world, random, transformations) -> new ResearchComplexStartPart(new ResearchComplexState(world, random), transformations), new StructureConfig(32, 8, 14357618)); create("research_complex", (world, random, transformations) -> new ResearchComplexStartPart(new ResearchComplexState(world, random), transformations), new StructureConfig(32, 8, 14357618));
} }
}
} }

View File

@ -19,23 +19,17 @@ 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;
private StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos, boolean placed) { StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos) {
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")), tag.getBoolean("Placed")); this(block, BlockRotation.valueOf(tag.getString("Rot")), new BlockPos(tag.getInt("X"), tag.getInt("Y"), tag.getInt("Z")));
} }
@Override @Override
@ -44,12 +38,10 @@ 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) {
if (!placed) {
BlockState state = block.getDefaultState().rotate(rotation); BlockState state = block.getDefaultState().rotate(rotation);
world.setBlockState(pos, state, 3); world.setBlockState(pos, state, 3);
@ -58,10 +50,7 @@ class StructureGeneratorPiece extends StructurePiece {
((StructureGeneratorBlockEntity) entity).setSeed(random.nextLong()); ((StructureGeneratorBlockEntity) entity).setSeed(random.nextLong());
} }
block.schedule(world, pos); block.schedule(world.toServerWorld(), pos);
placed = true;
}
return true; return true;
} }
} }

View File

@ -1,11 +1,9 @@
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;
@ -14,7 +12,6 @@ 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;
@ -43,26 +40,22 @@ public final class EnergonRelicsClient implements ClientModInitializer {
public void onInitializeClient() { public void onInitializeClient() {
EnergyBlock.initRenderer(); EnergyBlock.initRenderer();
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.THERMAL_GLASS, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.THERMAL_GLASS_BLOCK, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.DEFENSIVE_LASER, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.DEFENSIVE_LASER_BLOCK, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.FORCEFIELD, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.FORCEFIELD_BLOCK, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.TRACTOR_BEAM, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.TRACTOR_BEAM_BLOCK, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.REPULSOR_BEAM, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.REPULSOR_BEAM_BLOCK, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.INDUSTRIAL_LASER, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.INDUSTRIAL_LASER_BLOCK, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.ENERGY_PORTAL, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_PORTAL_BLOCK, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.ENERGY_BEAM, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_BEAM_BLOCK, 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.Blocks.ENERGY_PORTAL) { if (state.getBlock() instanceof AbstractFieldBlock || state.getBlock() == EnergonRelics.ENERGY_PORTAL_BLOCK) {
return ActionResult.FAIL; return ActionResult.FAIL;
} else { } else {
return ActionResult.PASS; return ActionResult.PASS;

View File

@ -22,6 +22,7 @@ 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);
@ -43,7 +44,7 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
MinecraftClient client = MinecraftClient.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
client.getItemRenderer().renderItem(new ItemStack(EnergonRelics.Items.DEFENSIVE_LASER_CORE), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers); client.getItemRenderer().renderItem(new ItemStack(EnergonRelics.DEFENSIVE_LASER_CORE_ITEM), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers);
matrices.pop(); matrices.pop();
@ -60,6 +61,5 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
matrices.pop(); matrices.pop();
} }
} }
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
} }
} }

View File

@ -3,8 +3,6 @@ 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;
@ -17,7 +15,6 @@ 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;
@ -26,14 +23,13 @@ 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().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)); 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));
} }
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"));
@ -46,78 +42,39 @@ 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.Items.NETWORK_CHIP_ITEM) { if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) {
boolean contains = ((EnergyReceiverBlockEntity) entity).contains(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack)); boolean contains = ((EnergyReceiverBlockEntity) entity).contains(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack));
Matrix4f matrix4f = matrices.peek().getModel();
if (!contains) { if (!contains) {
renderCuboid(entity, matrices, vertexConsumers.getBuffer(UNSELECTED_LAYER)); renderLayer(entity, matrix4f, vertexConsumers.getBuffer(UNSELECTED_LAYER));
} else { } else {
renderCuboid(entity, matrices, vertexConsumers.getBuffer(SELECTED_LAYER)); renderLayer(entity, matrix4f, vertexConsumers.getBuffer(SELECTED_LAYER));
} }
} }
} }
matrices.pop(); matrices.pop();
} }
private static boolean shouldDrawSide(BlockEntity entity, Direction side) { private void renderLayer(BlockEntity 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);
}
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);
} }
protected static void renderCuboid(BlockEntity entity, MatrixStack matrices, VertexConsumer consumer) { 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) {
float sizeX = 1f;
float sizeY = 1f;
float sizeZ = 1f;
matrices.translate(0.5d, 0.5d, 0.5d);
for (Direction side : Direction.values()) {
if (shouldDrawSide(entity, side)) { if (shouldDrawSide(entity, side)) {
matrices.push(); vertexConsumer.vertex(matrix4f, f, h, j).color(1f, 1f, 1f, 1f).next();
vertexConsumer.vertex(matrix4f, g, h, k).color(1f, 1f, 1f, 1f).next();
multiply(matrices, side); vertexConsumer.vertex(matrix4f, g, i, l).color(1f, 1f, 1f, 1f).next();
vertexConsumer.vertex(matrix4f, f, i, m).color(1f, 1f, 1f, 1f).next();
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,10 +12,12 @@ 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)
@ -67,9 +69,27 @@ 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();
renderCuboid(entity, matrixStack, vertexConsumerProvider.getBuffer(LAYER)); renderLayer((HolographicSkyBlockEntity) entity, matrix4f, 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,22 +3,16 @@ 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 INFUSING = new Identifier(EnergonRelics.NAMESPACE, "plugin/infusing"); public static final Identifier INFUSER = new Identifier(EnergonRelics.NAMESPACE, "plugin/infuser");
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
@ -28,17 +22,8 @@ public final class EnergonRelicsPlugin implements REIPluginV0 {
@Override @Override
public void registerOthers(RecipeHelper recipeHelper) { public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(INFUSING, EntryStack.create(EnergonRelics.Blocks.INFUSER)); recipeHelper.registerWorkingStations(INFUSER, EntryStack.create(EnergonRelics.INFUSER_BLOCK));
recipeHelper.registerWorkingStations(REACTOR_FUEL, EntryStack.create(EnergonRelics.Blocks.REACTOR_INPUT)); recipeHelper.registerWorkingStations(REACTOR_FUEL, EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK));
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 + ".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 + 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 + 18), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infusing.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 + ".infuser.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.output.getItem()); Identifier outputID = Registry.ITEM.getId(display.getResultingEntries().get(0).get(0).getItem());
Text text = new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infusing.display_item." + outputID.getNamespace() + "." + outputID.getPath()); Text text = new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".infuser.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.INFUSING; return EnergonRelicsPlugin.INFUSER;
} }
@Override @Override
public EntryStack getLogo() { public EntryStack getLogo() {
return EntryStack.create(EnergonRelics.Blocks.INFUSER); return EntryStack.create(EnergonRelics.INFUSER_BLOCK);
} }
@Override @Override
public String getCategoryName() { public String getCategoryName() {
return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".infusing.name"); return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".infuser.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;
public final EntryStack output; private 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,16 +35,12 @@ public class InfuserDisplay implements RecipeDisplay {
@Override @Override
public List<List<EntryStack>> getResultingEntries() { public List<List<EntryStack>> getResultingEntries() {
if (outputsItem) {
return Collections.singletonList(Collections.singletonList(output)); return Collections.singletonList(Collections.singletonList(output));
} else {
return Collections.emptyList();
}
} }
@Override @Override
public Identifier getRecipeCategory() { public Identifier getRecipeCategory() {
return EnergonRelicsPlugin.INFUSING; return EnergonRelicsPlugin.INFUSER;
} }
@Override @Override

View File

@ -8,15 +8,11 @@ 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;
@ -54,7 +50,7 @@ public class ReactorFuelCategory implements RecipeCategory<ReactorFuelDisplay> {
@Override @Override
public EntryStack getLogo() { public EntryStack getLogo() {
return EntryStack.create(EnergonRelics.Blocks.REACTOR_INPUT); return EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK);
} }
@Override @Override
@ -62,33 +58,6 @@ 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,7 +2,6 @@ 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
@ -10,16 +9,14 @@ import net.minecraft.util.DyeColor;
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 = 70; public static final long SOLAR_PANEL_MAX_ENERGY_OUTPUT = 50;
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 = 350; public static final int REACTOR_ENERGY_OUTPUT = 250;
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;
@ -56,15 +53,4 @@ 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

@ -1,17 +0,0 @@
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,7 +3,6 @@ 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;
@ -19,7 +18,11 @@ 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.Items.ITEM_GROUP)); super(new Settings().maxCount(1).group(EnergonRelics.ITEM_GROUP));
}
public interface MultimeterExtra {
MutableText getExtra();
} }
public static MutableText format(long value) { public static MutableText format(long value) {
@ -58,13 +61,10 @@ 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) {
MutableText extraText = ((MultimeterExtra) entity).getExtra();
if (extraText != null) {
if (success) { if (success) {
text.append(separator); 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.Extras.playBeep(world, context.getBlockPos()); EnergonRelics.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.Items.ITEM_GROUP)); super(new Settings().maxCount(1).group(EnergonRelics.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.Extras.playBeep(world, context.getBlockPos()); EnergonRelics.playBeep(world, context.getBlockPos());
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {
return ActionResult.PASS; return ActionResult.PASS;

View File

@ -0,0 +1,13 @@
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

@ -1,20 +0,0 @@
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

@ -1,16 +0,0 @@
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,6 +1,7 @@
package com.thebrokenrail.energonrelics.mixin; package com.thebrokenrail.energonrelics.mixin;
import com.thebrokenrail.energonrelics.feature.CustomFeatures; import com.thebrokenrail.energonrelics.EnergonRelics;
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;
@ -13,6 +14,11 @@ 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, CustomFeatures.VERIDIUM_ORE_FEATURE); builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, EnergonRelics.VERIDIUM_ORE_FEATURE);
}
@Inject(at = @At("RETURN"), method = "addDefaultUndergroundStructures")
private static void addDefaultUndergroundStructures(GenerationSettings.Builder builder, CallbackInfo info) {
StructureGeneratorBlock.addToBiome(builder);
} }
} }

View File

@ -5,7 +5,6 @@ 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;
@ -27,8 +26,6 @@ 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();
@ -42,8 +39,6 @@ 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);
@ -51,22 +46,17 @@ 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) {
pos.set(p, q, r); BlockPos pos = new BlockPos(p, q, r);
BlockState state = getEntityWorld().getBlockState(pos); if (test.test(getEntityWorld().getBlockState(pos).getBlock())) {
if (state.getCollisionShape(getEntityWorld(), pos).isEmpty() && test.test(state.getBlock())) {
getEntityWorld().getProfiler().pop();
return true; return true;
} }
} }
} }
} }
} }
getEntityWorld().getProfiler().pop();
return false; return false;
} }
@ -75,7 +65,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 (!saving && touchingBeam) { if (isTouching(block -> block instanceof BeamBlock) && !saving) {
info.setReturnValue(true); info.setReturnValue(true);
} }
} }
@ -96,15 +86,12 @@ 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 tickReturn(CallbackInfo info) { public void tick(CallbackInfo info) {
if (!isTouching(block -> block == EnergonRelics.ENERGY_PORTAL_BLOCK) && energyPortalCooldown > 0) {
energyPortalCooldown--; energyPortalCooldown--;
} }
}
@Override @Override
public void resetEnergyPortalCooldown() { public void resetEnergyPortalCooldown() {

View File

@ -1,47 +0,0 @@
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,9 +25,4 @@ 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

@ -1,11 +0,0 @@
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.Items.VERIDIUM_POWDER, VERIDIUM_POISON_EFFECT.potion); BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.VERIDIUM_POWDER_ITEM, 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.Items.NETWORK_CHIP_ITEM && !foundChip) { if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM && !foundChip) {
foundChip = true; foundChip = true;
} else if (stack.getItem() == EnergonRelics.Items.CIRCUIT_BOARD && !foundCircuit) { } else if (stack.getItem() == EnergonRelics.CIRCUIT_BOARD_ITEM && !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.Items.NETWORK_CHIP_ITEM) { if (stack.getItem() == EnergonRelics.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.Items.NETWORK_CHIP_ITEM) { } else if (stack.getItem() == EnergonRelics.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.Extras.DUPLICATE_NETWORK_CHIP_RECIPE; return EnergonRelics.DUPLICATE_NETWORK_CHIP_RECIPE;
} }
} }

View File

@ -103,14 +103,12 @@ 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.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_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_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(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(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

@ -43,8 +43,8 @@ public final class ReactorFuelRegistry {
} }
static { static {
add(EnergonRelics.Items.VERIDIUM_INGOT, 1f); add(EnergonRelics.VERIDIUM_INGOT_ITEM, 1f);
add(EnergonRelics.Blocks.VERIDIUM_BLOCK.asItem(), 9f); add(EnergonRelics.VERIDIUM_BLOCK_BLOCK.asItem(), 9f);
add(EnergonRelics.Items.VERIDIUM_POWDER, 0.25f); add(EnergonRelics.VERIDIUM_POWDER_ITEM, 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.Blocks.ENERGON_LIGHT.getDefaultState(); BlockState light = EnergonRelics.ENERGON_LIGHT_BLOCK.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.Blocks.ENERGON_LIGHT) { if (state.getBlock() == EnergonRelics.ENERGON_LIGHT_BLOCK) {
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.Blocks.ENERGON_LIGHT.getDefaultState()); set(new BlockPos(3, 5, 1), EnergonRelics.ENERGON_LIGHT_BLOCK.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.Blocks.ENERGON_LIGHT.getDefaultState()); set(new BlockPos(2, yOffset, 2), EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState());
} }
} }
private void buildReactor() { private void buildReactor() {
set(new BlockPos(0, 1, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState()); set(new BlockPos(0, 1, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
set(new BlockPos(1, 2, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState()); set(new BlockPos(1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
set(new BlockPos(0, 2, 0), EnergonRelics.Blocks.REACTOR_CORE.getDefaultState()); set(new BlockPos(0, 2, 0), EnergonRelics.REACTOR_CORE_BLOCK.getDefaultState());
set(new BlockPos(-1, 2, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState()); set(new BlockPos(-1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
set(new BlockPos(0, 3, 0), EnergonRelics.Blocks.REACTOR_INPUT.getDefaultState()); set(new BlockPos(0, 3, 0), EnergonRelics.REACTOR_INPUT_BLOCK.getDefaultState());
set(new BlockPos(0, 2, -1), EnergonRelics.Blocks.REACTOR_CONTROLLER.getDefaultState()); set(new BlockPos(0, 2, -1), EnergonRelics.REACTOR_CONTROLLER_BLOCK.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.Blocks.THERMAL_GLASS.getDefaultState()); set(new BlockPos(0, 2, 1), EnergonRelics.THERMAL_GLASS_BLOCK.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.Blocks.REACTOR_CONTROLLER) { if (state.getBlock() == EnergonRelics.REACTOR_CONTROLLER_BLOCK) {
BlockEntity entity = world.getBlockEntity(pos); BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof ReactorControllerBlockEntity) { if (entity instanceof ReactorControllerBlockEntity) {
((ReactorControllerBlockEntity) entity).placeStack(EnergonRelics.Items.NETWORK_CHIP_ITEM.create(getState().getMainNetwork()), world); ((ReactorControllerBlockEntity) entity).placeStack(EnergonRelics.NETWORK_CHIP_ITEM.create(getState().getMainNetwork()), world);
} }
} }
} }

View File

@ -2,11 +2,9 @@ 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": "minecraft:block/gold_block", "0": "energonrelics:block/gold_block",
"1": "energonrelics:block/lightning_rod_base", "1": "energonrelics:block/lightning_rod_base",
"particle": "#1" "particle": "#1"
}, },
@ -53,7 +53,8 @@
"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": "minecraft:block/gold_block" "particle": "energonrelics: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": "minecraft:block/gold_block" "particle": "energonrelics:block/gold_block"
}, },
"elements": [ "elements": [
{ {
@ -37,7 +37,9 @@
"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.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 863 B

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