BlesseNtumble / GalaxySpace

Addon for GalactiCraft 4
Apache License 2.0
68 stars 42 forks source link

Sublight/Ion engine is voided after removing rocket from launch pad #724

Open GalaxinTM opened 3 weeks ago

GalaxinTM commented 3 weeks ago

Do not remove this template, without it your issue will not be considered!

Please fill in the form below:

  1. Minecraft version: 1.12.2
  2. Galacticraft version: 4.0.6
  3. GalaxySpace version: 2.1.4
  4. AsmodeusCore version (for 2.0.1 version and above): 1.0.2
  5. Side (Single player (SSP), Multiplayer (SMP), or SSP opened to LAN (LAN)): SMP
  6. Other add-ons: MorePlanets, GalacticraftTweaker

    Description of the issue:

The rocket engine (Ion or Sublight) is voided after placing down and removing the rocket. It's good that the rocket keeps its engine after going to space like it normally does, but for the engine to be voided simply after removing it from the launch pad is a big problem.

What should happen:

What happens instead:


Screenshot/Video:

https://github.com/user-attachments/assets/b63e54e1-2408-4c63-a55d-f1dfa4e959ea


Attached log file (or url on pastebin.com):


GalaxinTM commented 3 weeks ago

I barely know anything about minecraft modding and how to use github in general, but I've dug into the code and found the code snippet

public List<ItemStack> getItemsDropped(List<ItemStack> droppedItems)
{
    super.getItemsDropped(droppedItems);
    ItemStack rocket = new ItemStack(GSItems.ROCKET_TIER_6, 1, this.rocketType.getIndex());
    rocket.setTagCompound(new NBTTagCompound());
    rocket.getTagCompound().setInteger("RocketFuel", this.fuelTank.getFluidAmount());
    droppedItems.add(rocket);
    return droppedItems;
}

This snippet does not account for the rocket engine being used in the rocket. It's missing a measure that accounts for the engine_type used. It affects rockets tier 4 and 5, as they can also have an Ion engine to boost their speed

GalaxinTM commented 2 weeks ago

I made a temporary fix using crafttweaker and zenutils

import mods.zenutils.event.EntityRemoveEvent;
import crafttweaker.world.IBlockPos;

events.onEntityRemove(function(event as EntityRemoveEvent){
    val entity = event.entity;
    val world = entity.world;
    if (("galacticraftcore:rocket_tier_4".matches(entity.definition.id) || "galacticraftcore:rocket_tier_5".matches(entity.definition.id) || "galacticraftcore:rocket_tier_6".matches(entity.definition.id)) && !world.isRemote() && 512 > entity.y) {
        if (entity.getNBT().engine_type == 3) {
            world.spawnEntity(<galaxyspace:rocket_modules:6>.createEntityItem(world, entity.position3f as IBlockPos)); // thanks friendlyhj
        } else if (entity.getNBT().engine_type == 1) {
            world.spawnEntity(<galaxyspace:rocket_modules:4>.createEntityItem(world, entity.position3f as IBlockPos));
        }
    }
});